/** * Pure helpers that classify an Atlas declarative-apply plan as destructive * or not, and decide what `rebase db push` should do about it. * * `db push` runs `atlas schema apply` to make the live database match the * generated `schema.sql`. Removing a collection field compiles to * `DROP COLUMN`; renaming compiles to drop-then-add — either destroys data. * We first run the apply with `--dry-run` to obtain the planned SQL, scan it * here, and refuse to auto-approve anything destructive without an explicit * opt-in. * * Everything in this file is side-effect free so it can be unit-tested * without Atlas or a database. */ /** * Split a SQL script into individual statements, dropping blank lines and * `--` comment lines. Deliberately simple: Atlas emits one plain statement * per `;`, without string literals that contain semicolons in a schema DDL * plan, so a naive split is safe and keeps this dependency-free. */ export declare function splitSqlStatements(sql: string): string[]; export interface DestructiveStatement { /** The offending statement (trimmed, without the trailing `;`). */ statement: string; /** Which destructive operation it was flagged for, e.g. "DROP COLUMN". */ kind: string; } /** * Scan an Atlas plan (the SQL printed by `schema apply --dry-run`) and return * the statements that would destroy data. An empty array means the plan is * safe to auto-approve. */ export declare function detectDestructiveStatements(planSql: string): DestructiveStatement[]; export type PushDecision = "apply" | "confirm" | "refuse"; /** * Decide how `db push` should proceed given the plan's destructiveness and * the invocation context. * * - No destructive statements → `apply` (safe to auto-approve). * - Destructive + `--allow-destructive` → `apply` (operator opted in). * - Destructive + interactive TTY → `confirm` (prompt before applying). * - Destructive + non-interactive → `refuse` (never silently drop data in * CI / scripts / agents). */ export declare function decidePushSafety(opts: { destructiveCount: number; allowDestructive: boolean; interactive: boolean; }): PushDecision;