Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,20 @@ def hr_candidate2hr_applicant(env):
"""
openupgrade.merge_models(env.cr, "hr.candidate", "hr.applicant", "candidate_id")
openupgrade.rename_tables(env.cr, [("hr_candidate", None)])
openupgrade.lift_constraints(
env.cr, openupgrade.get_legacy_name("hr_candidate"), "id", cascade=True
legacy_table = openupgrade.get_legacy_name("hr_candidate")
# PostgreSQL >= 17 catalogs NOT NULL as a named constraint and refuses to
# drop it while the column is still part of a primary key, even when the
# pkey drop is queued in the same ALTER TABLE statement (as
# openupgrade.lift_constraints does). Drop the pkey first, on its own, so
# the remaining lift_constraints() call only has the not-null constraint
# left to lift.
env.cr.execute(
"alter table {} drop constraint if exists {} cascade".format(
legacy_table, legacy_table + "_pkey"
)
)
openupgrade.remove_tables_fks(env.cr, [openupgrade.get_legacy_name("hr_candidate")])
openupgrade.lift_constraints(env.cr, legacy_table, "id", cascade=True)
openupgrade.remove_tables_fks(env.cr, [legacy_table])


@openupgrade.migrate()
Expand Down
Loading