Search code examples
migrationpostgislaravel-9

Laravel9 column change migration on Postgis does not work


I need to change column type in Postgis database. Column is of type char(1) and I want to set up varchar(50). So I wrote this migration. There are two varians and none of then works.

    public function up()
    {
        DB::raw("ALTER TABLE $this->voucher_groups_table ALTER COLUMN person_limit_type TYPE VARCHAR(50)");
        DB::raw("ALTER TABLE $this->voucher_groups_table ALTER COLUMN person_limit_type SET DEFAULT NULL");

        Schema::table($this->voucher_groups_table, function(Blueprint $table) {
            $table->string('person_limit_type', 50)->nullable()->change();
        });
    }

Mirgration pass with success but database table contains still the same type char(1). How is that possible?


Solution

  • It seems the only way to do it is use

    DB::statement()