-
-
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
Generated migrations confused by columnDefinition that contains GENERATED ALWAYS AS #6641
Comments
digging into this a bit more, I can now see that what's stored in
Then we can work out that it's identical and there is no remaining "unknown" part to the columnDefinition, so there's no diff. The other possibility might be to have a (new) command to compare the current Doctrine schema with the current Database (possibly only for fields that have columnDefinitions) and make suggestions of how the columnDefinitions in PHP-space could be changed to match what's currently in the database. The idea would be that this command could be run after the migration - the coder could then modify the detail of their columnDefinition to make it easier for Doctrine to diff it. e.g. here we could change the columnDefinition to At the moment there's no way even to mark a columnDefinition as "do not check" so we get (a lot of) false positives... we have many dozens of generated columns in the database. At the moment they have to be deleted manually every time we generate a migration... I'm not sure how best to help here... I'd like to help tidy this up, but this seems like a very technical part of the code, and I'm not entirely sure how it all fits together, or how it plays nicely with other platforms' code. Is it the right approach to add more detail in |
ugh... I think I found the immediate issue... it's that (none of) our generated fields have Now we can actually use this "feature" to tag fields that have new GENERATED code (by removing However, if you think the approach outlined above is sensible then I could do some work to try and detect actual changes to generated code added through columnDefinitions. (Of course, it would be even better to have a separate attribute parameter for generated fields... but I appreciate that it might not be cross-platform!) |
Bug Report
Summary
When using
make:migration
to generate migrations, fields which use columnDefinitions end up generating the same up() statement every time (even after the migration has been run).Current behavior
Field attribute is something like this:
Generated migration looks something like this:
When you run the migration everything works. But when you generate the next migration it tries to make the same changes again.
Expected behavior
When you generate the next migration, Doctrine should recognise that it is trying to make a change that has already been done and not add the
GENERATED ALWAYS...
code to the next migrationHow to reproduce
Add a columnDefinition to a field, generate migration, run it then generate the next migration.
I tried looking in the Comparator but struggled to find the detail. In
diffColumn()
I can see that$column2['columnDefinition']
is blank compared to$column1['columnDefinition']
which contains theGENERATED ALWAYS
code, but I don't fully understand where$column2
comes from or whyConnection::getSchema()
would return a blank columnDefinition...The text was updated successfully, but these errors were encountered: