diff --git a/server/src/routes/schema-change.ts b/server/src/routes/schema-change.ts index b8e78d1..d1d362b 100644 --- a/server/src/routes/schema-change.ts +++ b/server/src/routes/schema-change.ts @@ -170,6 +170,7 @@ const expectedSchema = z.object({ checks: z.array(z.object({ name, validated: z.boolean() })).max(500), foreignKeys: z.array(z.object({ name, columns: z.array(name).max(100), refTable: name, refColumns: z.array(name).max(100), validated: z.boolean() })).max(500), indexes: z.array(z.object({ name, columns: z.array(name.nullable()).max(100), unique: z.boolean() })).max(1_000), + views: z.array(name).max(1_000), })).max(100), absent: z.array(name).max(100), }); diff --git a/server/src/schema-change/compile.test.ts b/server/src/schema-change/compile.test.ts index 5d224e8..f45ef7a 100644 --- a/server/src/schema-change/compile.test.ts +++ b/server/src/schema-change/compile.test.ts @@ -361,8 +361,8 @@ describe("tables, renames and drops", () => { expect(errors(compile(plan({ type: "create_table", table: { name: "t", fields: [field, { name: "ID", dataType: "bigint" }] } }), facts()))).toEqual(["column-exists"]); }); - it("renames a table and says it breaks callers; later steps see the new name", () => { - const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }, { type: "add_column", tableName: "sales_orders", field: { name: "x", dataType: "text" } }), facts(orders())); + it("renames a table and says it breaks callers when compatibility views are off; later steps see the new name", () => { + const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }, { type: "add_column", tableName: "sales_orders", field: { name: "x", dataType: "text" } }), facts(orders()), { settings: { compatViews: false } }); expect(errors(runbook)).toEqual([]); expect(runbook.steps[0]).toMatchObject({ breaksClients: true, lock: "ACCESS EXCLUSIVE" }); expect(runbook.steps[1].sql).toContain("ALTER TABLE public.sales_orders ADD COLUMN x text;"); diff --git a/server/src/schema-change/compile.ts b/server/src/schema-change/compile.ts index 1b7329e..0e6215c 100644 --- a/server/src/schema-change/compile.ts +++ b/server/src/schema-change/compile.ts @@ -308,7 +308,7 @@ class Compiler { return { schema, name, qualified: qualifiedName(schema, name), partitioned: false, partitionCount: 0, partitions: [], nestedPartitions: false, estimatedRows: 0, heapBytes: 0, indexBytes: 0, totalBytes: 0, columns: [], primaryKey: [], uniques: [], checks: [], foreignKeys: [], referencedBy: [], - indexes: [], dependentViews: [], dependents: [], userTriggers: 0, stats: null, isNew: true, + indexes: [], dependentViews: [], dependents: [], userTriggers: 0, rowSecurity: false, privileges: [], stats: null, isNew: true, }; } @@ -395,22 +395,87 @@ class Compiler { const target = qualifiedName(table.schema, newName); this.claimRelation(table.schema, newName, "Table"); const oldQualified = table.qualified; + const oldName = table.name; + const from = qualifiedIdent(table.schema, oldName); + const to = qualifiedIdent(table.schema, newName); + const keepOldName = this.settings.compatViews && !table.isNew; - this.add({ - title: `Rename table ${oldQualified} to ${newName}`, - sql: `ALTER TABLE ${qualifiedIdent(table.schema, table.name)} RENAME TO ${ident(newName)};`, - mode: "short", - lock: "ACCESS EXCLUSIVE", - work: "metadata", - table, - breaksClients: true, - notes: [ - "The old name stops working immediately. Queries, functions and application code that use it will fail until they are changed.", - "Views, foreign keys and indexes follow the table. Index and constraint names keep their old text.", - ...(table.dependentViews.length ? [`Views that use it: ${table.dependentViews.join(", ")}.`] : []), - ], - undo: `ALTER TABLE ${qualifiedIdent(table.schema, newName)} RENAME TO ${ident(table.name)};`, - }); + if (!keepOldName) { + this.add({ + title: `Rename table ${oldQualified} to ${newName}`, + sql: `ALTER TABLE ${from} RENAME TO ${ident(newName)};`, + mode: "short", + lock: "ACCESS EXCLUSIVE", + work: "metadata", + table, + breaksClients: !table.isNew, + notes: [ + ...(table.isNew ? [] : ["The old name stops working immediately. Queries, functions and application code that use it will fail until they are changed."]), + "Views, foreign keys and indexes follow the table. Index and constraint names keep their old text.", + ...(table.dependentViews.length ? [`Views that use it: ${table.dependentViews.join(", ")}.`] : []), + ], + undo: `ALTER TABLE ${to} RENAME TO ${ident(oldName)};`, + }); + } else { + // The old name stays usable as a view over the renamed table, in the same transaction as the rename, so no query ever sees it missing. + const invoker = this.facts.serverVersionNum >= 150000; + if (table.rowSecurity && !invoker) { + this.fail("unsupported", `${oldQualified} has row-level security. Before PostgreSQL 15 a view over it would run as its owner, who is not held to the policies, so a compatibility view under the old name would let applications around them. Rename it directly by turning compatibility views off (compatViews: false), or move to PostgreSQL 15 or later.`, table.qualified); + } + const skipped = new Set(); + const grants = table.privileges + .filter((privilege) => !privilege.owner) + .filter((privilege) => { + const copied = ["SELECT", "INSERT", "UPDATE", "DELETE"].includes(privilege.privilege); + if (!copied) skipped.add(privilege.privilege); + return copied; + }); + const byGrantee = new Map(); + for (const grant of grants) { + const entry = byGrantee.get(grant.grantee) ?? { privileges: [], grantable: [] }; + entry.privileges.push(grant.privilege); + if (grant.grantable) entry.grantable.push(grant.privilege); + byGrantee.set(grant.grantee, entry); + } + const grantSql: string[] = []; + for (const [grantee, entry] of byGrantee) { + const who = grantee === "PUBLIC" ? "PUBLIC" : ident(grantee); + const plain = entry.privileges.filter((privilege) => !entry.grantable.includes(privilege)); + if (plain.length) grantSql.push(`GRANT ${plain.join(", ")} ON ${from} TO ${who};`); + if (entry.grantable.length) grantSql.push(`GRANT ${entry.grantable.join(", ")} ON ${from} TO ${who} WITH GRANT OPTION;`); + } + this.add({ + title: `Rename table ${oldQualified} to ${newName}, and keep ${oldName} working as a view`, + sql: [`ALTER TABLE ${from} RENAME TO ${ident(newName)};`, `CREATE VIEW ${from}${invoker ? " WITH (security_invoker = true)" : ""} AS SELECT * FROM ${to};`, ...grantSql].join("\n"), + mode: "short", + lock: "ACCESS EXCLUSIVE", + work: "metadata", + table, + notes: [ + `One transaction: ${newName} is the table and ${oldName} is a view over it, so applications using the old name keep working until they have switched.`, + `Through the view, SELECT, INSERT, UPDATE and DELETE work (a view that is just SELECT * is updatable, and the table's defaults still apply to INSERT). ALTER TABLE, TRUNCATE, COPY, LOCK and the like do not work on a view, and the view lists the columns the table has now: columns added later are not in it.`, + ...(grantSql.length ? [`The table's SELECT, INSERT, UPDATE and DELETE grants are copied onto the view (${[...byGrantee.keys()].join(", ")}).`] : ["The table has no grants other than its owner's, so none are copied."]), + ...(skipped.size ? [`Grants of ${[...skipped].join(", ")} are not copied (a view cannot hold them), and column-level grants are not copied either.`] : ["Column-level grants, if there are any, are not copied."]), + ...(invoker ? ["The view runs with the caller's own rights on the table (security_invoker), so row-level security and privileges apply as before."] : []), + "Index and constraint names keep their old text. Views, foreign keys and indexes follow the table.", + ...(table.dependentViews.length ? [`Views that use it: ${table.dependentViews.join(", ")}.`] : []), + `Until the view is dropped, a column of ${newName} that the view lists cannot be dropped or have its type changed: drop the view first.`, + ], + undo: `DROP VIEW ${from};\nALTER TABLE ${to} RENAME TO ${ident(oldName)};`, + }); + this.add({ + title: `Contract: drop the old name ${oldQualified}, the compatibility view`, + sql: `DROP VIEW ${from};`, + mode: "short", + lock: "ACCESS EXCLUSIVE", + work: "metadata", + table, + optional: true, + breaksClients: true, + notes: ["Run this later, once nothing uses the old name any more. Anything that still does will fail from then on."], + undo: `CREATE VIEW ${from}${invoker ? " WITH (security_invoker = true)" : ""} AS SELECT * FROM ${to};`, + }); + } table.name = newName; table.qualified = target; @@ -419,6 +484,12 @@ class Compiler { for (const fk of other.foreignKeys) if (fk.refSchema === table.schema && fk.refTable === splitQualified(oldQualified).name) fk.refTable = newName; for (const inbound of other.referencedBy) if (inbound.schema === table.schema && inbound.table === splitQualified(oldQualified).name) inbound.table = newName; } + if (keepOldName) { + // the view now depends on every column it lists, and later steps in the plan have to know + table.dependentViews.push(oldQualified); + this.claimedRelations.add(relationKey(table.schema, oldName)); + for (const column of table.columns) column.dependents.push({ kind: "view", description: `view ${oldQualified}`, blocks: true, external: true }); + } } private dropTable(operation: Extract): void { diff --git a/server/src/schema-change/expected-state.ts b/server/src/schema-change/expected-state.ts index 5820c16..7270945 100644 --- a/server/src/schema-change/expected-state.ts +++ b/server/src/schema-change/expected-state.ts @@ -19,6 +19,8 @@ export interface ExpectedTable { checks: { name: string; validated: boolean }[]; foreignKeys: { name: string; columns: string[]; refTable: string; refColumns: string[]; validated: boolean }[]; indexes: { name: string; columns: (string | null)[]; unique: boolean }[]; + /** Views that depend on the table, schema qualified: the others it already had, and the old name a rename leaves behind. */ + views: string[]; } export interface ExpectedState { @@ -30,7 +32,7 @@ export interface ExpectedState { export interface Mismatch { table: string; /** What differs: a column, index, constraint, foreign key, the primary key, or the table itself. */ - kind: "table" | "column" | "primary-key" | "unique" | "check" | "foreign-key" | "index"; + kind: "table" | "column" | "primary-key" | "unique" | "check" | "foreign-key" | "index" | "view"; message: string; } @@ -43,6 +45,7 @@ export function expectedState(original: Map, final: Map ({ name: check.name, validated: check.validated })), foreignKeys: table.foreignKeys.map((fk) => ({ name: fk.name, columns: [...fk.columns], refTable: `${fk.refSchema}.${fk.refTable}`, refColumns: [...fk.refColumns], validated: fk.validated })), indexes: table.indexes.filter((index) => !index.primary).map((index) => ({ name: index.name, columns: [...index.columns], unique: index.unique })), + views: [...table.dependentViews].sort(), })); const kept = new Set(tables.map((table) => table.qualified)); const absent = [...original.keys()].filter((key) => !kept.has(key)); @@ -112,6 +115,13 @@ export function diffExpected(expected: ExpectedState, actual: Facts): Mismatch[] if (!table.foreignKeys.some((fk) => fk.name === have.name)) note("foreign-key", `Foreign key ${have.name} exists, but the plan did not expect it.`); } + for (const view of table.views) { + if (!real.dependentViews.includes(view)) note("view", `View ${view} should depend on this table, but it does not exist.`); + } + for (const view of real.dependentViews) { + if (!table.views.includes(view)) note("view", `View ${view} depends on this table, but the plan did not expect it.`); + } + for (const index of table.indexes) { const have = real.indexes.find((candidate) => candidate.name === index.name); if (!have) note("index", `Index ${index.name} should exist, but it does not.`); diff --git a/server/src/schema-change/facts.ts b/server/src/schema-change/facts.ts index c73242b..7e8c560 100644 --- a/server/src/schema-change/facts.ts +++ b/server/src/schema-change/facts.ts @@ -94,6 +94,15 @@ export interface TableStats { modificationsSinceAnalyze: number; } +/** One privilege on a table as the catalog lists it (aclexplode of relacl); `grantee` is a role name or PUBLIC. */ +export interface TablePrivilege { + grantee: string; + privilege: string; + grantable: boolean; + /** The grantee owns the table: its privileges are implied and a copy of the table's grants does not repeat them. */ + owner: boolean; +} + export interface TableFacts { schema: string; name: string; @@ -121,6 +130,9 @@ export interface TableFacts { /** Objects on other tables, and functions, that depend on this table or any of its columns: what would block `DROP TABLE`. */ dependents: Dependent[]; userTriggers: number; + /** Row-level security is switched on: a view over the table would not apply the policies to its owner. */ + rowSecurity: boolean; + privileges: TablePrivilege[]; stats: TableStats | null; /** True for a table the plan itself creates: empty, with no history. */ isNew?: boolean; @@ -192,6 +204,8 @@ export async function loadFacts(client: Queryable, qualified: string[]): Promise t.relkind = 'p' AND EXISTS (SELECT 1 FROM pg_partition_tree(t.oid) p WHERE p.level > 1) AS nested_partitions, CASE WHEN t.relkind = 'p' THEN (SELECT COALESCE(json_agg(p.name ORDER BY p.name), '[]'::json) FROM (SELECT pn.nspname || '.' || pc.relname AS name FROM pg_partition_tree(t.oid) pt JOIN pg_class pc ON pc.oid = pt.relid JOIN pg_namespace pn ON pn.oid = pc.relnamespace WHERE pt.level = 1 ORDER BY 1 LIMIT ${MAX_LISTED_PARTITIONS}) p) ELSE '[]'::json END AS partitions, (SELECT count(*) FROM pg_trigger g WHERE g.tgrelid = t.oid AND NOT g.tgisinternal)::int AS user_triggers, + (SELECT c3.relrowsecurity FROM pg_class c3 WHERE c3.oid = t.oid) AS row_security, + COALESCE((SELECT json_agg(json_build_object('grantee', CASE WHEN a.grantee = 0 THEN 'PUBLIC' ELSE pg_get_userbyid(a.grantee) END, 'privilege', a.privilege_type, 'grantable', a.is_grantable, 'owner', a.grantee = c2.relowner) ORDER BY a.grantee, a.privilege_type) FROM pg_class c2, aclexplode(c2.relacl) a WHERE c2.oid = t.oid), '[]'::json) AS privileges, s.n_live_tup::text AS live, s.n_dead_tup::text AS dead, s.last_vacuum, s.last_autovacuum, s.last_analyze, s.last_autoanalyze, s.seq_scan::text AS seq_scan, s.idx_scan::text AS idx_scan, s.n_mod_since_analyze::text AS mods FROM t LEFT JOIN pg_stat_user_tables s ON s.relid = t.oid`, @@ -303,6 +317,8 @@ export async function loadFacts(client: Queryable, qualified: string[]): Promise dependentViews: [], dependents: [], userTriggers: Number(row.user_triggers), + rowSecurity: row.row_security === true, + privileges: (row.privileges as TablePrivilege[] | null) ?? [], stats: hasStats ? { liveTuples: Number(row.live), diff --git a/server/src/schema-change/rename.test.ts b/server/src/schema-change/rename.test.ts new file mode 100644 index 0000000..28afe07 --- /dev/null +++ b/server/src/schema-change/rename.test.ts @@ -0,0 +1,90 @@ +import { describe, expect, it } from "vitest"; +import { compile, facts, MIB, plan, table } from "./test-fixtures.js"; +import type { Runbook } from "./runbook.js"; + +const orders = (overrides: Partial[0]> = {}) => + table({ + name: "orders", rows: 5_000_000, bytes: 400 * MIB, + columns: ["id:bigint:notnull", "customer_id:bigint:notnull", "qty:integer:notnull"], + privileges: [ + { grantee: "app", privilege: "SELECT" }, { grantee: "app", privilege: "INSERT" }, { grantee: "app", privilege: "UPDATE" }, + { grantee: "reporting", privilege: "SELECT", grantable: true }, + { grantee: "PUBLIC", privilege: "SELECT" }, + { grantee: "owner_role", privilege: "SELECT", owner: true }, { grantee: "owner_role", privilege: "TRUNCATE", owner: true }, + { grantee: "etl", privilege: "TRUNCATE" }, + ], + ...overrides, + }); +const rename = (options: Parameters[2] = {}, ...tables: ReturnType[]) => compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }), facts(orders(), ...tables), options); +const errors = (runbook: Runbook) => runbook.findings.filter((finding) => finding.severity === "error").map((finding) => finding.code); + +describe("renaming a table without breaking its callers", () => { + it("renames it and leaves a view under the old name, in one step, with the old grants", () => { + const runbook = rename(); + expect(errors(runbook)).toEqual([]); + const [step, contract] = runbook.steps; + expect(step.title).toBe("Rename table public.orders to sales_orders, and keep orders working as a view"); + expect(step.breaksClients).toBe(false); + const statements = step.sql.replace(/^[\s\S]*?DO \$retry\$[\s\S]*?-- goforge:retry-begin\n/, "").split("-- goforge:retry-end")[0].split("\n").map((line) => line.trim()).filter(Boolean); + expect(statements).toEqual([ + "ALTER TABLE public.orders RENAME TO sales_orders;", + "CREATE VIEW public.orders WITH (security_invoker = true) AS SELECT * FROM public.sales_orders;", + "GRANT SELECT, INSERT, UPDATE ON public.orders TO app;", + "GRANT SELECT ON public.orders TO reporting WITH GRANT OPTION;", + "GRANT SELECT ON public.orders TO PUBLIC;", + ]); + expect(step.notes.join(" ")).toMatch(/Grants of TRUNCATE are not copied/); + expect(step.notes.join(" ")).toMatch(/security_invoker/); + expect(step.undo).toContain("DROP VIEW public.orders;\nALTER TABLE public.sales_orders RENAME TO orders;"); + expect(contract).toMatchObject({ optional: true, breaksClients: true }); + expect(contract.sql).toContain("DROP VIEW public.orders;"); + }); + + it("wraps the rename and the view in the lock retry, so they are retried and stay one transaction", () => { + const step = rename().steps[0]; + expect(step.sql).toContain("DO $retry$"); + expect(step.sql.indexOf("RENAME TO sales_orders")).toBeLessThan(step.sql.indexOf("CREATE VIEW")); + }); + + it("leaves out security_invoker before PostgreSQL 15, where it does not exist", () => { + const old = facts(orders()); + old.serverVersionNum = 140000; + const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }), old); + expect(runbook.steps[0].sql).toContain("CREATE VIEW public.orders AS SELECT * FROM public.sales_orders;"); + expect(runbook.steps[0].sql).not.toContain("security_invoker"); + }); + + it("refuses before PostgreSQL 15 when the table has row-level security, because the view would run as its owner", () => { + const old = facts(orders({ rowSecurity: true })); + old.serverVersionNum = 140000; + const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }), old); + expect(errors(runbook)).toEqual(["unsupported"]); + expect(runbook.findings.find((finding) => finding.code === "unsupported")?.message).toMatch(/row-level security/); + // from 15 the view runs with the caller's rights, so it is fine + expect(errors(compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }), facts(orders({ rowSecurity: true }))))).toEqual([]); + }); + + it("renames directly when compatibility views are off, and for a table the plan itself creates", () => { + const direct = rename({ settings: { compatViews: false } }); + expect(direct.steps).toHaveLength(1); + expect(direct.steps[0]).toMatchObject({ breaksClients: true }); + expect(direct.steps[0].sql).not.toContain("CREATE VIEW"); + const created = compile(plan({ type: "create_table", table: { name: "events", fields: [{ name: "id", dataType: "bigint", primaryKey: true }] } }, { type: "rename_table", tableName: "events", newName: "audit_events" }), facts()); + expect(errors(created)).toEqual([]); + expect(created.steps.every((step) => !step.sql.includes("CREATE VIEW"))).toBe(true); + }); + + it("tells later steps that a view now depends on the columns, and expects the old name as a view", () => { + const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }, { type: "alter_column", tableName: "sales_orders", columnName: "qty", changes: { dataType: "bigint" } }), facts(orders())); + expect(errors(runbook)).toEqual(["dependents"]); + expect(runbook.findings.find((finding) => finding.code === "dependents")?.message).toContain("view public.orders"); + const ok = rename(); + expect(ok.expected.tables.find((t) => t.qualified === "public.sales_orders")?.views).toEqual(["public.orders"]); + expect(ok.expected.absent).toEqual(["public.orders"]); + }); + + it("refuses to create something else under the old name in the same plan", () => { + const runbook = compile(plan({ type: "rename_table", tableName: "orders", newName: "sales_orders" }, { type: "create_table", table: { name: "orders", fields: [{ name: "id", dataType: "bigint", primaryKey: true }] } }), facts(orders())); + expect(errors(runbook)).toEqual(["name-taken"]); + }); +}); diff --git a/server/src/schema-change/runbook.ts b/server/src/schema-change/runbook.ts index 2e4068a..1e41ede 100644 --- a/server/src/schema-change/runbook.ts +++ b/server/src/schema-change/runbook.ts @@ -135,12 +135,14 @@ export interface CompileSettings { lockTimeoutSeconds: number; /** Attempts a step that takes a strong lock makes before it gives up (1 means it does not retry). */ lockAttempts: number; + /** Renaming an existing table leaves a view under the old name, so applications keep working until they have switched. */ + compatViews: boolean; backfillBatchRows: number; backfillPauseMs: number; defaultSchema: string; } -export const DEFAULT_COMPILE_SETTINGS: CompileSettings = { lockTimeoutSeconds: 2, lockAttempts: 8, backfillBatchRows: 10_000, backfillPauseMs: 50, defaultSchema: "public" }; +export const DEFAULT_COMPILE_SETTINGS: CompileSettings = { lockTimeoutSeconds: 2, lockAttempts: 8, compatViews: true, backfillBatchRows: 10_000, backfillPauseMs: 50, defaultSchema: "public" }; const statementLines = (sql: string): string[] => sql.replace(/\s+$/, "").split("\n"); diff --git a/server/src/schema-change/test-fixtures.ts b/server/src/schema-change/test-fixtures.ts index 7ec308e..76433cb 100644 --- a/server/src/schema-change/test-fixtures.ts +++ b/server/src/schema-change/test-fixtures.ts @@ -23,6 +23,8 @@ export interface TableSpec { checks?: { name: string; definition: string; columns: string[] }[]; partitions?: string[]; views?: string[]; + rowSecurity?: boolean; + privileges?: { grantee: string; privilege: string; grantable?: boolean; owner?: boolean }[]; /** Objects that depend on a column (`column` is its name) or, with no column, on the table. */ dependents?: { column?: string; kind: Dependent["kind"]; description: string; blocks?: boolean; external?: boolean }[]; } @@ -67,6 +69,8 @@ export function table(spec: TableSpec): TableFacts { dependentViews: spec.views ?? [], dependents: [], userTriggers: 0, + rowSecurity: spec.rowSecurity ?? false, + privileges: (spec.privileges ?? []).map((privilege) => ({ grantable: false, owner: false, ...privilege })), stats: null, }; for (const dependent of spec.dependents ?? []) { diff --git a/src/lib/schema-change-api.ts b/src/lib/schema-change-api.ts index 507a8c0..9b19af1 100644 --- a/src/lib/schema-change-api.ts +++ b/src/lib/schema-change-api.ts @@ -115,7 +115,7 @@ export interface Runbook { script: string; uncompiled: number[]; server: { version: string; collectedAt: string }; - settings: { lockTimeoutSeconds: number; lockAttempts: number; backfillBatchRows: number; backfillPauseMs: number; defaultSchema: string }; + settings: { lockTimeoutSeconds: number; lockAttempts: number; compatViews: boolean; backfillBatchRows: number; backfillPauseMs: number; defaultSchema: string }; /** What the tables should look like once the steps that run by default have run, for checking the database afterwards. */ expected: ExpectedState; } @@ -128,6 +128,7 @@ export interface ExpectedTable { checks: { name: string; validated: boolean }[]; foreignKeys: { name: string; columns: string[]; refTable: string; refColumns: string[]; validated: boolean }[]; indexes: { name: string; columns: (string | null)[]; unique: boolean }[]; + views: string[]; } export interface ExpectedState { @@ -310,7 +311,7 @@ export const fetchPreflight = (connectionId: string, tables: string[], signal?: export interface VerifyMismatch { table: string; - kind: "table" | "column" | "primary-key" | "unique" | "check" | "foreign-key" | "index"; + kind: "table" | "column" | "primary-key" | "unique" | "check" | "foreign-key" | "index" | "view"; message: string; }