【问题标题】:Change column in table have an enum type in postgres表中的更改列在 postgres 中具有枚举类型
【发布时间】:2019-02-20 22:59:25
【问题描述】:

这是我的代码:

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

我想重命名表中的列。并且在这个表中有一个列是枚举类型。但错误:未知数据库类型 company_roles 请求,Doctrine\DBAL\Platforms\PostgreSQL100Platform 可能
不支持。我使用 laravel 5.6

【问题讨论】:

标签: php laravel postgresql doctrine laravel-migrations


【解决方案1】:

此问题可能与 Laravel 文档中提到的“您无法重命名具有 'enum' 类型的表中的列”有关。见:

恐怕这就像 Laravel 使用的 Doctrine/DBal 5 年前的问题,请参阅:[Bug] Schema builder - renameColumn fails on table with enum columns 但其中一种解决方法也在同一个问题报告DB Query 上。作为参考,我把它放在这里:

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

在这种情况下,您需要在迁移类文件的down() 函数中提供正确的语句来恢复表的状态。

【讨论】:

    猜你喜欢
    • 2021-01-08
    • 2023-01-20
    • 1970-01-01
    • 1970-01-01
    • 2018-12-30
    • 2021-12-22
    • 1970-01-01
    • 1970-01-01
    • 2019-05-26
    相关资源
    最近更新 更多