Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Biginteger auto_increment primary key Phinx

I am trying to create a migration with a biginteger-primary key and switch it to auto_increment.

I am using robmorgans Phinx to create the migration.

Is it possible to change a table's primary key of the datatype BIGINTEGER to be auto_incremented after you've created it?

Currently it looks like this.

$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();
like image 585
JazzCat Avatar asked Feb 08 '23 01:02

JazzCat


1 Answers

There is no auto_increment option, see

https://book.cakephp.org/phinx/0/en/migrations.html#valid-column-options

What you are looking for is the identity option, which will, quote

enable or disable automatic incrementing

->changeColumn('id', 'biginteger', ['identity' => true])
like image 114
ndm Avatar answered Feb 12 '23 22:02

ndm