/** * Postgres default constraint names. * * When a constraint is authored without a name, Postgres derives one at * deploy time (`ChooseConstraintName` in the server): `{table}_pkey` for * primary keys, `{table}_{cols}_key` for unique constraints, * `{table}_{col}_fkey` for foreign keys, `{table}_{col}_check` (first * referenced column) or `{table}_check` for check constraints. Synthesizing * the same names makes unnamed authorship comparable to (and revertible as) * what the catalog will actually contain. */ /** A parsed `Constraint` node (structural — the fields this module reads). */ export interface ConstraintNode { contype?: string; conname?: string; keys?: { String?: { sval?: string; }; }[]; fk_attrs?: { String?: { sval?: string; }; }[]; raw_expr?: unknown; } /** First `ColumnRef` column name reached in an expression tree, DFS order. */ export declare function firstColumnRef(node: unknown): string | null; /** * The name Postgres would assign to an unnamed constraint on `table`, given * the constraint node and (for column-attached constraints) the owning * column. Returns `null` for kinds without a stable derivation (exclusion * constraints and anything unrecognized). */ export declare function defaultConstraintName(table: string, constraint: ConstraintNode, column?: string): string | null;