feat: add migration runner with structured failure diagnostic (E00-S03-T05)
MigrationRunner applies pending migrations through the migration ledger exactly once; when a migration fails it throws a MigrationFailedError whose diagnostic is a structured object identifying the failing migration (version), the failure phase (apply/record), the underlying cause, and the applied/pending ledger state, serializable via toJSON. Re-exported from the driver boundary so no other package needs the pg driver to run migrations. Advisory lock (T04) and ready gate (T06) remain out of scope.
This commit is contained in:
@@ -9,10 +9,11 @@
|
||||
*
|
||||
* This module is the driver boundary: it imports the PostgreSQL driver (`pg`)
|
||||
* and Kysely and re-exports the pieces the adapter is built on — the driver
|
||||
* surface (E00-S03-T02), the migration ledger (E00-S03-T03) and the migration
|
||||
* advisory lock (E00-S03-T04). The failure diagnostic (E00-S03-T05) lands in
|
||||
* a later story; until then the re-exports keep the driver reachable only
|
||||
* from here — the isolation is real, not a placeholder.
|
||||
* surface (E00-S03-T02), the migration ledger (E00-S03-T03), the migration
|
||||
* advisory lock (E00-S03-T04) and the migration runner with its failure
|
||||
* diagnostic (E00-S03-T05). Keeping every re-export here means the driver
|
||||
* stays reachable only from this package — the isolation is real, not a
|
||||
* placeholder.
|
||||
*/
|
||||
|
||||
import { Pool } from 'pg';
|
||||
@@ -21,3 +22,5 @@ import { Kysely, PostgresDialect } from 'kysely';
|
||||
export { Pool, Kysely, PostgresDialect };
|
||||
export { MigrationLedger, MIGRATION_LEDGER_TABLE } from './ledger.js';
|
||||
export { MigrationLock, MIGRATION_LOCK_KEY } from './lock.js';
|
||||
export { MigrationRunner, MigrationFailedError } from './runner.js';
|
||||
export type { Migration, MigrationDiagnostic, MigrationRunResult, MigrationFailurePhase } from './runner.js';
|
||||
|
||||
Reference in New Issue
Block a user