-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Version 2.9.2 keeps generating the same migration on an index where a length is defined on a varchar column #3419
Comments
|
Great Scott! |
Is it some MariaDB-specific behavior? It's definitely not something we account for. From the details above, it's not clear where the |
Additionally, could you please check if recreating the index without specified length produces any warnings and if your DB setup has some strict mode components disabled. See the article:
|
Hi guys I'm currently on a machine with 10.2.19-MariaDB and the bug doesn't appear here. Also no If I have to guess where the More potential related info:
I should probably update to a newer version of MySQL/MariaDB, or enable the But not sure what doctrine/dbal should do about this. In 2.9.1 it worked and was probably unintentionally changed in 2.9.2. Not sure how important this is or if other users also run against this? Disclaimer: I know very little about all these little database configuration thingies, so take everything I'm saying with a grain of salt, I'm only getting this from a bit of googling around :) |
Hello, I got the same issue. This is due (I guess) to this commit: d807849 I got the following diff: DROP INDEX rule_action_formatted_source_idx ON rule_action;
CREATE INDEX rule_action_formatted_source_idx ON rule_action (formatted_source);
DROP INDEX rule_project_source_input_idx ON rule;
DROP INDEX rule_formatted_source_idx ON rule;
CREATE INDEX rule_project_source_input_idx ON rule (project_id, source_input);
CREATE INDEX rule_formatted_source_idx ON rule (formatted_source); and when I play the migration, I got this exception:
I have updated my entity to add the lengths option * @ORM\Index(name="rule_action_formatted_source_idx", columns={"formatted_source"}, options={"lengths": {255}}), Then I got this diff DROP INDEX rule_action_formatted_source_idx ON rule_action;
CREATE INDEX rule_action_formatted_source_idx ON rule_action (formatted_source(255));
DROP INDEX rule_project_source_input_idx ON rule;
DROP INDEX rule_formatted_source_idx ON rule;
CREATE INDEX rule_project_source_input_idx ON rule (project_id, source_input);
CREATE INDEX rule_formatted_source_idx ON rule (formatted_source); Now I can play it, but doctrine keeps telling the DB is not in sync and generate the same diff server information:
|
I dont think this is MariaDB specific, having same issues with MySQL 5.7 - where I have manually added the index length. Given that its not possible to define the length in doctrine mappings not sure how that can be solved. EDIT I just found that it is possible to specify the length, although this isn't documented anywhere,
But this still having this bug, e.g. i get this again and again
|
Same issue here with MariaDB 10.3 and dbal 2.9.2. I locked my composer.json to dbal 2.8 for now: |
I can confirm this issue with mysql 5.6.47 and aws aurora. The index gets truncated and if you run the database with I haven't looked too deep into it but This will get more difficult when dealing with multi column indexes. I'd look into what mysql does in that situation. Maybe evenly distribute the available bytes across fields? There could be int fields... maybe it's not that easy |
This problem occurred to me while switching to utf8mb4. Fixed it setting the index length to 190:
Or by setting the indexed string column length to 190. Both seem to work. The schema seems to be in sync after this change. |
Bug Report
Summary
I just updated to version 2.9.2 of doctrine/dbal and started noticing that when running
bin/console doctrine:migrations:diff
it generated a new migration, then runningbin/console doctrine:migrations:migrate
followed by anotherbin/console doctrine:migrations:diff
generates the exact same migration again.This didn't happen in version 2.9.1
This is my first time opening an issue here, so if some info is missing which can help you, please let me know.
How to reproduce
Using 10.0.33-MariaDB
server_version
is not defined in the configuration (doctrine.yaml
).Have a database table with the following format:
Running
bin/console doctrine:migrations:diff
generates the following migration:Notice the length of the varchar column
queue
is not specified in the index here, but gets set when executing the migration. Everytime a diff is generated, it doesn't see the length of this field in the index.The entity class is something like this:
Thanks!
The text was updated successfully, but these errors were encountered: