# Skewcheck: ⛔ UNSAFE — reproducible compatibility regression

> **Question:** does the previous application version still work against the proposed database schema?

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

| | |
|---|---|
| Project | fixture/G-defective-repair |
| Execution | `example-G-defective-repair` |
| Baseline (old app) | `shop-v1` |
| Candidate | `G-defective-repair` |
| PostgreSQL | 16.15 (Debian 16.15-1.pgdg12+2) |
| Proposed migration(s) | `002_rename_email.sql` |
| Gate | **blocking** (exit 1) |
| Experiment complete | yes |

## Why
- test/customers.test.js: SQLSTATE 23502 (not_null_violation) linked to column_added:customers.email_address by R3 not_null_violation ↔ new NOT NULL requirement.
- test/orders.test.js: SQLSTATE 23502 (not_null_violation) linked to column_added:customers.email_address by R3 not_null_violation ↔ new NOT NULL requirement.

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

## Evidence
### regression — `test/customers.test.js`
**Observed:**
- test/customers.test.js passes on the baseline schema and fails in all 2 candidate runs.
- New in every candidate run, absent from the control run: SQLSTATE 23502 (not_null_violation): null value in column "email_address" of relation "customers" violates not-null constraint — statement: INSERT INTO customers (name, email) VALUES ($1, $2) RETURNING id
**Interpretation:** Column customers.email_address now requires a value that the old application's statement does not supply.
**Correlation rule:** R3 not_null_violation ↔ new NOT NULL requirement (strong)
**Linked change(s):** `column_added:customers.email_address`

### regression — `test/orders.test.js`
**Observed:**
- test/orders.test.js passes on the baseline schema and fails in all 2 candidate runs.
- New in every candidate run, absent from the control run: SQLSTATE 23502 (not_null_violation): null value in column "email_address" of relation "customers" violates not-null constraint — statement: INSERT INTO customers (name, email) VALUES ($1, $2) RETURNING id
**Interpretation:** Column customers.email_address now requires a value that the old application's statement does not supply.
**Correlation rule:** R3 not_null_violation ↔ new NOT NULL requirement (strong)
**Linked change(s):** `column_added:customers.email_address`

## Schema changes (catalog diff)
| Change | Risk | Exercised by old app | Tests |
|---|---|---|---|
| Column customers.email_address added (text NOT NULL) | breaking | yes (2 stmt) | `test/customers.test.js`, `test/orders.test.js` |

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

## Runs
| Run | Migrations | Tests (pass/fail/other) | DB errors | Statements |
|---|---|---|---|---|
| control (old app × baseline schema) | 1/1 applied | 2/0/0 | 0 | 7 |
| candidate #1 (old app × proposed schema) | 2/2 applied | 0/2/0 | 2 (23502 not_null_violation) | 2 |
| candidate #2 (old app × proposed schema) | 2/2 applied | 0/2/0 | 2 (23502 not_null_violation) | 2 |
| current app × proposed schema (context) | 2/2 applied | 0/1/0 | 1 (23502 not_null_violation) | 1 |

## Skipped checks
- Performance / lock-time analysis (out of scope).

## Limitations
- 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.

<sub>skewcheck 0.1.0 · report schema v1 · 2026-10-24T18:30:03.210Z</sub>