-
-
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
Preventing incorrect column renames no longer possible in 4.0 #6299
Comments
We could make that configurable. Detecting renames is fuzzy, so the requirement to disable that feature seems reasonable to me. Up for a PR? |
Sure. That would be for version 4.1.0 I guess, right? |
Yes. However, we could think about backporting the API to 3.x if that makes the upgrade from 3.x to 4.x easier. But let's target 4.1.x first. |
Done: #6300 |
My PR does not remove the rename detection even if an explicit renaming has been provided (maybe it should?) but if a column is explicitly renamed then those 2 particular columns shouldn't be taken into account during the detection |
We (Contao) use the doctrine schema manager to update the database schema after updates or after installing an extension. In this case the user can not alter the result of the comparator (like it would be possible using doctrine migrations) so if an incorrect rename was detected there would be no way to intervene. (Most users would probably also not recognise the wrong rename). We had many issues with this in the past (see also #3661) but we since used the workaround as outlined in #6299 (comment) and this worked flawlessly ever since.
No, as the rename detection is still in place and there is no option to disable it. |
Since the detection is made from dropped columns and added columns of the same type, I'm thinking of an alternative, which would be to tag dropped columns, when doing |
The problem is we never do a manual |
You could still iterate over the tables and columns in the old schema to set the flag Or an in between, we add a configuration in the SchemaConfig of Table so the iteration is only on the tables Otherwise I don't have anything against the comparator config but I do think it should indeed be as a state to limit the signature changes, the comparator class is not final and only the constructor is internal, so it's still allowed to be extended it seems which means a signature change of public or protected methods would indeed be a breaking change |
Addressed all review comments there, so this should be ready. 🎉 |
Bug Report
Summary
With doctrine 3.x we use the
onSchemaAlterTableRenameColumn
event in order to disable automatic column renaming.The code looks like this (basically reversing what
Comparator::detectRenamedColumns()
does):Now the event is gone in version 4.0 and it looks like there is no other way to influence this behavior.
I thought of decorating the
SchemaManagerFactory
so that it returns a decoratedSchemaManager
that returns a decoratedComparator
. But even then, there would be no way to decorateComparator::compareTables()
as it returns an immutableTableDiff
that cannot be instantiated as the constructor is marked@internal
. So I’d have to create a decoratedTableDiff
as well.This approach would mean, if in a future version any of the classes
SchemaManager
,Comparator
orTableDiff
get a new method, it will fail. (Because there are no interfaces for these 3 classes)Is there a better way to do this?
I basically just want to disable
Comparator::detectRenamedColumns()
so that it never detects a rename of a column.The text was updated successfully, but these errors were encountered: