How do you change the Collation of a column using Phinx
Asked Answered
S

1

11

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!

Sustainer answered 20/1, 2017 at 19:7 Comment(0)
H
10

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();
Hispaniola answered 12/7, 2017 at 19:21 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.