cakephp - Biginteger auto_increment 主键 Phinx

标签 cakephp auto-increment phinx

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

我正在使用 罗伯摩根菲尼克斯 创建迁移。

创建表后,是否可以将数据类型为 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();

最佳答案

没有auto_increment选项,见
https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-options
您要找的是identity选项,这将引用

enable or disable automatic incrementing

->changeColumn('id', 'biginteger', ['identity' => true])

关于cakephp - Biginteger auto_increment 主键 Phinx,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34767268/

相关文章:

php - 从数组中动态加载 mysql 表字段

php - MySQL/Html 编码

php - 保存记录时,这个简单的转换是否安全?

MySQL-DBI : How to tell if the first column is an auto increment column?

mysql - 如何让MySQL表的主键自增?

php - Cakephp 只加载一个 .css 文件 - 403-Error 所有其他

mysql - 函数执行时mysql字段的值递增

php - fatal error : Call to a member function run() on null in {path to the test file}

php - Phinx迁移SQLSTATE[42S01] : Base table or view already exists:

symfony - TYPO3 Composer 依赖冲突