Upgrade with MySQL backend : "Data too long for column 'carddata'"
dominiquefournier opened this issue · comments
I try to migrate my old 3.3 version to 4.3. I have a MySQL backend
When updating the schemes, the error raised :
bin/console doctrine:migrations:migrate
WARNING! You are about to execute a migration in database "cal" that could result in schema changes and data loss. Are you sure you wish to continue? (yes/no) [yes]:
>
[notice] Migrating up to DoctrineMigrations\Version20231229203515
[notice] Migration DoctrineMigrations\Version20221211154443 skipped during Execution. Reason: "This migration is specific to 'sqlite'. Skipping it is fine."
[notice] Migration DoctrineMigrations\Version20230209142217 skipped during Execution. Reason: "This migration is specific to 'postgresql'. Skipping it is fine."
[error] Migration DoctrineMigrations\Version20231001214111 failed during Execution. Error: "An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'carddata' at row 35"
07:29:47 CRITICAL [console] Error thrown while running command "doctrine:migrations:migrate". Message: "An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'carddata' at row 35" ["exception" => Doctrine\DBAL\Exception\DriverException^ { …},"command" => "doctrine:migrations:migrate","message" => "An exception occurred while executing a query: SQLSTATE[22001]: String data, right truncated: 1406 Data too long for column 'carddata' at row 35"]
The conversion from longblob to text doesn't works.
The SQL request is : ALTER TABLE cards CHANGE carddata carddata TEXT DEFAULT NULL; from Version20231001214111.php
The provided id has an image and the size is 100ko. The TEXT field has 64KB max. The LONGBLOB should be converted to LONGTEXT (4Go max)
If I do it manually, the migration works.
Hi @dominiquefournier 👋🏼
Guess what: #127 :)
I could change the old migration to allow MEDIUM TEXT directly but it's a bit tricky and would likely break existing installations or new migration runs. I will release the next version this week though.
Hi @thapi
Thanks to point his, I didn't saw it.
You are right, but the upgrade process crash on Version20231001214111.php if data already exists.
You may update this file too.
You may update this file too.
I may do this yes, but changing a previous migration is not really recommended. I'll test further
Done here