Skip to content

[OU-ADD] iap: backfill service_id from legacy service_name#37

Draft
dnplkndll wants to merge 1 commit into
19.0from
19.0-mig-iap-pre-migration
Draft

[OU-ADD] iap: backfill service_id from legacy service_name#37
dnplkndll wants to merge 1 commit into
19.0from
19.0-mig-iap-pre-migration

Conversation

@dnplkndll
Copy link
Copy Markdown

What this scope covers

Adds openupgrade_scripts/scripts/iap/19.0.1.1/post-migration.py to backfill iap_account.service_id from the preserved legacy service_name column for rows that an earlier major-version migration left in a half-migrated state.

Why

Surfaced in lab make migrate against our prod-seed via:

WARNING odoo.schema: Missing not-null constraint on iap.account.service_id

The 18.0 and 19.0 ORM definitions of iap.account are actually identical (service_id = Many2one(required=True), service_name = Char(related=...)). The mismatch comes from earlier — the openupgrade_legacy_18_0_service_name column on our seed shows the rename happened in 17→18 — and one stale row from 2020 never received a service_id value. 19.0's _auto_init then tries to add NOT NULL and warns when the orphan blocks it.

Any DB carrying that same shape (legacy_service_name preserved, service_id NULL) hits the same warning. The backfill defensively maps both.

What's in the patch

  • openupgrade_scripts/scripts/iap/19.0.1.1/post-migration.py — a single UPDATE … FROM iap_service statement that joins on technical_name via openupgrade.get_legacy_name("service_name").
  • docsource/modules180-190.rst — sets the iap row to Done so the test workflow picks it up.

No upgrade_analysis_work.txt (precedent: barcodes_gs1_nomenclature/19.0.1.0, digest/19.0.1.1, pos_discount/19.0.1.0 all ship post-migration.py without a work file when the analysis bot didn't generate a delta).

Reproducing

The analysis bot doesn't flag this — the gap is invisible at the ORM-definition level and only surfaces when a real seed carries orphan rows. To reproduce the warning before the patch:

docker compose exec -T db psql -U odoo -d <seed> -c "
  SELECT COUNT(*) FILTER (WHERE service_id IS NULL) AS null_rows,
         COUNT(*) AS total
    FROM iap_account
   WHERE openupgrade_legacy_18_0_service_name IS NOT NULL;"

A null_rows > 0 count indicates the same shape as our seed.

How to verify

After this branch lands in repos.yaml and make sync-repos:

make seed-prod && make migrate
# Expect: no "Missing not-null constraint on iap.account.service_id" in
# /tmp/migrate-iter.log; "Modules loaded." + "Registry loaded in <N>s."
# at the tail.

docker compose exec -T db psql -U odoo -d ou_iter -c \
  "SELECT COUNT(*) FILTER (WHERE service_id IS NULL) FROM iap_account;"
# Expect: 0

Adds openupgrade_scripts/scripts/iap/19.0.1.1/post-migration.py to map
the openupgrade_legacy_18_0_service_name column onto iap_account.service_id
for rows left half-migrated by an earlier major-version upgrade.

DBs in this shape have rows where service_id IS NULL despite 19.0's
required=True declaration, producing a "Missing not-null constraint on
iap.account.service_id" warning at schema sync. The backfill resolves
those rows by matching the preserved legacy service_name against
iap_service.technical_name.

Marks the iap row in docsource/modules180-190.rst as Done.
@dnplkndll dnplkndll force-pushed the 19.0-mig-iap-pre-migration branch from 212e9f0 to 1f8b453 Compare May 27, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant