I'm using Symfony 4 with a MySQL database (5.5.57-0ubuntu0.14.04.1) that doesn't support JSON type.
When I map a field to "json" using a Doctrine yml config file, the migration file generatet by doctrine:migrations:diff uses JSON MySQL type instead of LONGTEXT and it ends up with an error if I try to run the migration.
And every time a make a migration diff, I have to manually change JSON to LONGTEXT for the last changes and remove the changes to JSON as a result of older changes.
It's easy to screw up if in one of these migrations you forget to remove the "ALTER TABLE CHANGE somefield JSON".
My solution, at the moment, is to add in the doctrine.yml config file the following:
doctrine:
dbal:
mapping_types:
longtext: json
It makes some weird, but easy to track and remove, changes when I run doctrine:migrations:diff -v , like changing to LONGTEXT some couple of fields that were already LONGTEXT. I don't know why and I have to fix it this eventually.
But, at least, I could stop doctrine from trying to change my longtext to MySQL json data type that are mapped as doctrine json data type.
Did someone came across this problem?
Thanks!
I was wrong by using the "mapping_types" configartion that way. It make not sense. The solution It's even more easy, and I didn't realize the following parameter exists:
server_version
Just add the server version on the dbal configuration like this:
doctrine:
dbal:
driver: 'pdo_mysql'
server_version: '5.5.57'
charset: utf8mb4
default_table_options:
charset: utf8mb4
collate: utf8mb4_unicode_ci
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With