Search code examples
collationphinx

How do you change the Collation of a column using Phinx


I just started learning Phinx, and I am needing to change the collation of a column to latin1_swedish_ci. I'm not finding documentation on how to do this. I'm assuming it would be similar to:

->addColumn('text_two', 'string', ['collation' => 'latin1_swedish_ci'])

However, I have seen some talk that this feature wasn't implemented yet. https://github.com/robmorgan/phinx/issues/661

If anyone has any ways around this, that would be great!


Solution

  • This feature has been implemented as of 0.7.0.

    To change the collation of an existing column foo in the table bar to latin1_swedish_ci, it would look like this:

    $this->table('bar')
        ->changeColumn('foo', 'string', array(
            'collation' => 'latin1_swedish_ci',
        ))
        ->update();