Skip to content

rating: run integration conformance against the REAL migration DDL#27

Merged
hhuuggoo merged 1 commit into
release-2026.02.01from
hugo/rating-schema-single-source
Jun 17, 2026
Merged

rating: run integration conformance against the REAL migration DDL#27
hhuuggoo merged 1 commit into
release-2026.02.01from
hugo/rating-schema-single-source

Conversation

@hhuuggoo

Copy link
Copy Markdown
Contributor

What

The live-Postgres conformance test (TestIntegration_* / TestConformance_*) proves the rater's production SQL computes correct money — but it ran against a hand-copied schemaDDL constant, not the migration that ships. The sync between the two was enforced by a human reading two files. A column-type or index-expression drift between the copy and the migration would pass green here and break in prod — exactly the silent wrong-money failure this test exists to catch.

Change

Replace the hand-copied constant with ratingSchemaDDL(t), which loads the real migration files (migrations/0001_billing_event.sql then 0002_rating.sql — production apply order; base_model is declared in 0001 and re-added IF NOT EXISTS in 0002_rating, a harmless overlap). The schema can no longer drift from production: a migration change is picked up by the conformance test automatically. The old constant is kept, renamed schemaDDLReference, as a readable in-file description only.

The CI integration-test job (postgres:16 service) was already wired but tested a copy — it now tests the real schema on every PR.

Verification

  • Builds with -tags=integration, go vet clean.
  • Full conformance suite passes against a throwaway postgres:16 loading the migration DDL.
  • Non-integration unit suite unaffected.

Contracts

None. Test-only change — no schema, API, or behavior change. It tightens what the existing test validates against (a copy → the real migration).

…on DDL

The live-Postgres conformance test (TestIntegration_*/TestConformance_*) proved
the rater's production SQL computes correct money — but against a hand-copied
`schemaDDL` constant, not the migration that actually ships. The migration
comments said "keep the two in sync"; that sync was enforced by a human reading
two files. A column-type or index-expression drift between the copy and the
migration would pass green here and break in prod — exactly the silent
wrong-money failure this test exists to prevent.

Replace the hand-copied constant with `ratingSchemaDDL(t)`, which loads the real
migration files (migrations/0001_billing_event.sql then 0002_rating.sql, the
production apply order — base_model is declared in 0001 and re-added IF NOT
EXISTS in 0002_rating, a harmless overlap). The schema now CANNOT drift from
production: if a migration changes, the conformance test runs against the new
shape automatically. The old constant is retained, renamed `schemaDDLReference`,
as a readable in-file description only (not applied — editing it edits a
comment).

The CI integration-test job (postgres:16 service, `make integration-test`) was
already wired but tested a copy; it now tests the real schema on every PR.

Verified: builds with -tags=integration, go vet clean, the full conformance
suite passes against a throwaway postgres:16 loading the migration DDL, and the
non-integration unit suite is unaffected.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@hhuuggoo hhuuggoo merged commit 2624ff5 into release-2026.02.01 Jun 17, 2026
3 checks passed
@hhuuggoo hhuuggoo deleted the hugo/rating-schema-single-source branch June 17, 2026 23:56
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