-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Fix #6557: Avoid redundant column migrations when using type aliases #7652
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
base: master
Are you sure you want to change the base?
Conversation
|
Migration: smarter SQL‐type alias detection & loop fix to avoid redundant ALTERs Improves how the migrator recognises equivalent column types that are expressed through driver-specific aliases (e.g. Key Changes• Enhanced Affected Areas• This summary was automatically generated by @propel-code-bot |
|
Hi @DasJott Can you add some tests? |
What did this pull request do?
Improves the mapping of types to aliases.
The mapping keys do not (and CAN not) include any additional information behind the actual type name.
Therefore to check for aliases in a certain mapping we need to strip that info off, like:
varchar(255)[] => varchar.To really be sure for the mapping to work reliably the types are mapped best in both ways, like:
varchar => character varying,character varying => varchar.For at least postgres this was not the case for exactly that case.
For not having to touch all the other driver packages, this code simply tries to map the other way around when the first attempt failed.
User Case Description
We had a data struct containing a field
pq.StringArraywithgorm:"type:varchar[]". That type was returned by postgres ascharacter varying[]. The current code could not map that correctly and therefore on every service restart an unnecessary migration was started (which took very long on a table containing millions of entries).This is fixed with this PR.