Biginteger auto_increment主键Phinx

时间:2016-01-13 12:52:32

标签: cakephp auto-increment phinx

我正在尝试使用biginteger-primary键创建迁移并将其切换为 auto_increment

我正在使用 robmorgans Phinx 来创建迁移。

是否可以在创建数据类型BIGINTEGER后将表的主键更改为auto_incremented?

目前它看起来像这样。

$positions = $this->table('positions', ['id' => false, 'primary_key' => 'id'])
        ->changeColumn('id', 'biginteger', ['auto_increment' => true])
        ->addColumn('work_order_id', 'char', ['after' => 'vehicle_id','default' => null, 'null' => true,'limit' => 36])
        ->update();

1 个答案:

答案 0 :(得分:6)

没有auto_increment选项,请参阅

<强> http://docs.phinx.org/en/latest/migrations.html#valid-column-options

您正在寻找的是identity选项,它将引用

  

启用或禁用自动递增

<强> http://docs.phinx.org/en/latest/migrations.html?highlight=identity#valid-column-options

->changeColumn('id', 'biginteger', ['identity' => true])
相关问题