Search code examples
mysqlenumsmigrationphinx

Adding a 'enum' MySQL field type with Phinx Migrate


I'm trying to create a migration in Phinx (actually a rollback) which will create a enum type field in a MySQL DB. Having read the docs I was under the impression that this should be pretty simple but it just fails every time.

$table = $this->table('mytable');
$table->addColumn('warmth','enum', array('limit' => array('1', '2', '3', '4', '5', 'P', 'A', 'B', 'C', 'D', 'X', 'N')))
->save();

Unfortunately there's no easy way to have Phinx output the offending SQL query either.


Solution

  • Use latest version from master (above 0.5.x-dev):

    $this->table('my_table')
    ->addColumn('status', 'enum', ['values' => ['enabled', 'disabled']])
    ->save();