Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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!

like image 762
hjcoder18 Avatar asked Jan 20 '17 19:01

hjcoder18


1 Answers

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();
like image 182
AlbinoDrought Avatar answered Nov 03 '22 09:11

AlbinoDrought