feat: add migration ledger to database-postgres (E00-S03-T03)

MigrationLedger over the package-owned pg Pool: ensure() creates the
schema_migrations table (version text PRIMARY KEY, applied_at timestamptz
NOT NULL DEFAULT now()) with idempotent DDL; record() inserts an applied
migration with a parameterized, idempotent statement (ON CONFLICT DO
NOTHING — a rerun never double-applies); has()/applied() read the ledger
back in apply order. Re-exported from the driver boundary (src/index.ts)
so no other package needs the pg driver to touch migration state.
This commit is contained in:
implementer
2026-08-29 23:19:56 +00:00
parent 33ac04e795
commit 7f6450410e
5 changed files with 105 additions and 6 deletions
+6 -4
View File
@@ -8,13 +8,15 @@
* package will expose — so no other package ever imports the driver directly.
*
* This module is the driver boundary: it imports the PostgreSQL driver (`pg`)
* and Kysely and re-exports the pieces later stories build the adapter on
* (migration ledger E00-S03-T03, advisory lock E00-S03-T04). Until then the
* re-exports keep the driver reachable only from here — the isolation is real,
* not a placeholder.
* and Kysely and re-exports the pieces the adapter is built on — the driver
* surface (E00-S03-T02) and the migration ledger (E00-S03-T03). The advisory
* lock (E00-S03-T04) and failure diagnostic (E00-S03-T05) land in later
* stories; until then the re-exports keep the driver reachable only from here
* — the isolation is real, not a placeholder.
*/
import { Pool } from 'pg';
import { Kysely, PostgresDialect } from 'kysely';
export { Pool, Kysely, PostgresDialect };
export { MigrationLedger, MIGRATION_LEDGER_TABLE } from './ledger.js';