import { type Kysely } from "kysely"; /** * Default migration-history ledger table name. A single source of truth tracked * across postgres + sqlite so `meta migrate --apply` can skip already-applied * files (idempotency from the LEDGER, not from re-diffing). */ export declare const MIGRATIONS_TABLE = "_metaobjects_migrations"; /** Default Postgres schema holding the ledger (and, by default, the lock scope). */ export declare const DEFAULT_LEDGER_SCHEMA = "public"; /** The dialect signal threaded through the ledger fns (schema-qualification only applies to pg). */ export type LedgerDialect = "postgres" | "sqlite"; /** * Multi-tenant ledger configuration. Generalizes the fixed * `public._metaobjects_migrations` ledger so multiple apps/tenants can track * independently in one physical database. * * Defaults preserve the original single-tenant behavior exactly: `schema` * defaults to `public`, `table` to `_metaobjects_migrations`. Postgres uses * `schema`; SQLite has no schemas and ignores it. `lockName` is consumed by the * advisory-lock path (apply/rollback) — see {@link applyPending}. */ export interface LedgerOptions { /** Postgres schema holding the ledger table. Default `public`. Ignored on SQLite. */ schema?: string; /** Ledger table name. Default `_metaobjects_migrations`. */ table?: string; /** Advisory-lock name. Default derived from `.`. Postgres-only. */ lockName?: string; } /** A single ledger row. */ export interface LedgerRow { /** Migration name = the `-` directory name (sort key + id). */ name: string; /** sha-256 of the up.sql contents at apply time (tamper guard). */ checksum: string; } /** * Create the migration-history table if it does not already exist. Idempotent: * re-running is a no-op and preserves existing rows. Dialect-portable DDL * (TEXT columns work on both sqlite and postgres; `applied_at` is stored as * text so we don't depend on a dialect-specific timestamp type). * * On Postgres a multi-tenant `schema` is created first (`CREATE SCHEMA IF NOT * EXISTS`) so the ledger can live outside `public`. */ export declare function ensureLedger(db: Kysely>, dialect?: LedgerDialect, opts?: LedgerOptions): Promise; /** * Record a migration as applied. Inserts a row with the current UTC timestamp. * Intended to run inside the SAME transaction that applied the migration SQL. */ export declare function recordApplied(db: Kysely>, name: string, checksum: string, dialect?: LedgerDialect, opts?: LedgerOptions): Promise; /** Delete a migration's ledger row (rollback unrecord). */ export declare function deleteApplied(db: Kysely>, name: string, dialect?: LedgerDialect, opts?: LedgerOptions): Promise; /** Return the set of applied migration names. */ export declare function appliedNames(db: Kysely>, dialect?: LedgerDialect, opts?: LedgerOptions): Promise>; /** * Return a name→checksum map for all applied migrations (tamper-guard input). * * The {@link BASELINE_NAME} marker row is excluded at the SQL level: it is a * marker, NOT a migration, so no migration-listing consumer (e.g. rollback-all, * which derives its work list from these names) should ever see it. The baseline * is read independently via {@link baselineRecord}. */ export declare function appliedRecords(db: Kysely>, dialect?: LedgerDialect, opts?: LedgerOptions): Promise>; /** Reserved ledger name for the baseline marker (sorts before any timestamped migration). */ export declare const BASELINE_NAME = "0000-baseline"; /** * Record (or overwrite) the baseline marker — the snapshot checksum captured when * `migrate baseline` seeded the reference snapshot. Lets a later check detect a * snapshot that was hand-edited out of sync with the migration chain. */ export declare function recordBaseline(db: Kysely>, dialect: LedgerDialect, checksum: string, opts?: LedgerOptions): Promise; /** Read the baseline marker, or null if none recorded. */ export declare function baselineRecord(db: Kysely>, dialect?: LedgerDialect, opts?: LedgerOptions): Promise<{ name: string; checksum: string; } | null>; //# sourceMappingURL=ledger.d.ts.map