I notice Phinx already add this feature into createDatabase, but createTable didn't have this feature.
I hope when createTable it also can choose character and collate, I test it if I create database first, and didn't set character as UTF-8, it will use the database default charset.
I think it also need have default character and collate when create table.
+1
I just encountered this as well. As of 2016, Phinx automatically creates tables with a UTF8 encoding鈥攔egardless of what's set in your phinx.yml/.php/etc.鈥攗nless you pass in an options array to the table() method (or run setOptions() on the table object). This confused the heck out of me while trying to set up a project to use utf8mb4.
I agree with the above that it should automatically use the default character set/collation setting when creating a new table, but barring that, perhaps a note about passing the option to the Table object could be added to the documentation? I'm happy to provide a pull request and add it, if so.
Thanks!
I just encountered the same issue today and I thought it was a bug with MySQL...
A pull request to define the default charset in the config file exists since March : #810
In fact, Phinx defines the engine and the collation with "InnoDB" and "utf8_general_ci" by default if they're not set explicitly when you create a new table.
@chrisvanpatten, thank you for the tip with setOptions() :)
It helped me to find a way to write my migration like I wanted.
I think the documentation should be completed too. Maybe a future PR ;)
Closing due to lack of activity or out of scope. If there is new interest, please open a PR.
Most helpful comment
I just encountered this as well. As of 2016, Phinx automatically creates tables with a UTF8 encoding鈥攔egardless of what's set in your phinx.yml/.php/etc.鈥攗nless you pass in an options array to the
table()method (or runsetOptions()on the table object). This confused the heck out of me while trying to set up a project to use utf8mb4.I agree with the above that it should automatically use the default character set/collation setting when creating a new table, but barring that, perhaps a note about passing the option to the Table object could be added to the documentation? I'm happy to provide a pull request and add it, if so.
Thanks!