-
Notifications
You must be signed in to change notification settings - Fork 76
[FIX] util: fix constraint removal in postgres 18 #337
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
upgrade-util
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added by mistake I guess
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ho yes
) | ||
""", | ||
[new_table, old_table.replace("_", r"\_") + r"\_%"], | ||
[new_table, '%s_id_not_null' % old_table, old_table.replace("_", r"\_") + r"\_%"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could check cr._cnx.server_version >= 180000
and ignore only in that case.
Nit: old_table + '_id_not_null'
upgradeci retry with always only mail bus |
8707c8a
to
f654b2b
Compare
Since postgres 18 the not null on a field is an explicit constraint named tablename_colname_not_null. When trying to drop all constraint from a model, an error occurs when trying to drop the id primary key not null constraint. ALTER TABLE "mail_presence" DROP CONSTRAINT IF EXISTS "bus_presence_id_not_null" ERROR: column "id" is in a primary key This commit filters the constraints to remove the id not null one. We may want to make this filter generic on all not null constraint
f654b2b
to
4ee367d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that I have the same error when trying to restore a database from a runbot build, so not only an upgrade issue
Since postgres 18 the not null on a field is an explicit constraint named tablename_colname_not_null.
When trying to drop all constraint from a model, an error occurs when trying to drop the id primary key not null constraint.
This commit filters the constraints to remove the id not null one.
We may want to make this filter generic on all not null constraint.