New CHECK constraint

Unsafe
The previous application version reproducibly fails against the proposed schema, and the failure is linked to a specific schema change.

Totals must now be positive. v1 still creates fully discounted orders.

Recorded example: genuine engine output generated Sat, 24 Oct 2026 18:30:07 GMT from the committed fixture. Run it again live below.

Baseline schema
Proposed schema
Previous versionshop-v1
2/2 test files passno database errors
1/2 test files passSQLSTATE 23514, identical in all 2 runs
Current versionJ-check-constraint
Not needed: ordinary CI covers this
Not configured

The outlined cell is the compatibility question. The verdict comes only from it, compared against the cell to its left.

Why

  1. test/orders.test.js: SQLSTATE 23514 (check_violation) linked to constraint_added:orders.orders_total_positive by R4 constraint violation ↔ added/changed constraint.

Next step

Make the migration backward compatible (expand/contract: keep the old shape until the old version is retired), then re-run the gate.

Starts a throwaway PostgreSQL and runs the full experiment, usually in under 15 seconds.

Evidence

Regression test/orders.test.js

Observed
test/orders.test.js passes on the baseline schema and fails in all 2 candidate runs.
Database error
SQLSTATE 23514 check_violation — new row for relation "orders" violates check constraint "orders_total_positive"
INSERT INTO orders (customer_id, total_cents) VALUES ($1, $2) RETURNING id, status
Interpretation
Constraint "orders_total_positive" is new or changed in the proposed schema and rejects a write the old application performs.
Rule
R4 constraint violation ↔ added/changed constraint (strong correlation)
Linked change
constraint_added:orders.orders_total_positive

Schema changes

1 of 1 risk-bearing schema change(s) were exercised by the old application's tests in the control run.

ChangeRisk to old statementsExercised by previous version
Constraint orders_total_positive added on orders: CHECK ((total_cents > 0))breakingYes, 3 statements in test/orders.test.js

Runs

Proposed migration: 002_positive_totals.sql · PostgreSQL 16.15 (Debian 16.15-1.pgdg12+2) · gate blocks the pipeline (exit 1)

RunMigrationsTest filesDatabase errorsStatements logged
control (old app × baseline schema)1/12/2 pass07
candidate #1 (old app × proposed schema)2/21/2 pass1 (23514)6
candidate #2 (old app × proposed schema)2/21/2 pass1 (23514)6

Download this report: JSONMarkdownJUnit XML

What this result does not cover
  • Current application × proposed schema (no current app configured).
  • Performance / lock-time analysis (out of scope).
  • Skewcheck only observes code paths that the old application's tests execute; untested paths are reported as coverage gaps, not as safe.
  • Coverage is identifier-level: a statement "touches" a changed object when it names the table (and column, or uses *). It is not a SQL parser.
  • Correlation between an error and a schema change uses a fixed set of deterministic rules (R1–R6). Anything else is reported as ADVISORY, never UNSAFE.
  • Performance, locking and migration runtime on production-sized data are not evaluated.
  • Test files of one run share a database and run sequentially; ordering effects are identical across runs but are not isolated.
  • Data-only migration effects are detected only when a test asserts on the affected data.