在迁移中使用postgreSQL重命名列

时间:2017-01-25 11:02:24

标签: postgresql laravel laravel-5 doctrine laravel-migrations

我尝试在迁移中重命名列:

\Schema::table('invitations', function (Blueprint $table) {
    $table->renameColumn('service_id', 'project_id');
});

运行此结果时出错:

  

请求了未知的数据库类型jsonb,Doctrine \ DBAL \ Platforms \ PostgreSQL92Platform可能不支持它。

我的表格为jsonb列,我认为这是问题,但我不知道为什么会出现此问题(因为service_id不是jsonb列)。

如何重命名我的专栏?(为什么它与我写的内容无关?)

1 个答案:

答案 0 :(得分:0)

我为MySQL编写了类似的迁移,恕我直言,与Psql没有区别。 函数renameColumn()仅适用于Doctrine \ DBAL`,我不想将此依赖项添加到项目中。所以我这样做了

DB::transaction( function () {
    DB::raw('ALTER TABLE invitations RENAME COLUMN service_id TO project_id');
});

抱歉我的英文。

相关问题