Skip to content

migrate --expect-additive refuses a NOT NULL column that carries a default — #805's tags.kind can never deploy #904

Done

Description

@athvin

What happened

Deploy of 350cd213 (#805, system tags) failed in deploy dev (ci namespace): the er-schema-migrate pre-upgrade hook exited 3 — BackoffLimitExceeded (the hook runs backoffLimit: 0, so one refusal fails the release) — and --atomic rolled the release back. Run: https://github.com/athvin/entity-resolution-engine/actions/runs/42516648310

Root cause (reproduced locally)

er-server migrate --expect-additive plans live-store vs catalog before any fixup runs, and er-entity-diff classifies a missing NOT NULL column as Breaking unconditionally:

rust/crates/er-entity-diff/src/lib.rs — "adding a nullable column is safe; a NOT NULL add needs a default (breaking here)".

#805 added tags.kind text NOT NULL DEFAULT 'user', so the dev store's plan is breaking and the gate refuses — correctly, per its rule. The 0005_tag_kind fixup inside ensure_schema never runs because the gate exits first. Every release containing #805 is undeployable until this is fixed.

Repro (exact hook invocation against a store aged to pre-#805):

verdict: breaking (catalog 73637fbf2edd)
1 statement(s) would be applied:
  public.tags: ALTER TABLE public.tags ADD COLUMN apply_min_role text;
1 difference(s) the reconciler REFUSES to auto-apply:
  public.tags: column kind is absent; add column
EXIT=3

The fix the code already describes

Two comments say the rule was meant to be default-aware: the differ's own "(breaking here)" aside, and ReconcileError::Breaking's doc — "a NOT NULL column added without a default". Make both true: a missing NOT NULL column with a declared default is Safe on Postgres, and add_column_sql emits the full fragment (ADD COLUMN kind text NOT NULL DEFAULT 'user';).

Safety argument (the one 0005_tag_kind's doc already makes): pg ≥ 11 fills existing rows from the default metadata-only; old code's INSERTs name their columns (E011), so the default fills kind for them; old SELECTs enumerate known columns. Control-plane tables are small — the data with volume lives in the lake, not this store — so even a volatile default's rewrite cannot hold the hook past its 600s deadline in practice.

Verify

Activity

  1. added
    bug
    on Nov 8, 2026
  2. self-assigned this
    on Nov 8, 2026
  3. athvin commented on Nov 8, 2026

    @athvin
    OwnerAuthor

    Claimed — working in #905 (draft). Closing that PR releases the claim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions