Skip to content

fix(ci): repair qty-precision migration trigger dependency + regenerate stale workflow docs#333

Merged
OneTwo3D merged 2 commits into
developmentfrom
ci/fix-migration-trigger-and-stale-workflow-docs
Jun 21, 2026
Merged

fix(ci): repair qty-precision migration trigger dependency + regenerate stale workflow docs#333
OneTwo3D merged 2 commits into
developmentfrom
ci/fix-migration-trigger-and-stale-workflow-docs

Conversation

@OneTwo3D

Copy link
Copy Markdown
Owner

Fixes the two pre-existing CI blockers that were red on every PR (not introduced by recent work — no recent PR touched migrations).

1. Migration trigger dependency (the real blocker)

20260619120000_cost_layer_qty_precision_14_6 alters stock_movements.qty to numeric(14,6), but the stock_movements_reporting_evidence_guard constraint trigger (20260602103000) lists qty in its UPDATE OF ... qty ... column set, so Postgres refuses: cannot alter type of a column used in a trigger definition (P3018). prisma migrate deploy failed on a fresh DB, blocking e2e-select, invariant-preflight, and schema-guardrails(fresh-db-drift) entirely. Fix: drop the trigger around the column rewrite, recreate it identically (trigger function unchanged). Only stock_movements.qty has a column-scoped trigger; the other widened columns have none.

2. Stale workflow docs

docs/workflows.md was out of date (failing docs-workflows). Regenerated.

Validation: the fresh-db-drift job (migrate deploy on a fresh DB) is the real test — it was skipped on prior PRs since they didn't touch prisma/**. Watching CI.

Migration-checksum note: this migration has been red in CI since it merged, so it has almost certainly never applied cleanly anywhere; any env that recorded it applied needs prisma migrate resolve before its next deploy.

🤖 Generated with Claude Code

…te stale workflow docs

Two pre-existing CI blockers (red on every PR; not introduced by recent work):

1. Migration 20260619120000_cost_layer_qty_precision_14_6 alters stock_movements.qty
   to numeric(14,6), but the stock_movements_reporting_evidence_guard constraint
   trigger (20260602103000) lists qty in its 'UPDATE OF ... qty ...' column set, so
   Postgres refuses: 'cannot alter type of a column used in a trigger definition'
   (P3018). prisma migrate deploy failed on a fresh DB, blocking the e2e-select,
   invariant-preflight, and schema-guardrails(fresh-db-drift) jobs entirely. Drop the
   trigger around the column rewrite and recreate it identically (the trigger function
   is unchanged). Only stock_movements.qty had a column-scoped trigger; the other
   widened columns have none.

2. docs/workflows.md was out of date, failing the docs-workflows check. Regenerated
   via npm run docs:workflows.

NOTE: editing an in-sequence migration changes its checksum. This migration has been
red in CI since it merged, so it has almost certainly never applied cleanly via
migrate deploy anywhere; on any environment that did record it applied, run
'prisma migrate resolve' before the next deploy.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@OneTwo3D OneTwo3D force-pushed the ci/fix-migration-trigger-and-stale-workflow-docs branch from 50ad095 to 7c1d100 Compare June 21, 2026 16:52

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 50ad095de6

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

ALTER COLUMN "quantity" TYPE numeric(14,6),
ALTER COLUMN "reservedQty" TYPE numeric(14,6);

-- The stock_movements_reporting_evidence_guard constraint trigger (migration

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Add the schema-scope marker so migration-scope passes

On a PR this still trips the schema guard before the fresh-db job: .github/workflows/schema-guardrails.yml runs node scripts/check-prisma-schema-scope.mjs "origin/${{ github.base_ref }}" HEAD, and that script fails any changed prisma/migrations/**/migration.sql without a matching prisma/schema.prisma change unless the migration file contains an exact -- prisma-schema-scope-ok: db-native... comment. I reproduced node scripts/check-prisma-schema-scope.mjs e510de09f37f7ae09e2174cb2ec030d62b947d43^ e510de09f37f7ae09e2174cb2ec030d62b947d43, and this migration is reported as unchecked, so the CI blocker remains for any PR carrying this trigger-only edit.

Useful? React with 👍 / 👎.

…QL (42P18)

The inventory invariant SQL collector passed STRANDED_TRANSFER_DAYS into a
jsonb_build_object value position without a type cast, so Postgres could not
determine the bind parameter's type ('could not determine data type of
parameter $42') and the whole inventory invariant report failed at runtime.
This surfaced only now that the migration fix lets invariant-preflight reach the
report on a fresh DB (unit tests use mocked clients, so the raw query never ran).
Cast it ::int, matching the same constant's already-cast use in the WHERE clause.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@OneTwo3D OneTwo3D merged commit a7f8984 into development Jun 21, 2026
11 of 12 checks passed
@OneTwo3D OneTwo3D deleted the ci/fix-migration-trigger-and-stale-workflow-docs branch June 21, 2026 17:32
OneTwo3D pushed a commit that referenced this pull request Jun 21, 2026
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