Make integration-test migration replay fail closed
If an integration test cannot create its schema but continues into entity tests, the delayed failures lose the original cause. A missing migration directory, zero SQL files, a read error, or one failed statement is a bo…
Make integration-test migration replay fail closed
If an integration test cannot create its schema but continues into entity tests, the delayed failures lose the original cause. A missing migration directory, zero SQL files, a read error, or one failed statement is a bootstrap failure.
Safe replay rules
- Throw immediately when the repository SSOT directory cannot be found.
- Do not treat a directory with no SQL files as success.
- Read sorted SQL files as UTF-8 and stop at the first execution error.
- Apply the same rule to seeds; an applied-count log is not proof of success.
This contract distinguishes “the test ran” from “the test ran against the real schema.” Migration idempotency is a separate concern; the test harness must first refuse to hide failure.
Questions for the verdict
Check that migration files were actually read, that the first SQL error remains attached to its cause, and that an applied-count log is not being treated as proof of success.
Related course: Close partial failure, recovery, and platform boundaries
Terms in this content
More in quality
All in this category →Related posts
Idempotent migrations and partial-failure recovery
An operational database cannot be changed in one shot like a fresh database. Preserve existing rows, converge to the same state on repeated runs, and expose enough failure context for a safe retry.
TypeORM and read-only entities
TypeORM was once a representative ORM in the Node camp and was widely used alongside NestJS. Its position has shifted somewhat as new ORMs appeared, but it still runs in many codebases.
SQL as the single source of truth
Where should the schema's truth live? ORM models, migration files, DDL SQL — there are several candidates. We compare the cumulative-migration model with the single-SQL-file + CREATE IF NOT EXISTS model.
SSOT Everywhere
SSOT (Single Source of Truth) started as a data governance term and has expanded into a principle for code, documentation, and schema operations. This article covers the origin, areas of application, and trade-offs.