hieu pham ba
hieu pham ba

Reputation: 113

Change column in table have an enum type in postgres

This is my code:

public function up()
{
    Schema::table('organization_user', function (Blueprint $table) {
        $table->renameColumn('company_id', 'organization_id');
    });
}

I want to rename column in table. And in this table have an column is enum type. But errors: Unknown database type company_roles requested, Doctrine\DBAL\Platforms\PostgreSQL100Platform may
not support it. I use laravel 5.6

Upvotes: 1

Views: 904

Answers (1)

omitobi
omitobi

Reputation: 7334

This issue may be related to what is mentioned in Laravel Docs "You can't rename columns in the table that has 'enum' type". See: enter image description here

I am afraid this is like 5 years old issue with Doctrine/DBal that Laravel uses see:[Bug] Schema builder - renameColumn fails on table with enum columns But one of the workarounds is also on the same issue report DB Query. For reference sake I'll put it here:

DB::statement("ALTER TABLE table_name MODIFY COLUMN column_name ENUM('Here','is','choices')");

In this case, you need to provide the right statement in the down() function of your migration class file to restore the state of the table.

Upvotes: 1

Related Questions