/** * FK-safe ordering for scope dumps. * * A dump's `tables` array carries no ordering guarantee — the server export sorts * by table NAME, and `readDump` enumerates `sqlite_master` in creation order. Neither * says anything about foreign keys: a child table (`crm_bank_accounts`) can precede * its parent (`crm_vendors`), and a loader that inserts in array order then trips * `FOREIGN KEY constraint failed` on the child's first row. * * The adapters defer FK checks to a transaction commit (their "suspenders"), but not * every loader does — `writeSqlite` below inserts row-by-row with no deferral, and an * older deployed control plane predates the deferral fix. So we make the dump FK-safe * BY CONSTRUCTION here (the "belt"): order every table after the tables it references, * so parents insert before children whatever the loader does. * * Deferral still covers what a total order cannot express — FK cycles and * self-references — so a cycle isn't an error here: we break it deterministically and * lean on the loader's deferral for the within-cycle rows. */ /** Table names referenced by this table's DDL (`... REFERENCES ...`). */ export declare function referencedTables(ddl: string): string[]; /** * Order tables so every FK target precedes the table referencing it. Stable * (independent tables keep their input order), total, and cycle-tolerant. */ export declare function orderTablesByForeignKeys(tables: T[]): T[]; //# sourceMappingURL=dump-order.d.ts.map