4

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();
JazzCat
  • 4,243
  • 1
  • 26
  • 40

1 Answers1

9

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])
sdexp
  • 756
  • 4
  • 18
  • 36
ndm
  • 59,784
  • 9
  • 71
  • 110