(db: Db, ns: MigrationNamespace, names: readonly string[]): Promise<void> import {baseline} from '@fuzdev/fuz_app/db/migrate.js'; Insert tracker rows for the named migrations of a namespace without executing them.
Used to promote an existing schema (e.g. produced by an out-of-band
bootstrap, or a hand-applied DDL set) into the identity tracker.
baseline() trusts the operator-supplied list — it does not verify that
the schema actually matches what the named migrations would have produced.
Pair with a schema-assertion script post-baseline before re-enabling traffic.
Contract:
- Creates the
schema_versiontable if missing — a promotion script can callbaseline()against a fresh tracker with no separate DDL step. - Acquires the same per-namespace advisory lock as run_migrations (with
the same try/catch fallback for environments lacking
pg_advisory_lock). - Refuses if any tracker rows already exist *for this namespace* — lets multi-call baseline scripts resume after partial failure (completed namespaces guard themselves while remaining ones still run).
- Verifies the supplied names are a strict prefix of the namespace's current migrations array — a name not in the array, or out of order, errors before any INSERT.
- Writes sequences
0..N-1in one transaction.
db
the database instance
ns
the namespace whose migrations are being baselined
names
prefix of ns.migrations[].name to record as already-applied
readonly string[]returns
Promise<void>
throws
MigrationError- with `kind` of `baseline-name-not-in-code`, `baseline-name-out-of-order`, or `baseline-namespace-already-populated`
mutates
schema_version— inserts tracker rows for `names` without running the corresponding migration bodies