Alter table to Add default auto increment primary key 'id' in Phinx migration

1k Views Asked by At

I had created a table in a Phinx migration using

$table = $this->table('verification', ['id' => false, 'primary_key' => ['validation_id']]);
$table->addColumn('validation_id','string',['limit' => 15, 'null' => false])
        ->addColumn('status','string', ['null' => true])
    >create();

Now in a separate migration I want to alter the table and set that id value to true and make that id as primary key (default behaviour). And make validation_id as a unique index.

I know how to do it by dropping the table first and creating new table. But I don't want to drop the table, just alter it. How to alter table to add back the auto increment default id column?

0

There are 0 best solutions below