@prisma-next/target-postgres 0.12.0-dev.2 → 0.12.0-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/control.mjs +5 -5
- package/dist/{descriptor-meta-Dvr_77Z3.mjs → descriptor-meta-Uu8QaClr.mjs} +2 -2
- package/dist/{descriptor-meta-Dvr_77Z3.mjs.map → descriptor-meta-Uu8QaClr.mjs.map} +1 -1
- package/dist/{descriptor-meta-runtime-ByjztWgs.mjs → descriptor-meta-runtime-DMRX39kp.mjs} +2 -2
- package/dist/{descriptor-meta-runtime-ByjztWgs.mjs.map → descriptor-meta-runtime-DMRX39kp.mjs.map} +1 -1
- package/dist/{enum-planning-DrNWCtCp.mjs → enum-planning-DRA9LaMU.mjs} +0 -0
- package/dist/{enum-planning-DrNWCtCp.mjs.map → enum-planning-DRA9LaMU.mjs.map} +1 -1
- package/dist/enum-planning.d.mts +1 -1
- package/dist/enum-planning.mjs +1 -1
- package/dist/{issue-planner-2RgYsjUJ.mjs → issue-planner-BtaL6OfW.mjs} +7 -7
- package/dist/{issue-planner-2RgYsjUJ.mjs.map → issue-planner-BtaL6OfW.mjs.map} +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.mjs +1 -1
- package/dist/{op-factory-call-C_K5ibAY.mjs → op-factory-call-ewOd5q6L.mjs} +2 -2
- package/dist/{op-factory-call-C_K5ibAY.mjs.map → op-factory-call-ewOd5q6L.mjs.map} +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +2 -1
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-CC3r_uNJ.mjs → planner-Bjz5pnLa.mjs} +4 -4
- package/dist/{planner-CC3r_uNJ.mjs.map → planner-Bjz5pnLa.mjs.map} +1 -1
- package/dist/{planner-ddl-builders-DgyqpFji.mjs → planner-ddl-builders-BNMfSE9r.mjs} +2 -2
- package/dist/{planner-ddl-builders-DgyqpFji.mjs.map → planner-ddl-builders-BNMfSE9r.mjs.map} +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-sql-checks-BMu3fiMc.mjs → planner-sql-checks-CfEiTXoQ.mjs} +2 -2
- package/dist/{planner-sql-checks-BMu3fiMc.mjs.map → planner-sql-checks-CfEiTXoQ.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-C0UtIDB8.mjs → postgres-contract-serializer-BnOboPWs.mjs} +3 -3
- package/dist/{postgres-contract-serializer-C0UtIDB8.mjs.map → postgres-contract-serializer-BnOboPWs.mjs.map} +1 -1
- package/dist/{postgres-enum-type-DS-KLVRH.mjs → postgres-enum-type-BMgyxNyy.mjs} +2 -1
- package/dist/postgres-enum-type-BMgyxNyy.mjs.map +1 -0
- package/dist/{postgres-enum-type-5MBoKsIj.d.mts → postgres-enum-type-CSzsvXrO.d.mts} +4 -1
- package/dist/postgres-enum-type-CSzsvXrO.d.mts.map +1 -0
- package/dist/{postgres-schema-vp5rvbYg.mjs → postgres-schema-BxAuNFX0.mjs} +2 -2
- package/dist/{postgres-schema-vp5rvbYg.mjs.map → postgres-schema-BxAuNFX0.mjs.map} +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{tables-C8RrPLUq.mjs → tables-DoA39Yqo.mjs} +2 -2
- package/dist/{tables-C8RrPLUq.mjs.map → tables-DoA39Yqo.mjs.map} +1 -1
- package/dist/types.d.mts +1 -1
- package/dist/types.mjs +2 -2
- package/package.json +17 -17
- package/src/core/postgres-enum-type.ts +4 -0
- package/dist/postgres-enum-type-5MBoKsIj.d.mts.map +0 -1
- package/dist/postgres-enum-type-DS-KLVRH.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-enum-type-BMgyxNyy.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SqlNode } from "@prisma-next/sql-contract/types";
|
|
2
|
+
import { ControlPolicy } from "@prisma-next/contract/types";
|
|
2
3
|
|
|
3
4
|
//#region src/core/postgres-enum-type.d.ts
|
|
4
5
|
interface PostgresEnumTypeInput<TName extends string = string, TValues extends readonly string[] = readonly string[]> {
|
|
@@ -15,6 +16,7 @@ interface PostgresEnumTypeInput<TName extends string = string, TValues extends r
|
|
|
15
16
|
*/
|
|
16
17
|
readonly nativeType?: string;
|
|
17
18
|
readonly values: TValues;
|
|
19
|
+
readonly control?: ControlPolicy;
|
|
18
20
|
}
|
|
19
21
|
/** Codec id used by Postgres enum-typed columns (text wire format). */
|
|
20
22
|
declare const PG_ENUM_CODEC_ID = "pg/enum@1";
|
|
@@ -56,6 +58,7 @@ declare class PostgresEnumType<TName extends string = string, TValues extends re
|
|
|
56
58
|
* dispatching through the prototype-only `codecBinding` accessor.
|
|
57
59
|
*/
|
|
58
60
|
readonly codecId: typeof PG_ENUM_CODEC_ID;
|
|
61
|
+
readonly control?: ControlPolicy;
|
|
59
62
|
constructor(input: PostgresEnumTypeInput<TName, TValues>);
|
|
60
63
|
get codecBinding(): {
|
|
61
64
|
readonly codecId: typeof PG_ENUM_CODEC_ID;
|
|
@@ -66,4 +69,4 @@ declare class PostgresEnumType<TName extends string = string, TValues extends re
|
|
|
66
69
|
}
|
|
67
70
|
//#endregion
|
|
68
71
|
export { PostgresEnumTypeInput as n, PostgresEnumType as t };
|
|
69
|
-
//# sourceMappingURL=postgres-enum-type-
|
|
72
|
+
//# sourceMappingURL=postgres-enum-type-CSzsvXrO.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-enum-type-CSzsvXrO.d.mts","names":[],"sources":["../src/core/postgres-enum-type.ts"],"mappings":";;;;UAIiB,qBAAA;;AAAjB;;;;WASW,IAAA,EAAM,KAAA;EAQI;;;;;EAAA,SAFV,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAAA,SACR,OAAA,GAAU,aAAA;AAAA;;cAIf,gBAAA;;;AAJ4B;AACjC;;;;AAGqB;AAyBtB;;;;;;;;;;;;;;;cAAa,gBAAA,+FAGH,OAAA;EAAA,SACU,IAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAFF;;;;;;;;;EAAA,SAYN,OAAA,SAAgB,gBAAA;EAAA,SACR,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,qBAAA,CAAsB,KAAA,EAAO,OAAA;EAAA,IAY5C,YAAA,CAAA;IAAA,SACO,OAAA,SAAgB,gBAAA;IAAA,SAChB,UAAA;MAAA,SAAuB,MAAA,EAAQ,OAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresEnumType } from "./postgres-enum-type-
|
|
1
|
+
import { t as PostgresEnumType } from "./postgres-enum-type-BMgyxNyy.mjs";
|
|
2
2
|
import { n as escapeLiteral } from "./sql-utils-CggjWNij.mjs";
|
|
3
3
|
import { NamespaceBase, UNBOUND_NAMESPACE_ID, freezeNode } from "@prisma-next/framework-components/ir";
|
|
4
4
|
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
@@ -158,4 +158,4 @@ function postgresCreateNamespace(input) {
|
|
|
158
158
|
//#endregion
|
|
159
159
|
export { postgresCreateNamespace as i, PostgresUnboundSchema as n, isPostgresSchema as r, PostgresSchema as t };
|
|
160
160
|
|
|
161
|
-
//# sourceMappingURL=postgres-schema-
|
|
161
|
+
//# sourceMappingURL=postgres-schema-BxAuNFX0.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-schema-
|
|
1
|
+
{"version":3,"file":"postgres-schema-BxAuNFX0.mjs","names":[],"sources":["../src/core/postgres-schema.ts"],"sourcesContent":["import {\n freezeNode,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport {\n type SqlNamespaceTablesInput,\n type SqlStorage,\n StorageTable,\n type StorageTableInput,\n} from '@prisma-next/sql-contract/types';\nimport { PostgresEnumType, type PostgresEnumTypeInput } from './postgres-enum-type';\nimport { escapeLiteral } from './sql-utils';\n\nexport interface PostgresSchemaInput {\n readonly id: string;\n readonly tables?: Record<string, StorageTable | StorageTableInput>;\n readonly enum?: Record<string, PostgresEnumType | PostgresEnumTypeInput>;\n}\n\n/**\n * Postgres target `Namespace` concretion — a Postgres schema (`CREATE\n * SCHEMA …`). Each Postgres `SqlStorage` carries a\n * `namespaces: Record<NamespaceId, PostgresSchema>` map populated by\n * the Postgres PSL interpreter from `namespace { … }` AST buckets.\n *\n * Qualifier emission is the rendering seam: DDL / SQL emission asks the\n * namespace for its qualifier (`\"<schema>\"`) or for a qualified table\n * name (`\"<schema>\".\"<table>\"`) and consumes the result polymorphically.\n * The unbound singleton below overrides these methods to elide the\n * prefix entirely — call sites stay polymorphic and never branch on\n * `id === UNBOUND_NAMESPACE_ID`.\n */\nexport class PostgresSchema extends NamespaceBase {\n /**\n * Stable singleton reference for the late-bound slot. Materialised\n * lazily below the singleton subclass declaration so the static\n * initialiser sees the subclass before assigning. Consumers always\n * reach for `PostgresSchema.unbound` (or `PostgresUnboundSchema.instance`\n * — same identity).\n */\n static unbound: PostgresUnboundSchema;\n\n declare readonly kind: 'schema';\n readonly id: string;\n readonly tables: Readonly<Record<string, StorageTable>>;\n readonly enum: Readonly<Record<string, PostgresEnumType>>;\n\n constructor(input: PostgresSchemaInput) {\n super();\n this.id = input.id;\n this.tables = Object.freeze(\n Object.fromEntries(\n Object.entries(input.tables ?? {}).map(([name, t]) => [\n name,\n t instanceof StorageTable ? t : new StorageTable(t),\n ]),\n ),\n );\n this.enum = Object.freeze(\n Object.fromEntries(\n Object.entries(input.enum ?? {}).map(([name, ty]) => [\n name,\n ty instanceof PostgresEnumType ? ty : new PostgresEnumType(ty),\n ]),\n ),\n );\n Object.defineProperty(this, 'kind', {\n value: 'schema',\n writable: false,\n enumerable: false,\n configurable: true,\n });\n freezeNode(this);\n }\n\n /**\n * The bare schema qualifier as it would appear in a rendered SQL\n * fragment (already quoted). The unbound-schema singleton overrides\n * this to return `''`.\n */\n qualifier(): string {\n return `\"${this.id}\"`;\n }\n\n /**\n * Qualify a table name with the schema prefix\n * (`\"<schema>\".\"<table>\"`). The unbound-schema singleton overrides\n * this to emit just `\"<table>\"` so the resolved DDL is unqualified\n * and `search_path` decides where the object lands at runtime.\n */\n qualifyTable(tableName: string): string {\n return `\"${this.id}\".\"${tableName}\"`;\n }\n\n /**\n * Render a SQL string-literal containing the qualified-name form\n * suitable for `to_regclass(...)` arguments (e.g. `'\"public\".\"user\"'`).\n * The unbound singleton overrides this to elide the schema prefix\n * (`'\"user\"'`) so `search_path` resolves the object at runtime.\n */\n regclassLiteral(name: string): string {\n return `'${escapeLiteral(this.qualifyTable(name))}'`;\n }\n\n /**\n * Render a SQL expression that evaluates to this namespace's schema\n * name at runtime, ready to drop into a `WHERE table_schema = …` /\n * `WHERE n.nspname = …` clause. Named schemas emit a quoted SQL\n * literal (`'public'`); the unbound singleton overrides this to emit\n * `current_schema()` so catalog queries match whichever schema the\n * connection's `search_path` resolved at runtime.\n */\n schemaSqlExpression(): string {\n return `'${escapeLiteral(this.id)}'`;\n }\n\n /**\n * The bare schema name a DDL planner should target when emitting\n * statements that need to identify this namespace in the live\n * database (e.g. `CREATE TABLE \"<ddlSchemaName>\".\"<table>\" …`,\n * catalog filters, planner conflict lookups). Named schemas resolve\n * to their own id. The `PostgresUnboundSchema` singleton inherits\n * this and returns `UNBOUND_NAMESPACE_ID` — callers that dispatch\n * through `qualifyTableName` / `toRegclassLiteral` route through the\n * polymorphic `PostgresUnboundSchema` overrides and produce\n * unqualified (search-path-resolved) output automatically.\n */\n ddlSchemaName(_storage: SqlStorage): string {\n return this.id;\n }\n}\n\n/**\n * Singleton subclass for the reserved sentinel namespace id\n * (`UNBOUND_NAMESPACE_ID`) — the late-bound Postgres slot whose binding\n * the connection's `search_path` resolves at runtime. Overrides\n * qualifier emission to elide the schema prefix; call sites that consume\n * `qualifier()` / `qualifyTable()` get unqualified output without\n * branching on the namespace id.\n *\n * This is the target-side materialization of \"the framework provides\n * affordances; targets implement specifics\": the framework names the\n * sentinel; Postgres decides what late-bound means here (the table\n * name, naked — the schema is supplied by the live connection's\n * `search_path`).\n *\n * `ddlSchemaName` is inherited from `PostgresSchema` and returns\n * `UNBOUND_NAMESPACE_ID`. Downstream helpers (`qualifyTableName`,\n * `toRegclassLiteral`) route through the polymorphic factory and\n * produce unqualified output automatically.\n */\nexport class PostgresUnboundSchema extends PostgresSchema {\n static readonly instance: PostgresUnboundSchema = new PostgresUnboundSchema();\n\n constructor(input?: PostgresSchemaInput) {\n super(input ?? { id: UNBOUND_NAMESPACE_ID });\n }\n\n override qualifier(): string {\n return '';\n }\n\n override qualifyTable(tableName: string): string {\n return `\"${tableName}\"`;\n }\n\n override schemaSqlExpression(): string {\n return 'current_schema()';\n }\n}\n\nPostgresSchema.unbound = PostgresUnboundSchema.instance;\n\n/**\n * Narrow an arbitrary namespace (or `undefined`) to `PostgresSchema`\n * so callers can dispatch to the polymorphic emission methods without\n * branching at the call site. Uses the structural `kind` discriminator\n * (`'schema'`) rather than `instanceof` so the check survives realm /\n * bundle / hot-reload boundaries — matching the rest of the IR's\n * narrowing convention. `PostgresUnboundSchema` passes through because\n * it inherits the same `kind: 'schema'` from `PostgresSchema`.\n */\nexport function isPostgresSchema(ns: unknown): ns is PostgresSchema {\n return (ns as { kind?: unknown } | null | undefined)?.kind === 'schema';\n}\n\n/**\n * Target-supplied `Namespace` factory the Postgres target plumbs\n * through `defineContract({ createNamespace })` and the SQL PSL\n * interpreter. Returns the unbound singleton for the framework\n * sentinel and a fresh `PostgresSchema` for any other coordinate.\n *\n * The factory has no per-call state — every named id deterministically\n * maps to a distinct schema instance — so callers can pass it through\n * by reference and trust the resulting `SqlStorage.namespaces` map to\n * be value-stable for a given input set.\n */\nexport function postgresCreateNamespace(input: SqlNamespaceTablesInput): PostgresSchema {\n if (input.id === UNBOUND_NAMESPACE_ID) {\n return new Post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AsB,WAA2B;EAC/C,OAAO,IAAI,UAAU;CACvB;CAEA,sBAAuC;EACrC,OAAO;CACT;AACF;AAEA,eAAe,UAAU,sBAAsB;;;;;;;;;;AAW/C,SAAgB,iBAAiB,IAAmC;CAClE,OAAQ,IAA8C,SAAS;AACjE;;;;;;;;;;;;AAaA,SAAgB,wBAAwB,OAAgD;CACtF,IAAI,MAAM,OAAO,sBACf,OAAO,IAAI,sBAAsB,KAAK;CAExC,OAAO,IAAI,eAAe,KAAK;AACjC"}
|
package/dist/runtime.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-
|
|
2
|
-
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-
|
|
1
|
+
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-DMRX39kp.mjs";
|
|
2
|
+
import { t as PostgresContractSerializer } from "./postgres-contract-serializer-BnOboPWs.mjs";
|
|
3
3
|
//#region src/exports/runtime.ts
|
|
4
4
|
/**
|
|
5
5
|
* Target-postgres deliberately does NOT import `SqlRuntimeTargetDescriptor` from `@prisma-next/sql-runtime`. The target package is a control-plane residence and must not pull the SQL execution-plane package into its dependency closure. The runtime descriptor here is shaped to satisfy the framework's `RuntimeTargetDescriptor` plus the structural `SqlStaticContributions` (`codecs:` returning a descriptor list) that
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-CggjWNij.mjs";
|
|
2
|
-
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, n as columnDefaultExistsCheck, o as columnTypeCheck, r as columnExistsCheck, s as constraintExistsCheck } from "./planner-sql-checks-
|
|
2
|
+
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, n as columnDefaultExistsCheck, o as columnTypeCheck, r as columnExistsCheck, s as constraintExistsCheck } from "./planner-sql-checks-CfEiTXoQ.mjs";
|
|
3
3
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
4
4
|
//#region src/core/migrations/operations/shared.ts
|
|
5
5
|
function step(description, sql) {
|
|
@@ -513,4 +513,4 @@ function dropTable(schemaName, tableName) {
|
|
|
513
513
|
//#endregion
|
|
514
514
|
export { setNotNull as S, alterColumnType as _, addEnumValues as a, dropNotNull as b, renameType as c, installExtension as d, addForeignKey as f, addColumn as g, dropConstraint as h, dropIndex as i, createExtension as l, addUnique as m, dropTable as n, createEnumType as o, addPrimaryKey as p, createIndex as r, dropEnumType as s, createTable as t, createSchema as u, dropColumn as v, setDefault as x, dropDefault as y };
|
|
515
515
|
|
|
516
|
-
//# sourceMappingURL=tables-
|
|
516
|
+
//# sourceMappingURL=tables-DoA39Yqo.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables-C8RrPLUq.mjs","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/operations/columns.ts","../src/core/migrations/operations/constraints.ts","../src/core/migrations/operations/dependencies.ts","../src/core/migrations/operations/enums.ts","../src/core/migrations/operations/indexes.ts","../src/core/migrations/operations/tables.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { quoteIdentifier } from '../../sql-utils';\nimport type { OperationClass, PostgresPlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Literal-args shape for a column definition consumed by `createTable` and\n * `addColumn`. Fully materialized: codec expansion and default rendering have\n * already happened in the wrapper.\n *\n * - `typeSql` is the column's DDL type string (e.g. `\"integer\"`, `\"SERIAL\"`,\n * `\"varchar(100)\"`), already produced by `buildColumnTypeSql` in the\n * call-factory wrapper.\n * - `defaultSql` is the full `DEFAULT …` clause (e.g. `\"DEFAULT 42\"`) or an\n * empty string when the column has no default, matching\n * `buildColumnDefaultSql`'s output.\n */\nexport interface ColumnSpec {\n readonly name: string;\n readonly typeSql: string;\n readonly defaultSql: string;\n readonly nullable: boolean;\n}\n\n/**\n * Literal-args shape for a foreign key definition. `references.schema`\n * carries the target table's namespace (schema) coordinate so the rendered\n * DDL qualifies the REFERENCES clause correctly for cross-schema FKs.\n */\nexport interface ForeignKeySpec {\n readonly name: string;\n readonly columns: readonly string[];\n readonly references: {\n readonly schema: string;\n readonly table: string;\n readonly columns: readonly string[];\n };\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n}\n\nexport function step(description: string, sql: string) {\n return { description, sql };\n}\n\nexport function targetDetails(\n objectType: OperationClass,\n name: string,\n schema: string,\n table?: string,\n): { readonly id: 'postgres'; readonly details: PostgresPlanTargetDetails } {\n return {\n id: 'postgres',\n details: { schema, objectType, name, ...ifDefined('table', table) },\n };\n}\n\nexport function renderColumnDefinition(column: ColumnSpec): string {\n const parts = [\n quoteIdentifier(column.name),\n column.typeSql,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport {\n columnDefaultExistsCheck,\n columnExistsCheck,\n columnNullabilityCheck,\n columnTypeCheck,\n qualifyTableName,\n} from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, step, targetDetails } from './shared';\n\nexport function addColumn(schemaName: string, tableName: string, column: ColumnSpec): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const parts = [\n `ALTER TABLE ${qualified}`,\n `ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n const addSql = parts.join(' ');\n\n return {\n id: `column.${tableName}.${column.name}`,\n label: `Add column \"${column.name}\" to \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('column', column.name, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${column.name}\" is missing`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: column.name,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add column \"${column.name}\"`, addSql)],\n postcheck: [\n step(\n `verify column \"${column.name}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: column.name }),\n ),\n ],\n };\n}\n\nexport function dropColumn(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropColumn.${tableName}.${columnName}`,\n label: `Drop column \"${columnName}\" from \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop column \"${columnName}\"`,\n `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" does not exist`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\n };\n}\n\n/**\n * `qualifiedTargetType` is the new column type as it appears in the\n * `ALTER COLUMN TYPE` clause (schema-qualified for user-defined types, raw\n * native name for built-ins). `formatTypeExpected` is the unqualified\n * `format_type` form used in the postcheck. `rawTargetTypeForLabel` is the\n * string appearing in the human-readable label (typically `toType` when\n * explicit, else the column's native type).\n */\nexport function alterColumnType(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n },\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const usingClause = options.using\n ? ` USING ${options.using}`\n : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;\n return {\n id: `alterType.${tableName}.${columnName}`,\n label: `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `alter type of \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} TYPE ${options.qualifiedTargetType}${usingClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has type \"${options.formatTypeExpected}\"`,\n columnTypeCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n expectedType: options.formatTypeExpected,\n }),\n ),\n ],\n meta: { warning: 'TABLE_REWRITE' },\n };\n}\n\nexport function setNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `alterNullability.setNotNull.${tableName}.${columnName}`,\n label: `Set NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n step(\n `ensure no NULL values in \"${columnName}\"`,\n `SELECT NOT EXISTS (SELECT 1 FROM ${qualified} WHERE ${quoteIdentifier(columnName)} IS NULL)`,\n ),\n ],\n execute: [\n step(\n `set NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET NOT NULL`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" is NOT NULL`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n ),\n ],\n };\n}\n\nexport function dropNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `alterNullability.dropNotNull.${tableName}.${columnName}`,\n label: `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'widening',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" is nullable`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: true,\n }),\n ),\n ],\n };\n}\n\n/**\n * `defaultSql` is the full `DEFAULT …` clause as produced by\n * `buildColumnDefaultSql` — e.g. `\"DEFAULT 42\"`,\n * `\"DEFAULT (CURRENT_TIMESTAMP)\"`, or `\"DEFAULT nextval('seq'::regclass)\"`.\n *\n * `operationClass` defaults to `'additive'` (setting a default on a column\n * that currently has none). The reconciliation planner passes `'widening'`\n * when the column already has a different default — policy enforcement\n * treats that as a widening change rather than an additive one.\n */\nexport function setDefault(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `setDefault.${tableName}.${columnName}`,\n label: `Set default on \"${tableName}\".\"${columnName}\"`,\n operationClass,\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `set default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${defaultSql}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has a default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: true,\n }),\n ),\n ],\n };\n}\n\nexport function dropDefault(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropDefault.${tableName}.${columnName}`,\n label: `Drop default on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has no default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { constraintExistsCheck, qualifyTableName } from '../planner-sql-checks';\nimport { type ForeignKeySpec, type Op, step, targetDetails } from './shared';\n\nconst REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\n};\n\nfunction renderForeignKeySql(schemaName: string, tableName: string, fk: ForeignKeySpec): string {\n let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}\nADD CONSTRAINT ${quoteIdentifier(fk.name)}\nFOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')})\nREFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.references.columns\n .map(quoteIdentifier)\n .join(', ')})`;\n\n if (fk.onDelete !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onDelete];\n if (!action) {\n throw new Error(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);\n }\n sql += `\\nON DELETE ${action}`;\n }\n if (fk.onUpdate !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];\n if (!action) {\n throw new Error(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);\n }\n sql += `\\nON UPDATE ${action}`;\n }\n return sql;\n}\n\nexport function addPrimaryKey(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n return {\n id: `primaryKey.${tableName}.${constraintName}`,\n label: `Add primary key on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('primaryKey', constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure primary key \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [\n step(\n `add primary key \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`,\n ),\n ],\n postcheck: [\n step(\n `verify primary key \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addUnique(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n return {\n id: `unique.${tableName}.${constraintName}`,\n label: `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`,\n operationClass: 'additive',\n target: targetDetails('unique', constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [\n step(\n `add unique constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addForeignKey(schemaName: string, tableName: string, fk: ForeignKeySpec): Op {\n return {\n id: `foreignKey.${tableName}.${fk.name}`,\n label: `Add foreign key \"${fk.name}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('foreignKey', fk.name, schemaName, tableName),\n precheck: [\n step(\n `ensure FK \"${fk.name}\" does not exist`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add FK \"${fk.name}\"`, renderForeignKeySql(schemaName, tableName, fk))],\n postcheck: [\n step(\n `verify FK \"${fk.name}\" exists`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n }),\n ),\n ],\n };\n}\n\n/**\n * `kind` feeds the operation's `target.details.objectType`. Descriptor-flow\n * does not carry kind information in its drop-constraint descriptor, so the\n * default is `'unique'`. The reconciliation planner passes the correct kind\n * (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the `SchemaIssue`\n * that produced the drop.\n */\nexport function dropConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropConstraint.${tableName}.${constraintName}`,\n label: `Drop constraint \"${constraintName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails(kind, constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n execute: [\n step(\n `drop constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport { type Op, step } from './shared';\n\nexport function createExtension(extensionName: string): Op {\n return {\n id: `extension.${extensionName}`,\n label: `Create extension \"${extensionName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${quoteIdentifier(extensionName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n\n/**\n * Install a Postgres extension as the baseline op for an extension-pack\n * contract space. Layered on top of {@link createExtension}: stamps an\n * `invariantId` (required so the per-space marker records the install),\n * scopes the op `id` under a caller-chosen namespace (e.g. `pgvector.`),\n * and emits pre- and postcheck SQL probing `pg_extension`. The richer\n * shape lets the runner's idempotency probe skip the install on re-run\n * (postcheck-pre-satisfied) without firing the precheck.\n *\n * Use this for hand-rolled baseline migrations in contract-space\n * extension packages (e.g. `extension-pgvector`, `extension-paradedb`);\n * use the bare {@link createExtension} for planner-emitted ops where the\n * caller already controls idempotency through the surrounding plan.\n */\nexport function installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n}): Op {\n const { extensionName, invariantId, id } = options;\n const label = options.label ?? `Enable extension \"${extensionName}\"`;\n return {\n id,\n label,\n operationClass: 'additive',\n invariantId,\n target: {\n id: 'postgres',\n details: { schema: 'public', objectType: 'dependency', name: extensionName },\n },\n precheck: [\n step(\n `verify extension \"${extensionName}\" is not already enabled`,\n `SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n execute: [\n step(\n `create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${extensionName}`,\n ),\n ],\n postcheck: [\n step(\n `confirm extension \"${extensionName}\" is enabled`,\n `SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n };\n}\n\nexport function createSchema(schemaName: string): Op {\n return {\n id: `schema.${schemaName}`,\n label: `Create schema \"${schemaName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create schema \"${schemaName}\"`,\n `CREATE SCHEMA IF NOT EXISTS ${quoteIdentifier(schemaName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n","import { escapeLiteral, qualifyName, quoteIdentifier } from '../../sql-utils';\nimport { type Op, step, targetDetails } from './shared';\n\nfunction enumTypeExistsCheck(schemaName: string, nativeType: string, exists = true): string {\n const clause = exists ? 'EXISTS' : 'NOT EXISTS';\n return `SELECT ${clause} (\n SELECT 1\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n WHERE n.nspname = '${escapeLiteral(schemaName)}'\n AND t.typname = '${escapeLiteral(nativeType)}'\n)`;\n}\n\nexport function createEnumType(\n schemaName: string,\n typeName: string,\n values: readonly string[],\n nativeType: string = typeName,\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n const literalValues = values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n return {\n id: `type.${typeName}`,\n label: `Create enum type \"${typeName}\"`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(\n `ensure type \"${nativeType}\" does not exist`,\n enumTypeExistsCheck(schemaName, nativeType, false),\n ),\n ],\n execute: [\n step(\n `create enum type \"${typeName}\"`,\n `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`,\n ),\n ],\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\n/**\n * `typeName` is the contract-facing type name (used for id/label).\n * `nativeType` is the Postgres type name to mutate (may differ for external types).\n */\nexport function addEnumValues(\n schemaName: string,\n typeName: string,\n nativeType: string,\n values: readonly string[],\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n return {\n id: `type.${typeName}.addValues`,\n label: `Add values to enum type \"${typeName}\": ${values.join(', ')}`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(`ensure type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n execute: values.map((value) =>\n step(\n `add value '${value}' to enum \"${nativeType}\"`,\n `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`,\n ),\n ),\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\nexport function dropEnumType(schemaName: string, typeName: string): Op {\n const qualified = qualifyName(schemaName, typeName);\n return {\n id: `type.${typeName}.drop`,\n label: `Drop enum type \"${typeName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [step(`ensure type \"${typeName}\" exists`, enumTypeExistsCheck(schemaName, typeName))],\n execute: [step(`drop enum type \"${typeName}\"`, `DROP TYPE ${qualified}`)],\n postcheck: [\n step(`verify type \"${typeName}\" removed`, enumTypeExistsCheck(schemaName, typeName, false)),\n ],\n };\n}\n\nexport function renameType(schemaName: string, fromName: string, toName: string): Op {\n const qualifiedFrom = qualifyName(schemaName, fromName);\n return {\n id: `type.${fromName}.rename`,\n label: `Rename type \"${fromName}\" to \"${toName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', fromName, schemaName),\n precheck: [\n step(`ensure type \"${fromName}\" exists`, enumTypeExistsCheck(schemaName, fromName)),\n step(\n `ensure type \"${toName}\" does not already exist`,\n enumTypeExistsCheck(schemaName, toName, false),\n ),\n ],\n execute: [\n step(\n `rename type \"${fromName}\" to \"${toName}\"`,\n `ALTER TYPE ${qualifiedFrom} RENAME TO ${quoteIdentifier(toName)}`,\n ),\n ],\n postcheck: [step(`verify type \"${toName}\" exists`, enumTypeExistsCheck(schemaName, toName))],\n };\n}\n","import { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\nexport interface CreateIndexExtras {\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\nfunction renderIndexOptionValue(key: string, value: unknown): string {\n if (typeof value === 'string') return `'${escapeLiteral(value)}'`;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n throw new Error(\n `Index option \"${key}\" must be a string, finite number, or boolean; got ${typeof value}`,\n );\n}\n\nfunction renderIndexOptions(options: Record<string, unknown>): string {\n return Object.entries(options)\n .map(([key, value]) => `${quoteIdentifier(key)} = ${renderIndexOptionValue(key, value)}`)\n .join(', ');\n}\n\nexport function createIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: CreateIndexExtras,\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const using = extras?.type ? ` USING ${quoteIdentifier(extras.type)}` : '';\n const options = extras?.options;\n const withClause =\n options && Object.keys(options).length > 0 ? ` WITH (${renderIndexOptions(options)})` : '';\n return {\n id: `index.${tableName}.${indexName}`,\n label: `Create index \"${indexName}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [\n step(\n `ensure index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n execute: [\n step(\n `create index \"${indexName}\"`,\n `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropIndex(schemaName: string, tableName: string, indexName: string): Op {\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index \"${indexName}\"`,\n operationClass: 'destructive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [\n step(\n `ensure index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n execute: [\n step(`drop index \"${indexName}\"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n };\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, renderColumnDefinition, step, targetDetails } from './shared';\n\nexport function createTable(\n schemaName: string,\n tableName: string,\n columns: ReadonlyArray<ColumnSpec>,\n primaryKey?: { readonly columns: readonly string[] },\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnDefs = columns.map(renderColumnDefinition);\n const constraintDefs: string[] = [];\n if (primaryKey) {\n constraintDefs.push(`PRIMARY KEY (${primaryKey.columns.map(quoteIdentifier).join(', ')})`);\n }\n const allDefs = [...columnDefs, ...constraintDefs];\n const createSql = `CREATE TABLE ${qualified} (\\n ${allDefs.join(',\\n ')}\\n)`;\n\n return {\n id: `table.${tableName}`,\n label: `Create table \"${tableName}\"`,\n summary: `Creates table \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [\n step(\n `ensure table \"${tableName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`,\n ),\n ],\n execute: [step(`create table \"${tableName}\"`, createSql)],\n postcheck: [\n step(\n `verify table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropTable(schemaName: string, tableName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [\n step(\n `ensure table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${qualified}`)],\n postcheck: [\n step(\n `verify table \"${tableName}\" does not exist`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AAS,CAAC,KAAK,eAAe,UAAU,IAAI,cAAc,WAAW,CAAC;EACtE,WAAW,CACT,KACE,iBAAiB,UAAU,mBAC3B,sBAAsB,kBAAkB,YAAY,SAAS,EAAE,UACjE,CACF;CACF;AACF"}
|
|
1
|
+
{"version":3,"file":"tables-DoA39Yqo.mjs","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/operations/columns.ts","../src/core/migrations/operations/constraints.ts","../src/core/migrations/operations/dependencies.ts","../src/core/migrations/operations/enums.ts","../src/core/migrations/operations/indexes.ts","../src/core/migrations/operations/tables.ts"],"sourcesContent":["import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { quoteIdentifier } from '../../sql-utils';\nimport type { OperationClass, PostgresPlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Literal-args shape for a column definition consumed by `createTable` and\n * `addColumn`. Fully materialized: codec expansion and default rendering have\n * already happened in the wrapper.\n *\n * - `typeSql` is the column's DDL type string (e.g. `\"integer\"`, `\"SERIAL\"`,\n * `\"varchar(100)\"`), already produced by `buildColumnTypeSql` in the\n * call-factory wrapper.\n * - `defaultSql` is the full `DEFAULT …` clause (e.g. `\"DEFAULT 42\"`) or an\n * empty string when the column has no default, matching\n * `buildColumnDefaultSql`'s output.\n */\nexport interface ColumnSpec {\n readonly name: string;\n readonly typeSql: string;\n readonly defaultSql: string;\n readonly nullable: boolean;\n}\n\n/**\n * Literal-args shape for a foreign key definition. `references.schema`\n * carries the target table's namespace (schema) coordinate so the rendered\n * DDL qualifies the REFERENCES clause correctly for cross-schema FKs.\n */\nexport interface ForeignKeySpec {\n readonly name: string;\n readonly columns: readonly string[];\n readonly references: {\n readonly schema: string;\n readonly table: string;\n readonly columns: readonly string[];\n };\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n}\n\nexport function step(description: string, sql: string) {\n return { description, sql };\n}\n\nexport function targetDetails(\n objectType: OperationClass,\n name: string,\n schema: string,\n table?: string,\n): { readonly id: 'postgres'; readonly details: PostgresPlanTargetDetails } {\n return {\n id: 'postgres',\n details: { schema, objectType, name, ...ifDefined('table', table) },\n };\n}\n\nexport function renderColumnDefinition(column: ColumnSpec): string {\n const parts = [\n quoteIdentifier(column.name),\n column.typeSql,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport {\n columnDefaultExistsCheck,\n columnExistsCheck,\n columnNullabilityCheck,\n columnTypeCheck,\n qualifyTableName,\n} from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, step, targetDetails } from './shared';\n\nexport function addColumn(schemaName: string, tableName: string, column: ColumnSpec): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const parts = [\n `ALTER TABLE ${qualified}`,\n `ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n const addSql = parts.join(' ');\n\n return {\n id: `column.${tableName}.${column.name}`,\n label: `Add column \"${column.name}\" to \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('column', column.name, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${column.name}\" is missing`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: column.name,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add column \"${column.name}\"`, addSql)],\n postcheck: [\n step(\n `verify column \"${column.name}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: column.name }),\n ),\n ],\n };\n}\n\nexport function dropColumn(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropColumn.${tableName}.${columnName}`,\n label: `Drop column \"${columnName}\" from \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop column \"${columnName}\"`,\n `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" does not exist`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\n };\n}\n\n/**\n * `qualifiedTargetType` is the new column type as it appears in the\n * `ALTER COLUMN TYPE` clause (schema-qualified for user-defined types, raw\n * native name for built-ins). `formatTypeExpected` is the unqualified\n * `format_type` form used in the postcheck. `rawTargetTypeForLabel` is the\n * string appearing in the human-readable label (typically `toType` when\n * explicit, else the column's native type).\n */\nexport function alterColumnType(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n },\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const usingClause = options.using\n ? ` USING ${options.using}`\n : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;\n return {\n id: `alterType.${tableName}.${columnName}`,\n label: `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `alter type of \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} TYPE ${options.qualifiedTargetType}${usingClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has type \"${options.formatTypeExpected}\"`,\n columnTypeCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n expectedType: options.formatTypeExpected,\n }),\n ),\n ],\n meta: { warning: 'TABLE_REWRITE' },\n };\n}\n\nexport function setNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `alterNullability.setNotNull.${tableName}.${columnName}`,\n label: `Set NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n step(\n `ensure no NULL values in \"${columnName}\"`,\n `SELECT NOT EXISTS (SELECT 1 FROM ${qualified} WHERE ${quoteIdentifier(columnName)} IS NULL)`,\n ),\n ],\n execute: [\n step(\n `set NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET NOT NULL`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" is NOT NULL`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n ),\n ],\n };\n}\n\nexport function dropNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `alterNullability.dropNotNull.${tableName}.${columnName}`,\n label: `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'widening',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" is nullable`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: true,\n }),\n ),\n ],\n };\n}\n\n/**\n * `defaultSql` is the full `DEFAULT …` clause as produced by\n * `buildColumnDefaultSql` — e.g. `\"DEFAULT 42\"`,\n * `\"DEFAULT (CURRENT_TIMESTAMP)\"`, or `\"DEFAULT nextval('seq'::regclass)\"`.\n *\n * `operationClass` defaults to `'additive'` (setting a default on a column\n * that currently has none). The reconciliation planner passes `'widening'`\n * when the column already has a different default — policy enforcement\n * treats that as a widening change rather than an additive one.\n */\nexport function setDefault(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `setDefault.${tableName}.${columnName}`,\n label: `Set default on \"${tableName}\".\"${columnName}\"`,\n operationClass,\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `set default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${defaultSql}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has a default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: true,\n }),\n ),\n ],\n };\n}\n\nexport function dropDefault(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropDefault.${tableName}.${columnName}`,\n label: `Drop default on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has no default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { constraintExistsCheck, qualifyTableName } from '../planner-sql-checks';\nimport { type ForeignKeySpec, type Op, step, targetDetails } from './shared';\n\nconst REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\n};\n\nfunction renderForeignKeySql(schemaName: string, tableName: string, fk: ForeignKeySpec): string {\n let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}\nADD CONSTRAINT ${quoteIdentifier(fk.name)}\nFOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')})\nREFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.references.columns\n .map(quoteIdentifier)\n .join(', ')})`;\n\n if (fk.onDelete !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onDelete];\n if (!action) {\n throw new Error(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);\n }\n sql += `\\nON DELETE ${action}`;\n }\n if (fk.onUpdate !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];\n if (!action) {\n throw new Error(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);\n }\n sql += `\\nON UPDATE ${action}`;\n }\n return sql;\n}\n\nexport function addPrimaryKey(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n return {\n id: `primaryKey.${tableName}.${constraintName}`,\n label: `Add primary key on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('primaryKey', constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure primary key \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [\n step(\n `add primary key \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`,\n ),\n ],\n postcheck: [\n step(\n `verify primary key \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addUnique(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n return {\n id: `unique.${tableName}.${constraintName}`,\n label: `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`,\n operationClass: 'additive',\n target: targetDetails('unique', constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [\n step(\n `add unique constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addForeignKey(schemaName: string, tableName: string, fk: ForeignKeySpec): Op {\n return {\n id: `foreignKey.${tableName}.${fk.name}`,\n label: `Add foreign key \"${fk.name}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('foreignKey', fk.name, schemaName, tableName),\n precheck: [\n step(\n `ensure FK \"${fk.name}\" does not exist`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add FK \"${fk.name}\"`, renderForeignKeySql(schemaName, tableName, fk))],\n postcheck: [\n step(\n `verify FK \"${fk.name}\" exists`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n }),\n ),\n ],\n };\n}\n\n/**\n * `kind` feeds the operation's `target.details.objectType`. Descriptor-flow\n * does not carry kind information in its drop-constraint descriptor, so the\n * default is `'unique'`. The reconciliation planner passes the correct kind\n * (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the `SchemaIssue`\n * that produced the drop.\n */\nexport function dropConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropConstraint.${tableName}.${constraintName}`,\n label: `Drop constraint \"${constraintName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails(kind, constraintName, schemaName, tableName),\n precheck: [\n step(\n `ensure constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n execute: [\n step(\n `drop constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport { type Op, step } from './shared';\n\nexport function createExtension(extensionName: string): Op {\n return {\n id: `extension.${extensionName}`,\n label: `Create extension \"${extensionName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${quoteIdentifier(extensionName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n\n/**\n * Install a Postgres extension as the baseline op for an extension-pack\n * contract space. Layered on top of {@link createExtension}: stamps an\n * `invariantId` (required so the per-space marker records the install),\n * scopes the op `id` under a caller-chosen namespace (e.g. `pgvector.`),\n * and emits pre- and postcheck SQL probing `pg_extension`. The richer\n * shape lets the runner's idempotency probe skip the install on re-run\n * (postcheck-pre-satisfied) without firing the precheck.\n *\n * Use this for hand-rolled baseline migrations in contract-space\n * extension packages (e.g. `extension-pgvector`, `extension-paradedb`);\n * use the bare {@link createExtension} for planner-emitted ops where the\n * caller already controls idempotency through the surrounding plan.\n */\nexport function installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n}): Op {\n const { extensionName, invariantId, id } = options;\n const label = options.label ?? `Enable extension \"${extensionName}\"`;\n return {\n id,\n label,\n operationClass: 'additive',\n invariantId,\n target: {\n id: 'postgres',\n details: { schema: 'public', objectType: 'dependency', name: extensionName },\n },\n precheck: [\n step(\n `verify extension \"${extensionName}\" is not already enabled`,\n `SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n execute: [\n step(\n `create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${extensionName}`,\n ),\n ],\n postcheck: [\n step(\n `confirm extension \"${extensionName}\" is enabled`,\n `SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n };\n}\n\nexport function createSchema(schemaName: string): Op {\n return {\n id: `schema.${schemaName}`,\n label: `Create schema \"${schemaName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create schema \"${schemaName}\"`,\n `CREATE SCHEMA IF NOT EXISTS ${quoteIdentifier(schemaName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n","import { escapeLiteral, qualifyName, quoteIdentifier } from '../../sql-utils';\nimport { type Op, step, targetDetails } from './shared';\n\nfunction enumTypeExistsCheck(schemaName: string, nativeType: string, exists = true): string {\n const clause = exists ? 'EXISTS' : 'NOT EXISTS';\n return `SELECT ${clause} (\n SELECT 1\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n WHERE n.nspname = '${escapeLiteral(schemaName)}'\n AND t.typname = '${escapeLiteral(nativeType)}'\n)`;\n}\n\nexport function createEnumType(\n schemaName: string,\n typeName: string,\n values: readonly string[],\n nativeType: string = typeName,\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n const literalValues = values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n return {\n id: `type.${typeName}`,\n label: `Create enum type \"${typeName}\"`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(\n `ensure type \"${nativeType}\" does not exist`,\n enumTypeExistsCheck(schemaName, nativeType, false),\n ),\n ],\n execute: [\n step(\n `create enum type \"${typeName}\"`,\n `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`,\n ),\n ],\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\n/**\n * `typeName` is the contract-facing type name (used for id/label).\n * `nativeType` is the Postgres type name to mutate (may differ for external types).\n */\nexport function addEnumValues(\n schemaName: string,\n typeName: string,\n nativeType: string,\n values: readonly string[],\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n return {\n id: `type.${typeName}.addValues`,\n label: `Add values to enum type \"${typeName}\": ${values.join(', ')}`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(`ensure type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n execute: values.map((value) =>\n step(\n `add value '${value}' to enum \"${nativeType}\"`,\n `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`,\n ),\n ),\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\nexport function dropEnumType(schemaName: string, typeName: string): Op {\n const qualified = qualifyName(schemaName, typeName);\n return {\n id: `type.${typeName}.drop`,\n label: `Drop enum type \"${typeName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [step(`ensure type \"${typeName}\" exists`, enumTypeExistsCheck(schemaName, typeName))],\n execute: [step(`drop enum type \"${typeName}\"`, `DROP TYPE ${qualified}`)],\n postcheck: [\n step(`verify type \"${typeName}\" removed`, enumTypeExistsCheck(schemaName, typeName, false)),\n ],\n };\n}\n\nexport function renameType(schemaName: string, fromName: string, toName: string): Op {\n const qualifiedFrom = qualifyName(schemaName, fromName);\n return {\n id: `type.${fromName}.rename`,\n label: `Rename type \"${fromName}\" to \"${toName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', fromName, schemaName),\n precheck: [\n step(`ensure type \"${fromName}\" exists`, enumTypeExistsCheck(schemaName, fromName)),\n step(\n `ensure type \"${toName}\" does not already exist`,\n enumTypeExistsCheck(schemaName, toName, false),\n ),\n ],\n execute: [\n step(\n `rename type \"${fromName}\" to \"${toName}\"`,\n `ALTER TYPE ${qualifiedFrom} RENAME TO ${quoteIdentifier(toName)}`,\n ),\n ],\n postcheck: [step(`verify type \"${toName}\" exists`, enumTypeExistsCheck(schemaName, toName))],\n };\n}\n","import { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\nexport interface CreateIndexExtras {\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\nfunction renderIndexOptionValue(key: string, value: unknown): string {\n if (typeof value === 'string') return `'${escapeLiteral(value)}'`;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n throw new Error(\n `Index option \"${key}\" must be a string, finite number, or boolean; got ${typeof value}`,\n );\n}\n\nfunction renderIndexOptions(options: Record<string, unknown>): string {\n return Object.entries(options)\n .map(([key, value]) => `${quoteIdentifier(key)} = ${renderIndexOptionValue(key, value)}`)\n .join(', ');\n}\n\nexport function createIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: CreateIndexExtras,\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const using = extras?.type ? ` USING ${quoteIdentifier(extras.type)}` : '';\n const options = extras?.options;\n const withClause =\n options && Object.keys(options).length > 0 ? ` WITH (${renderIndexOptions(options)})` : '';\n return {\n id: `index.${tableName}.${indexName}`,\n label: `Create index \"${indexName}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [\n step(\n `ensure index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n execute: [\n step(\n `create index \"${indexName}\"`,\n `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropIndex(schemaName: string, tableName: string, indexName: string): Op {\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index \"${indexName}\"`,\n operationClass: 'destructive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [\n step(\n `ensure index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n execute: [\n step(`drop index \"${indexName}\"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n };\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, renderColumnDefinition, step, targetDetails } from './shared';\n\nexport function createTable(\n schemaName: string,\n tableName: string,\n columns: ReadonlyArray<ColumnSpec>,\n primaryKey?: { readonly columns: readonly string[] },\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnDefs = columns.map(renderColumnDefinition);\n const constraintDefs: string[] = [];\n if (primaryKey) {\n constraintDefs.push(`PRIMARY KEY (${primaryKey.columns.map(quoteIdentifier).join(', ')})`);\n }\n const allDefs = [...columnDefs, ...constraintDefs];\n const createSql = `CREATE TABLE ${qualified} (\\n ${allDefs.join(',\\n ')}\\n)`;\n\n return {\n id: `table.${tableName}`,\n label: `Create table \"${tableName}\"`,\n summary: `Creates table \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [\n step(\n `ensure table \"${tableName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`,\n ),\n ],\n execute: [step(`create table \"${tableName}\"`, createSql)],\n postcheck: [\n step(\n `verify table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropTable(schemaName: string, tableName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [\n step(\n `ensure table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${qualified}`)],\n postcheck: [\n step(\n `verify table \"${tableName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`,\n ),\n ],\n };\n}\n"],"mappings":";;;;AA4CA,SAAgB,KAAK,aAAqB,KAAa;CACrD,OAAO;EAAE;EAAa;CAAI;AAC5B;AAEA,SAAgB,cACd,YACA,MACA,QACA,OAC0E;CAC1E,OAAO;EACL,IAAI;EACJ,SAAS;GAAE;GAAQ;GAAY;GAAM,GAAG,UAAU,SAAS,KAAK;EAAE;CACpE;AACF;AAEA,SAAgB,uBAAuB,QAA4B;CAOjE,OANc;EACZ,gBAA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AQ,IAAI,sBAAsB;CACrD,MAAM,iBAA2B,CAAC;CAClC,IAAI,YACF,eAAe,KAAK,gBAAgB,WAAW,QAAQ,IAAI,eAAe,EAAE,KAAK,IAAI,EAAE,EAAE;CAG3F,MAAM,YAAY,gBAAgB,UAAU,QAAQ,CADnC,GAAG,YAAY,GAAG,cACuB,EAAE,KAAK,OAAO,EAAE;CAE1E,OAAO;EACL,IAAI,SAAS;EACb,OAAO,iBAAiB,UAAU;EAClC,SAAS,kBAAkB,UAAU;EACrC,gBAAgB;EAChB,QAAQ,cAAc,SAAS,WAAW,UAAU;EACpD,UAAU,CACR,KACE,iBAAiB,UAAU,mBAC3B,sBAAsB,kBAAkB,YAAY,SAAS,EAAE,UACjE,CACF;EACA,SAAS,CAAC,KAAK,iBAAiB,UAAU,IAAI,SAAS,CAAC;EACxD,WAAW,CACT,KACE,iBAAiB,UAAU,WAC3B,sBAAsB,kBAAkB,YAAY,SAAS,EAAE,cACjE,CACF;CACF;AACF;AAEA,SAAgB,UAAU,YAAoB,WAAuB;CACnE,MAAM,YAAY,iBAAiB,YAAY,SAAS;CACxD,OAAO;EACL,IAAI,aAAa;EACjB,OAAO,eAAe,UAAU;EAChC,gBAAgB;EAChB,QAAQ,cAAc,SAAS,WAAW,UAAU;EACpD,UAAU,CACR,KACE,iBAAiB,UAAU,WAC3B,sBAAsB,kBAAkB,YAAY,SAAS,EAAE,cACjE,CACF;EACA,SAAS,CAAC,KAAK,eAAe,UAAU,IAAI,cAAc,WAAW,CAAC;EACtE,WAAW,CACT,KACE,iBAAiB,UAAU,mBAC3B,sBAAsB,kBAAkB,YAAY,SAAS,EAAE,UACjE,CACF;CACF;AACF"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-
|
|
1
|
+
import { n as PostgresEnumTypeInput, t as PostgresEnumType } from "./postgres-enum-type-CSzsvXrO.mjs";
|
|
2
2
|
import { t as PostgresColumnDefault } from "./types-O40IcFV9.mjs";
|
|
3
3
|
import { NamespaceBase } from "@prisma-next/framework-components/ir";
|
|
4
4
|
import { SqlNamespaceTablesInput, SqlStorage, StorageTable, StorageTableInput } from "@prisma-next/sql-contract/types";
|
package/dist/types.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { t as PostgresEnumType } from "./postgres-enum-type-
|
|
2
|
-
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-
|
|
1
|
+
import { t as PostgresEnumType } from "./postgres-enum-type-BMgyxNyy.mjs";
|
|
2
|
+
import { i as postgresCreateNamespace, n as PostgresUnboundSchema, t as PostgresSchema } from "./postgres-schema-BxAuNFX0.mjs";
|
|
3
3
|
export { PostgresEnumType, PostgresSchema, PostgresUnboundSchema, postgresCreateNamespace };
|
package/package.json
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.12.0-dev.
|
|
3
|
+
"version": "0.12.0-dev.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Postgres target pack for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/cli": "0.12.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.12.0-dev.
|
|
11
|
-
"@prisma-next/errors": "0.12.0-dev.
|
|
12
|
-
"@prisma-next/family-sql": "0.12.0-dev.
|
|
13
|
-
"@prisma-next/framework-components": "0.12.0-dev.
|
|
14
|
-
"@prisma-next/migration-tools": "0.12.0-dev.
|
|
15
|
-
"@prisma-next/ts-render": "0.12.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract": "0.12.0-dev.
|
|
17
|
-
"@prisma-next/sql-errors": "0.12.0-dev.
|
|
18
|
-
"@prisma-next/sql-operations": "0.12.0-dev.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.12.0-dev.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.12.0-dev.
|
|
21
|
-
"@prisma-next/utils": "0.12.0-dev.
|
|
9
|
+
"@prisma-next/cli": "0.12.0-dev.4",
|
|
10
|
+
"@prisma-next/contract": "0.12.0-dev.4",
|
|
11
|
+
"@prisma-next/errors": "0.12.0-dev.4",
|
|
12
|
+
"@prisma-next/family-sql": "0.12.0-dev.4",
|
|
13
|
+
"@prisma-next/framework-components": "0.12.0-dev.4",
|
|
14
|
+
"@prisma-next/migration-tools": "0.12.0-dev.4",
|
|
15
|
+
"@prisma-next/ts-render": "0.12.0-dev.4",
|
|
16
|
+
"@prisma-next/sql-contract": "0.12.0-dev.4",
|
|
17
|
+
"@prisma-next/sql-errors": "0.12.0-dev.4",
|
|
18
|
+
"@prisma-next/sql-operations": "0.12.0-dev.4",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.12.0-dev.4",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.12.0-dev.4",
|
|
21
|
+
"@prisma-next/utils": "0.12.0-dev.4",
|
|
22
22
|
"@standard-schema/spec": "^1.1.0",
|
|
23
23
|
"arktype": "^2.2.0",
|
|
24
24
|
"pathe": "^2.0.3"
|
|
25
25
|
},
|
|
26
26
|
"devDependencies": {
|
|
27
|
-
"@prisma-next/test-utils": "0.12.0-dev.
|
|
28
|
-
"@prisma-next/tsconfig": "0.12.0-dev.
|
|
29
|
-
"@prisma-next/tsdown": "0.12.0-dev.
|
|
27
|
+
"@prisma-next/test-utils": "0.12.0-dev.4",
|
|
28
|
+
"@prisma-next/tsconfig": "0.12.0-dev.4",
|
|
29
|
+
"@prisma-next/tsdown": "0.12.0-dev.4",
|
|
30
30
|
"tsdown": "0.22.0",
|
|
31
31
|
"typescript": "5.9.3",
|
|
32
32
|
"vitest": "4.1.6"
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ControlPolicy } from '@prisma-next/contract/types';
|
|
1
2
|
import { freezeNode } from '@prisma-next/framework-components/ir';
|
|
2
3
|
import { SqlNode } from '@prisma-next/sql-contract/types';
|
|
3
4
|
|
|
@@ -18,6 +19,7 @@ export interface PostgresEnumTypeInput<
|
|
|
18
19
|
*/
|
|
19
20
|
readonly nativeType?: string;
|
|
20
21
|
readonly values: TValues;
|
|
22
|
+
readonly control?: ControlPolicy;
|
|
21
23
|
}
|
|
22
24
|
|
|
23
25
|
/** Codec id used by Postgres enum-typed columns (text wire format). */
|
|
@@ -64,6 +66,7 @@ export class PostgresEnumType<
|
|
|
64
66
|
* dispatching through the prototype-only `codecBinding` accessor.
|
|
65
67
|
*/
|
|
66
68
|
readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;
|
|
69
|
+
declare readonly control?: ControlPolicy;
|
|
67
70
|
|
|
68
71
|
constructor(input: PostgresEnumTypeInput<TName, TValues>) {
|
|
69
72
|
super();
|
|
@@ -73,6 +76,7 @@ export class PostgresEnumType<
|
|
|
73
76
|
// `TValues` literal tuple. Cast preserves the caller-supplied
|
|
74
77
|
// tuple shape so inferred contract types retain literal narrowing.
|
|
75
78
|
this.values = Object.freeze([...input.values] as unknown as TValues);
|
|
79
|
+
if (input.control !== undefined) this.control = input.control;
|
|
76
80
|
freezeNode(this);
|
|
77
81
|
}
|
|
78
82
|
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-5MBoKsIj.d.mts","names":[],"sources":["../src/core/postgres-enum-type.ts"],"mappings":";;;UAGiB,qBAAA;;AAAjB;;;;WASW,IAAA,EAAM,KAAA;EAPf;;;;;EAAA,SAaS,UAAA;EAAA,SACA,MAAA,EAAQ,OAAO;AAAA;AACzB;AAAA,cAGK,gBAAA;;;AAAgB;AAyBtB;;;;;;;;;;;;;;;;;;;;cAAa,gBAAA,+FAGH,OAAA;EAAA,SACU,IAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;;;;;;;;;;WAUR,OAAA,SAAgB,gBAAA;cAEb,KAAA,EAAO,qBAAA,CAAsB,KAAA,EAAO,OAAA;EAAA,IAW5C,YAAA,CAAA;IAAA,SACO,OAAA,SAAgB,gBAAA;IAAA,SAChB,UAAA;MAAA,SAAuB,MAAA,EAAQ,OAAA;IAAA;EAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-enum-type-DS-KLVRH.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAuBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAE5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
|