/** * Derive the migration-facing facts about a project's PRIOR state that the * compiler used to compute for itself by walking the uploaded migration tree. * * Under compiler-owned migrations these came from `CompilerInput.existingFiles` * via `parseExistingNonIdPkTables` (apps/compiler/src/schema/existing-pk-detection.ts) * and `projectHasPriorAuditEmission` (apps/compiler/src/utils/audit-latch.ts). * Both are pure functions over the same `{ path: content }` map the CLI already * builds with `loadDrizzleMeta`, so client ownership does not change what is * computed — only where. The CLI now sends the two derived facts instead of the * megabytes of history they were derived from. * * Both facts are load-bearing and both fail SAFE in the same direction the * compiler's versions did: * * - `existingNonIdPkTables` gates `injectIdField`. A table already deployed on * a non-`id` primary key must keep it — rewriting the PK would require * SQLite's recreate-and-copy dance and repointing every dependent FK. * Missing the fact means proposing that rewrite against a live table. * - `auditSchemaLatched` is the "once emitted, always emitted" latch on the * append-only forensic sink. Missing the fact means a generated migration * DROPs `audit.events` and destroys evidence. * * Keep these byte-equivalent to the compiler's copies. A divergence here is * invisible in generated output until it produces a destructive migration. */ /** * Tables that are already deployed on a primary key that is not `id`, read * from the highest-numbered features snapshot. Compound PKs count too — the * rewriter must not try to drop the table-level constraint either. * * Empty set when no snapshot exists (greenfield): every table is new and the * rewriter may proceed. */ export declare function parseExistingNonIdPkTables(existingFiles: Record | undefined): Set; /** * True when the project's prior drizzle state shows the Postgres audit schema * was ever emitted. * * Primary signal: a prior snapshot carrying the `audit` schema or an * `audit.`-qualified table (pg snapshot shape). D1's split-layout audit * snapshot is sqlite-shaped (`audit_events`, no `schemas` key) and can never * match — D1 must NOT latch, since its audit store is a separate database and * latching the feature-side predicate would re-arm the `auditDatabaseId` hard * error. * * Fallback signal: prior migration SQL that CREATEs the audit subsystem. This * covers broken lineages where a generated drop was hand-neutralized in SQL * but the snapshots still recorded the schema as removed — the database kept * the sink while the snapshot lineage lied. */ export declare function projectHasPriorAuditEmission(existingFiles: Record | undefined): boolean; export interface ClientMigrationPriorState { auditSchemaLatched: boolean; existingNonIdPkTables: string[]; } /** * Build the `migration.priorState` payload from locally-loaded drizzle meta. * Sorted for a stable request body — the payload is content-addressed upstream * and an unstable ordering would churn the hash on every compile. */ export declare function buildClientMigrationPriorState(drizzleMeta: Record | undefined): ClientMigrationPriorState; //# sourceMappingURL=prior-state.d.ts.map