[FIX] util: fix constraint removal in postgres 18#337
Draft
Xavier-Do wants to merge 1 commit intoodoo:masterfrom
Draft
[FIX] util: fix constraint removal in postgres 18#337Xavier-Do wants to merge 1 commit intoodoo:masterfrom
Xavier-Do wants to merge 1 commit intoodoo:masterfrom
Conversation
Contributor
aj-fuentes
reviewed
Oct 9, 2025
aj-fuentes
reviewed
Oct 9, 2025
| ) | ||
| """, | ||
| [new_table, old_table.replace("_", r"\_") + r"\_%"], | ||
| [new_table, '%s_id_not_null' % old_table, old_table.replace("_", r"\_") + r"\_%"], |
Contributor
There was a problem hiding this comment.
You could check cr._cnx.server_version >= 180000 and ignore only in that case.
Nit: old_table + '_id_not_null'
Contributor
|
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
william-andre
left a comment
There was a problem hiding this comment.
Note that I have the same error when trying to restore a database from a runbot build, so not only an upgrade issue
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.