@prisma-next/target-postgres 0.14.0-dev.4 → 0.14.0-dev.41
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/authoring-BX1WHIdN.mjs +220 -0
- package/dist/authoring-BX1WHIdN.mjs.map +1 -0
- package/dist/canonicalize-Bn3BM1Cn.mjs +46 -0
- package/dist/canonicalize-Bn3BM1Cn.mjs.map +1 -0
- package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
- package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
- package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-CueCoGD0.d.mts} +2 -2
- package/dist/{codec-types-DHCkwPKE.d.mts.map → codec-types-CueCoGD0.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-Ca8upop6.d.mts} +12 -1
- package/dist/codecs-Ca8upop6.d.mts.map +1 -0
- package/dist/codecs.d.mts +1 -1
- package/dist/codecs.mjs +34 -1
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +8 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +3 -3
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +639 -21
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-qKy1U5V9.d.mts} +2 -2
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-qKy1U5V9.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-BmLIe1z_.mjs} +62 -5
- package/dist/ddl-BmLIe1z_.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/{default-normalizer-DyyCHQWs.mjs → default-normalizer-Dug8Fez9.mjs} +119 -2
- package/dist/default-normalizer-Dug8Fez9.mjs.map +1 -0
- package/dist/default-normalizer.d.mts +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
- package/dist/descriptor-meta-tjatyhtZ.mjs +18 -0
- package/dist/descriptor-meta-tjatyhtZ.mjs.map +1 -0
- package/dist/{issue-planner-DL6g3CmE.mjs → issue-planner-DbFvaAgu.mjs} +35 -10
- package/dist/issue-planner-DbFvaAgu.mjs.map +1 -0
- package/dist/issue-planner.d.mts +3 -3
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +5 -5
- package/dist/migration.mjs +4 -4
- package/dist/nodes-CSkPX3rI.d.mts +120 -0
- package/dist/nodes-CSkPX3rI.d.mts.map +1 -0
- package/dist/{nodes-Bbhs2rwj.mjs → nodes-Dh__NS58.mjs} +56 -2
- package/dist/nodes-Dh__NS58.mjs.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CJWUxyUW.d.mts} +44 -13
- package/dist/op-factory-call-CJWUxyUW.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-t65c4jyY.mjs} +201 -28
- package/dist/op-factory-call-t65c4jyY.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +74 -2
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-CG2pLHk-.mjs +640 -0
- package/dist/planner-CG2pLHk-.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
- package/dist/planner-ddl-builders-B8Nn6nHN.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +2 -4
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-BolD0Mvc.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-BolD0Mvc.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-Cz9--XOT.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-Cz9--XOT.d.mts.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-DE9c4519.mjs} +2 -2
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-DE9c4519.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +82 -4
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-BegduLr6.mjs} +50 -23
- package/dist/postgres-contract-view-BegduLr6.mjs.map +1 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/postgres-database-schema-node-os8ogEap.d.mts +183 -0
- package/dist/postgres-database-schema-node-os8ogEap.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-BfMmK6tv.mjs} +21 -2
- package/dist/postgres-migration-BfMmK6tv.mjs.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-D7kNVWVG.d.mts} +19 -6
- package/dist/postgres-migration-D7kNVWVG.d.mts.map +1 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-BLIHBEfX.mjs} +108 -5
- package/dist/postgres-schema-BLIHBEfX.mjs.map +1 -0
- package/dist/postgres-schema-BywoeKlt.d.mts +189 -0
- package/dist/postgres-schema-BywoeKlt.d.mts.map +1 -0
- package/dist/postgres-table-schema-node-1nNc8XDT.mjs +248 -0
- package/dist/postgres-table-schema-node-1nNc8XDT.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
- package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/resolve-ddl-schema-CL1RR1mx.mjs +20 -0
- package/dist/resolve-ddl-schema-CL1RR1mx.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +2 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +7 -6
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-ir-annotations.d.mts +14 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/types.d.mts +4 -140
- package/dist/types.mjs +3 -2
- package/package.json +22 -17
- package/src/contract-free/checks.ts +73 -0
- package/src/contract-free/ddl.ts +45 -1
- package/src/core/authoring.ts +115 -1
- package/src/core/codecs.ts +35 -1
- package/src/core/ddl/nodes.ts +94 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +4 -0
- package/src/core/entity-kinds.ts +16 -0
- package/src/core/migrations/bound-schema.ts +10 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +125 -0
- package/src/core/migrations/control-policy.ts +3 -0
- package/src/core/migrations/diff-database-schema.ts +191 -0
- package/src/core/migrations/issue-planner.ts +44 -3
- package/src/core/migrations/op-factory-call.ts +109 -21
- package/src/core/migrations/operations/columns.ts +24 -12
- package/src/core/migrations/operations/data-transform.ts +6 -0
- package/src/core/migrations/operations/rls.ts +106 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +15 -56
- package/src/core/migrations/planner-recipes.ts +31 -13
- package/src/core/migrations/planner-strategies.ts +3 -11
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +165 -33
- package/src/core/migrations/postgres-migration.ts +34 -4
- package/src/core/migrations/render-typescript.ts +42 -15
- package/src/core/migrations/resolve-ddl-schema.ts +24 -0
- package/src/core/migrations/runner.ts +13 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +24 -19
- package/src/core/postgres-contract-serializer.ts +50 -33
- package/src/core/postgres-contract-view.ts +48 -0
- package/src/core/postgres-rls-policy.ts +64 -0
- package/src/core/postgres-role.ts +37 -0
- package/src/core/postgres-schema.ts +37 -13
- package/src/core/postgres-validators.ts +20 -0
- package/src/core/psl-infer/infer-psl-contract.ts +834 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +157 -0
- package/src/core/rls/canonicalize.ts +48 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +63 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +61 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +93 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +66 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +107 -0
- package/src/core/schema-ir/schema-node-kinds.ts +28 -0
- package/src/exports/contract-free.ts +7 -1
- package/src/exports/control.ts +39 -12
- package/src/exports/ddl.ts +4 -0
- package/src/exports/migration.ts +1 -0
- package/src/exports/planner-ddl-builders.ts +0 -2
- package/src/exports/planner.ts +2 -0
- package/src/exports/rls-canonicalize.ts +6 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/types.ts +28 -0
- package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- package/dist/nodes-pLeLgdis.d.mts +0 -67
- package/dist/nodes-pLeLgdis.d.mts.map +0 -1
- package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
- package/dist/planner-Bs_baQax.mjs +0 -324
- package/dist/planner-Bs_baQax.mjs.map +0 -1
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
- package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
- package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
- package/dist/render-typescript-KMgosran.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
|
@@ -17,6 +17,12 @@ const FALSE_PATTERN = /^false$/i;
|
|
|
17
17
|
const NUMERIC_PATTERN = /^-?\d+(\.\d+)?$/;
|
|
18
18
|
const STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'(?:::(?:"[^"]+"|[\w\s]+)(?:\(\d+\))?)?$/;
|
|
19
19
|
/**
|
|
20
|
+
* Matches a Postgres array literal default of the form `'{...}'::elemtype[]`.
|
|
21
|
+
* The literal body is captured in group 1; the cast (including `[]`) is optional.
|
|
22
|
+
* Examples: `'{}'::text[]`, `'{1,2}'::integer[]`, `'{}'`
|
|
23
|
+
*/
|
|
24
|
+
const ARRAY_LITERAL_PATTERN = /^'(\{.*\})'(?:::.+\[\])?$/;
|
|
25
|
+
/**
|
|
20
26
|
* Returns the canonical expression for a timestamp default function, or undefined
|
|
21
27
|
* if the expression is not a recognized timestamp default.
|
|
22
28
|
*
|
|
@@ -40,6 +46,106 @@ function canonicalizeTimestampDefault(expr) {
|
|
|
40
46
|
if (NOW_LITERAL_PATTERN.test(inner)) return "now()";
|
|
41
47
|
}
|
|
42
48
|
/**
|
|
49
|
+
* Splits a Postgres array literal body (without the enclosing braces) into its
|
|
50
|
+
* element tokens, honouring quoting. A comma only separates elements when it is
|
|
51
|
+
* outside double quotes; inside a quoted element a doubled quote (`""`) or a
|
|
52
|
+
* backslash-escaped quote (`\"`) is a literal quote, and a backslash escapes the
|
|
53
|
+
* next character. Returns undefined if the body is malformed (e.g. an unbalanced
|
|
54
|
+
* quote).
|
|
55
|
+
*/
|
|
56
|
+
function splitArrayElements(inner) {
|
|
57
|
+
const tokens = [];
|
|
58
|
+
let current = "";
|
|
59
|
+
let inQuotes = false;
|
|
60
|
+
let quoted = false;
|
|
61
|
+
for (let i = 0; i < inner.length; i++) {
|
|
62
|
+
const char = inner[i];
|
|
63
|
+
if (inQuotes) {
|
|
64
|
+
if (char === "\\") {
|
|
65
|
+
const next = inner[i + 1];
|
|
66
|
+
if (next === void 0) return void 0;
|
|
67
|
+
current += next;
|
|
68
|
+
i++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
if (char === "\"") {
|
|
72
|
+
if (inner[i + 1] === "\"") {
|
|
73
|
+
current += "\"";
|
|
74
|
+
i++;
|
|
75
|
+
continue;
|
|
76
|
+
}
|
|
77
|
+
inQuotes = false;
|
|
78
|
+
continue;
|
|
79
|
+
}
|
|
80
|
+
current += char;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
if (char === "\"") {
|
|
84
|
+
inQuotes = true;
|
|
85
|
+
quoted = true;
|
|
86
|
+
continue;
|
|
87
|
+
}
|
|
88
|
+
if (char === ",") {
|
|
89
|
+
tokens.push({
|
|
90
|
+
value: current,
|
|
91
|
+
quoted
|
|
92
|
+
});
|
|
93
|
+
current = "";
|
|
94
|
+
quoted = false;
|
|
95
|
+
continue;
|
|
96
|
+
}
|
|
97
|
+
current += char;
|
|
98
|
+
}
|
|
99
|
+
if (inQuotes) return void 0;
|
|
100
|
+
tokens.push({
|
|
101
|
+
value: current,
|
|
102
|
+
quoted
|
|
103
|
+
});
|
|
104
|
+
return tokens;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parses a Postgres array literal body (`{...}`) into a JS array of primitives.
|
|
108
|
+
* Returns undefined if the body cannot be reliably parsed.
|
|
109
|
+
*
|
|
110
|
+
* Handles:
|
|
111
|
+
* - `{}` → `[]`
|
|
112
|
+
* - `{elem1,elem2,...}` → `[elem1, elem2, ...]` with numeric and string element coercion
|
|
113
|
+
* - quoted elements that contain commas, doubled/escaped quotes, and the literal
|
|
114
|
+
* strings `NULL`/`true`/`false` (a quoted token is always a string)
|
|
115
|
+
*/
|
|
116
|
+
function parseArrayLiteralBody(body) {
|
|
117
|
+
const inner = body.slice(1, -1).trim();
|
|
118
|
+
if (inner === "") return [];
|
|
119
|
+
const tokens = splitArrayElements(inner);
|
|
120
|
+
if (tokens === void 0) return void 0;
|
|
121
|
+
const result = [];
|
|
122
|
+
for (const token of tokens) {
|
|
123
|
+
if (token.quoted) {
|
|
124
|
+
result.push(token.value);
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
const el = token.value.trim();
|
|
128
|
+
if (el.toUpperCase() === "NULL") {
|
|
129
|
+
result.push(null);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (el === "true") {
|
|
133
|
+
result.push(true);
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (el === "false") {
|
|
137
|
+
result.push(false);
|
|
138
|
+
continue;
|
|
139
|
+
}
|
|
140
|
+
if (NUMERIC_PATTERN.test(el)) {
|
|
141
|
+
result.push(Number(el));
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
144
|
+
return;
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
43
149
|
* Parses a raw Postgres column default expression into a normalized ColumnDefault.
|
|
44
150
|
* This enables semantic comparison between contract defaults and introspected schema defaults.
|
|
45
151
|
*
|
|
@@ -47,17 +153,28 @@ function canonicalizeTimestampDefault(expr) {
|
|
|
47
153
|
* keeping the introspection layer focused on faithful data capture.
|
|
48
154
|
*
|
|
49
155
|
* @param rawDefault - Raw default expression from information_schema.columns.column_default
|
|
50
|
-
* @param nativeType - Native column type, used for type-aware parsing (bigint
|
|
156
|
+
* @param nativeType - Native column type, used for type-aware parsing (array, bigint, JSON)
|
|
51
157
|
* @returns Normalized ColumnDefault or undefined if the expression cannot be parsed
|
|
52
158
|
*/
|
|
53
159
|
function parsePostgresDefault(rawDefault, nativeType) {
|
|
54
160
|
const trimmed = rawDefault.trim();
|
|
55
161
|
const normalizedType = nativeType?.toLowerCase();
|
|
56
162
|
const isBigInt = normalizedType === "bigint" || normalizedType === "int8";
|
|
163
|
+
const isArrayType = normalizedType?.endsWith("[]") ?? false;
|
|
57
164
|
if (NEXTVAL_PATTERN.test(trimmed)) return {
|
|
58
165
|
kind: "function",
|
|
59
166
|
expression: "autoincrement()"
|
|
60
167
|
};
|
|
168
|
+
if (isArrayType) {
|
|
169
|
+
const arrayMatch = trimmed.match(ARRAY_LITERAL_PATTERN);
|
|
170
|
+
if (arrayMatch?.[1] !== void 0) {
|
|
171
|
+
const parsed = parseArrayLiteralBody(arrayMatch[1]);
|
|
172
|
+
if (parsed !== void 0) return {
|
|
173
|
+
kind: "literal",
|
|
174
|
+
value: parsed
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
}
|
|
61
178
|
const canonicalTimestamp = canonicalizeTimestampDefault(trimmed);
|
|
62
179
|
if (canonicalTimestamp) return {
|
|
63
180
|
kind: "function",
|
|
@@ -128,4 +245,4 @@ function parsePostgresDefault(rawDefault, nativeType) {
|
|
|
128
245
|
//#endregion
|
|
129
246
|
export { parsePostgresDefault as t };
|
|
130
247
|
|
|
131
|
-
//# sourceMappingURL=default-normalizer-
|
|
248
|
+
//# sourceMappingURL=default-normalizer-Dug8Fez9.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-normalizer-Dug8Fez9.mjs","names":[],"sources":["../src/core/default-normalizer.ts"],"sourcesContent":["import type { ColumnDefault, JsonValue } from '@prisma-next/contract/types';\n\n/**\n * Pre-compiled regex patterns for performance.\n * These are compiled once at module load time rather than on each function call.\n */\nconst NEXTVAL_PATTERN = /^nextval\\s*\\(/i;\nconst NOW_FUNCTION_PATTERN = /^(now\\s*\\(\\s*\\)|CURRENT_TIMESTAMP)$/i;\nconst CLOCK_TIMESTAMP_PATTERN = /^clock_timestamp\\s*\\(\\s*\\)$/i;\nconst TIMESTAMP_CAST_SUFFIX = /::timestamp(?:tz|\\s+(?:with|without)\\s+time\\s+zone)?$/i;\nconst TEXT_CAST_SUFFIX = /::text$/i;\nconst NOW_LITERAL_PATTERN = /^'now'$/i;\nconst UUID_PATTERN = /^gen_random_uuid\\s*\\(\\s*\\)$/i;\nconst UUID_OSSP_PATTERN = /^uuid_generate_v4\\s*\\(\\s*\\)$/i;\nconst NULL_PATTERN = /^NULL(?:::.+)?$/i;\nconst TRUE_PATTERN = /^true$/i;\nconst FALSE_PATTERN = /^false$/i;\nconst NUMERIC_PATTERN = /^-?\\d+(\\.\\d+)?$/;\nconst STRING_LITERAL_PATTERN = /^'((?:[^']|'')*)'(?:::(?:\"[^\"]+\"|[\\w\\s]+)(?:\\(\\d+\\))?)?$/;\n\n/**\n * Matches a Postgres array literal default of the form `'{...}'::elemtype[]`.\n * The literal body is captured in group 1; the cast (including `[]`) is optional.\n * Examples: `'{}'::text[]`, `'{1,2}'::integer[]`, `'{}'`\n */\nconst ARRAY_LITERAL_PATTERN = /^'(\\{.*\\})'(?:::.+\\[\\])?$/;\n\n/**\n * Returns the canonical expression for a timestamp default function, or undefined\n * if the expression is not a recognized timestamp default.\n *\n * Keeps now()/CURRENT_TIMESTAMP and clock_timestamp() distinct:\n * - now(), CURRENT_TIMESTAMP, ('now'::text)::timestamp... → 'now()'\n * - clock_timestamp(), clock_timestamp()::timestamptz → 'clock_timestamp()'\n *\n * These are semantically different in Postgres: now() returns the transaction\n * start time (constant within a transaction), while clock_timestamp() returns\n * the actual wall-clock time (can differ across rows in a single INSERT).\n */\nfunction canonicalizeTimestampDefault(expr: string): string | undefined {\n if (NOW_FUNCTION_PATTERN.test(expr)) return 'now()';\n if (CLOCK_TIMESTAMP_PATTERN.test(expr)) return 'clock_timestamp()';\n\n if (!TIMESTAMP_CAST_SUFFIX.test(expr)) return undefined;\n\n let inner = expr.replace(TIMESTAMP_CAST_SUFFIX, '').trim();\n\n if (inner.startsWith('(') && inner.endsWith(')')) {\n inner = inner.slice(1, -1).trim();\n }\n\n if (NOW_FUNCTION_PATTERN.test(inner)) return 'now()';\n if (CLOCK_TIMESTAMP_PATTERN.test(inner)) return 'clock_timestamp()';\n\n inner = inner.replace(TEXT_CAST_SUFFIX, '').trim();\n if (NOW_LITERAL_PATTERN.test(inner)) return 'now()';\n\n return undefined;\n}\n\ntype ArrayElementToken = { readonly value: string; readonly quoted: boolean };\n\n/**\n * Splits a Postgres array literal body (without the enclosing braces) into its\n * element tokens, honouring quoting. A comma only separates elements when it is\n * outside double quotes; inside a quoted element a doubled quote (`\"\"`) or a\n * backslash-escaped quote (`\\\"`) is a literal quote, and a backslash escapes the\n * next character. Returns undefined if the body is malformed (e.g. an unbalanced\n * quote).\n */\nfunction splitArrayElements(inner: string): readonly ArrayElementToken[] | undefined {\n const tokens: ArrayElementToken[] = [];\n let current = '';\n let inQuotes = false;\n let quoted = false;\n\n for (let i = 0; i < inner.length; i++) {\n const char = inner[i];\n if (inQuotes) {\n if (char === '\\\\') {\n const next = inner[i + 1];\n if (next === undefined) return undefined;\n current += next;\n i++;\n continue;\n }\n if (char === '\"') {\n if (inner[i + 1] === '\"') {\n current += '\"';\n i++;\n continue;\n }\n inQuotes = false;\n continue;\n }\n current += char;\n continue;\n }\n if (char === '\"') {\n inQuotes = true;\n quoted = true;\n continue;\n }\n if (char === ',') {\n tokens.push({ value: current, quoted });\n current = '';\n quoted = false;\n continue;\n }\n current += char;\n }\n\n if (inQuotes) return undefined;\n tokens.push({ value: current, quoted });\n return tokens;\n}\n\n/**\n * Parses a Postgres array literal body (`{...}`) into a JS array of primitives.\n * Returns undefined if the body cannot be reliably parsed.\n *\n * Handles:\n * - `{}` → `[]`\n * - `{elem1,elem2,...}` → `[elem1, elem2, ...]` with numeric and string element coercion\n * - quoted elements that contain commas, doubled/escaped quotes, and the literal\n * strings `NULL`/`true`/`false` (a quoted token is always a string)\n */\nfunction parseArrayLiteralBody(body: string): readonly JsonValue[] | undefined {\n const inner = body.slice(1, -1).trim();\n if (inner === '') return [];\n const tokens = splitArrayElements(inner);\n if (tokens === undefined) return undefined;\n const result: JsonValue[] = [];\n for (const token of tokens) {\n if (token.quoted) {\n // A quoted token is always a string — `\"NULL\"`, `\"true\"`, `\"1\"` are the\n // literal text, never the keyword/number.\n result.push(token.value);\n continue;\n }\n const el = token.value.trim();\n if (el.toUpperCase() === 'NULL') {\n result.push(null);\n continue;\n }\n if (el === 'true') {\n result.push(true);\n continue;\n }\n if (el === 'false') {\n result.push(false);\n continue;\n }\n if (NUMERIC_PATTERN.test(el)) {\n result.push(Number(el));\n continue;\n }\n return undefined;\n }\n return result;\n}\n\n/**\n * Parses a raw Postgres column default expression into a normalized ColumnDefault.\n * This enables semantic comparison between contract defaults and introspected schema defaults.\n *\n * Used by the migration diff layer to normalize raw database defaults during comparison,\n * keeping the introspection layer focused on faithful data capture.\n *\n * @param rawDefault - Raw default expression from information_schema.columns.column_default\n * @param nativeType - Native column type, used for type-aware parsing (array, bigint, JSON)\n * @returns Normalized ColumnDefault or undefined if the expression cannot be parsed\n */\nexport function parsePostgresDefault(\n rawDefault: string,\n nativeType?: string,\n): ColumnDefault | undefined {\n const trimmed = rawDefault.trim();\n const normalizedType = nativeType?.toLowerCase();\n const isBigInt = normalizedType === 'bigint' || normalizedType === 'int8';\n const isArrayType = normalizedType?.endsWith('[]') ?? false;\n\n if (NEXTVAL_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'autoincrement()' };\n }\n\n if (isArrayType) {\n const arrayMatch = trimmed.match(ARRAY_LITERAL_PATTERN);\n if (arrayMatch?.[1] !== undefined) {\n const parsed = parseArrayLiteralBody(arrayMatch[1]);\n if (parsed !== undefined) {\n return { kind: 'literal', value: parsed };\n }\n }\n }\n\n const canonicalTimestamp = canonicalizeTimestampDefault(trimmed);\n if (canonicalTimestamp) {\n return { kind: 'function', expression: canonicalTimestamp };\n }\n\n if (UUID_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'gen_random_uuid()' };\n }\n\n if (UUID_OSSP_PATTERN.test(trimmed)) {\n return { kind: 'function', expression: 'gen_random_uuid()' };\n }\n\n if (NULL_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: null };\n }\n\n if (TRUE_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: true };\n }\n if (FALSE_PATTERN.test(trimmed)) {\n return { kind: 'literal', value: false };\n }\n\n if (NUMERIC_PATTERN.test(trimmed)) {\n const num = Number(trimmed);\n if (!Number.isFinite(num)) return undefined;\n if (isBigInt && !Number.isSafeInteger(num)) {\n return { kind: 'literal', value: trimmed };\n }\n return { kind: 'literal', value: num };\n }\n\n const stringMatch = trimmed.match(STRING_LITERAL_PATTERN);\n if (stringMatch?.[1] !== undefined) {\n const unescaped = stringMatch[1].replace(/''/g, \"'\");\n if (normalizedType === 'json' || normalizedType === 'jsonb') {\n try {\n return { kind: 'literal', value: JSON.parse(unescaped) };\n } catch {\n // Keep legacy behavior for malformed/non-JSON string content.\n }\n }\n if (isBigInt && NUMERIC_PATTERN.test(unescaped)) {\n const num = Number(unescaped);\n if (Number.isSafeInteger(num)) {\n return { kind: 'literal', value: num };\n }\n return { kind: 'literal', value: unescaped };\n }\n return { kind: 'literal', value: unescaped };\n }\n\n return { kind: 'function', expression: trimmed };\n}\n"],"mappings":";;;;;AAMA,MAAM,kBAAkB;AACxB,MAAM,uBAAuB;AAC7B,MAAM,0BAA0B;AAChC,MAAM,wBAAwB;AAC9B,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,eAAe;AACrB,MAAM,oBAAoB;AAC1B,MAAM,eAAe;AACrB,MAAM,eAAe;AACrB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;AACxB,MAAM,yBAAyB;;;;;;AAO/B,MAAM,wBAAwB;;;;;;;;;;;;;AAc9B,SAAS,6BAA6B,MAAkC;CACtE,IAAI,qBAAqB,KAAK,IAAI,GAAG,OAAO;CAC5C,IAAI,wBAAwB,KAAK,IAAI,GAAG,OAAO;CAE/C,IAAI,CAAC,sBAAsB,KAAK,IAAI,GAAG,OAAO,KAAA;CAE9C,IAAI,QAAQ,KAAK,QAAQ,uBAAuB,EAAE,CAAC,CAAC,KAAK;CAEzD,IAAI,MAAM,WAAW,GAAG,KAAK,MAAM,SAAS,GAAG,GAC7C,QAAQ,MAAM,MAAM,GAAG,EAAE,CAAC,CAAC,KAAK;CAGlC,IAAI,qBAAqB,KAAK,KAAK,GAAG,OAAO;CAC7C,IAAI,wBAAwB,KAAK,KAAK,GAAG,OAAO;CAEhD,QAAQ,MAAM,QAAQ,kBAAkB,EAAE,CAAC,CAAC,KAAK;CACjD,IAAI,oBAAoB,KAAK,KAAK,GAAG,OAAO;AAG9C;;;;;;;;;AAYA,SAAS,mBAAmB,OAAyD;CACnF,MAAM,SAA8B,CAAC;CACrC,IAAI,UAAU;CACd,IAAI,WAAW;CACf,IAAI,SAAS;CAEb,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AE,MAAM;GAAW,OAAO;EAAI;CACvC;CAEA,MAAM,cAAc,QAAQ,MAAM,sBAAsB;CACxD,IAAI,cAAc,OAAO,KAAA,GAAW;EAClC,MAAM,YAAY,YAAY,EAAE,CAAC,QAAQ,OAAO,GAAG;EACnD,IAAI,mBAAmB,UAAU,mBAAmB,SAClD,IAAI;GACF,OAAO;IAAE,MAAM;IAAW,OAAO,KAAK,MAAM,SAAS;GAAE;EACzD,QAAQ,CAER;EAEF,IAAI,YAAY,gBAAgB,KAAK,SAAS,GAAG;GAC/C,MAAM,MAAM,OAAO,SAAS;GAC5B,IAAI,OAAO,cAAc,GAAG,GAC1B,OAAO;IAAE,MAAM;IAAW,OAAO;GAAI;GAEvC,OAAO;IAAE,MAAM;IAAW,OAAO;GAAU;EAC7C;EACA,OAAO;GAAE,MAAM;GAAW,OAAO;EAAU;CAC7C;CAEA,OAAO;EAAE,MAAM;EAAY,YAAY;CAAQ;AACjD"}
|
|
@@ -9,7 +9,7 @@ import { ColumnDefault } from "@prisma-next/contract/types";
|
|
|
9
9
|
* keeping the introspection layer focused on faithful data capture.
|
|
10
10
|
*
|
|
11
11
|
* @param rawDefault - Raw default expression from information_schema.columns.column_default
|
|
12
|
-
* @param nativeType - Native column type, used for type-aware parsing (bigint
|
|
12
|
+
* @param nativeType - Native column type, used for type-aware parsing (array, bigint, JSON)
|
|
13
13
|
* @returns Normalized ColumnDefault or undefined if the expression cannot be parsed
|
|
14
14
|
*/
|
|
15
15
|
declare function parsePostgresDefault(rawDefault: string, nativeType?: string): ColumnDefault | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"default-normalizer.d.mts","names":[],"sources":["../src/core/default-normalizer.ts"],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"default-normalizer.d.mts","names":[],"sources":["../src/core/default-normalizer.ts"],"mappings":";;;;;AA6KA;;;;;;;;AAGgB;iBAHA,oBAAA,CACd,UAAA,UACA,UAAA,YACC,aAAa"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as parsePostgresDefault } from "./default-normalizer-
|
|
1
|
+
import { t as parsePostgresDefault } from "./default-normalizer-Dug8Fez9.mjs";
|
|
2
2
|
export { parsePostgresDefault };
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
const postgresTargetDescriptorMetaRuntime = {
|
|
2
|
+
kind: "target",
|
|
3
|
+
familyId: "sql",
|
|
4
|
+
targetId: "postgres",
|
|
5
|
+
id: "postgres",
|
|
6
|
+
version: "0.0.1",
|
|
7
|
+
capabilities: {}
|
|
8
|
+
};
|
|
9
|
+
//#endregion
|
|
10
|
+
export { postgresTargetDescriptorMetaRuntime as t };
|
|
11
|
+
|
|
12
|
+
//# sourceMappingURL=descriptor-meta-runtime-UwYdV8fD.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-runtime-UwYdV8fD.mjs","names":[],"sources":["../src/core/descriptor-meta-runtime.ts"],"sourcesContent":["// Runtime-safe slice of the postgres target descriptor metadata.\n//\n// This file exists separately from ./descriptor-meta on purpose: the runtime\n// plane reads only `kind/familyId/targetId/id/version/capabilities` (plus the\n// `__codecTypes` phantom). The `authoring` slot lives on the pack/control\n// descriptor only, because authoring contributions are consumed at\n// contract-construction time by `assembleAuthoringContributions` (control\n// plane) and the PSL interpreter — never at runtime.\n//\n// Keeping the runtime closure free of the `./authoring` import is what lets\n// the bundler tree-shake `@prisma-next/family-sql/control` (and its\n// transitive `verify-sql-schema` chunk) out of the runtime entry. Do not\n// add an `authoring` field here — if you need to, the pack/control meta in\n// `./descriptor-meta` is the right place. See TML-2766 for context.\nimport type { CodecTypes } from '../exports/codec-types';\n\nconst postgresTargetDescriptorMetaRuntimeBase = {\n kind: 'target',\n familyId: 'sql',\n targetId: 'postgres',\n id: 'postgres',\n version: '0.0.1',\n capabilities: {},\n} as const;\n\nexport const postgresTargetDescriptorMetaRuntime: typeof postgresTargetDescriptorMetaRuntimeBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaRuntimeBase;\n"],"mappings":"AAyBA,MAAa,sCAET;CAVF,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc,CAAC;AAKb"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { i as postgresCreateNamespace } from "./postgres-schema-BLIHBEfX.mjs";
|
|
2
|
+
import { i as postgresAuthoringTypes, n as postgresAuthoringFieldPresets, r as postgresAuthoringPslBlockDescriptors, t as postgresAuthoringEntityTypes } from "./authoring-BX1WHIdN.mjs";
|
|
3
|
+
import { t as postgresTargetDescriptorMetaRuntime } from "./descriptor-meta-runtime-UwYdV8fD.mjs";
|
|
4
|
+
const postgresTargetDescriptorMeta = {
|
|
5
|
+
...postgresTargetDescriptorMetaRuntime,
|
|
6
|
+
defaultNamespaceId: "public",
|
|
7
|
+
authoring: {
|
|
8
|
+
type: postgresAuthoringTypes,
|
|
9
|
+
field: postgresAuthoringFieldPresets,
|
|
10
|
+
entityTypes: postgresAuthoringEntityTypes,
|
|
11
|
+
pslBlockDescriptors: postgresAuthoringPslBlockDescriptors,
|
|
12
|
+
createNamespace: postgresCreateNamespace
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
//#endregion
|
|
16
|
+
export { postgresTargetDescriptorMeta as t };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=descriptor-meta-tjatyhtZ.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descriptor-meta-tjatyhtZ.mjs","names":[],"sources":["../src/core/descriptor-meta.ts"],"sourcesContent":["import type { CodecTypes } from '../exports/codec-types';\nimport {\n postgresAuthoringEntityTypes,\n postgresAuthoringFieldPresets,\n postgresAuthoringPslBlockDescriptors,\n postgresAuthoringTypes,\n} from './authoring';\nimport { postgresTargetDescriptorMetaRuntime } from './descriptor-meta-runtime';\nimport { postgresCreateNamespace } from './postgres-schema';\n\nconst postgresTargetDescriptorMetaBase = {\n ...postgresTargetDescriptorMetaRuntime,\n defaultNamespaceId: 'public',\n authoring: {\n type: postgresAuthoringTypes,\n field: postgresAuthoringFieldPresets,\n entityTypes: postgresAuthoringEntityTypes,\n pslBlockDescriptors: postgresAuthoringPslBlockDescriptors,\n createNamespace: postgresCreateNamespace,\n },\n} as const;\n\nexport const postgresTargetDescriptorMeta: typeof postgresTargetDescriptorMetaBase & {\n readonly __codecTypes?: CodecTypes;\n} = postgresTargetDescriptorMetaBase;\n"],"mappings":";;;AAsBA,MAAa,+BAET;CAbF,GAAG;CACH,oBAAoB;CACpB,WAAW;EACT,MAAM;EACN,OAAO;EACP,aAAa;EACb,qBAAqB;EACrB,iBAAiB;CACnB;AAKE"}
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
-
import { r as isPostgresSchema } from "./postgres-schema-
|
|
1
|
+
import { r as isPostgresSchema } from "./postgres-schema-BLIHBEfX.mjs";
|
|
2
|
+
import { i as quoteIdentifier } from "./sql-utils-DcfMz4MQ.mjs";
|
|
3
|
+
import { D as postgresDefaultToDdlColumnDefault, E as SetNotNullCall, O as buildTargetDetails, S as DropTableCall, T as SetDefaultCall, _ as DropConstraintCall, a as AddNotNullColumnWithTempDefaultCall, b as DropNotNullCall, c as AlterColumnTypeCall, f as CreateSchemaCall, g as DropColumnCall, h as DropCheckConstraintCall, i as AddNotNullColumnDirectCall, m as DataTransformCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as CreateTableCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropDefaultCall, w as RawSqlCall, y as DropIndexCall } from "./op-factory-call-t65c4jyY.mjs";
|
|
2
4
|
import { t as resolveColumnTypeMetadata } from "./planner-type-resolution-Bt2f_q-F.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import { n as buildColumnDefaultSql, r as buildColumnTypeSql, t as buildAddColumnSql } from "./planner-ddl-builders-B2wOwLqI.mjs";
|
|
5
|
+
import { t as buildExpectedFormatType } from "./planner-sql-checks-DE9c4519.mjs";
|
|
6
|
+
import { n as buildColumnTypeSql, t as buildColumnDefaultSql } from "./planner-ddl-builders-B8Nn6nHN.mjs";
|
|
6
7
|
import { n as resolveIdentityValue } from "./planner-identity-values-CJPha2Sz.mjs";
|
|
7
8
|
import { i as hasUniqueConstraint, n as hasForeignKey, t as buildSchemaLookupMap } from "./planner-schema-lookup-CiVaAQP-.mjs";
|
|
8
9
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
9
10
|
import { resolveValueSetValues } from "@prisma-next/family-sql/control";
|
|
10
11
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
11
|
-
import { arraysEqual } from "@prisma-next/family-sql/schema-verify";
|
|
12
12
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
13
|
+
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
13
14
|
import * as contractFree from "@prisma-next/sql-relational-core/contract-free";
|
|
14
15
|
import { col } from "@prisma-next/sql-relational-core/contract-free";
|
|
16
|
+
import { arraysEqual } from "@prisma-next/family-sql/diff";
|
|
15
17
|
import { notOk, ok } from "@prisma-next/utils/result";
|
|
16
|
-
import { StorageTable } from "@prisma-next/sql-contract/types";
|
|
17
18
|
//#region src/core/migrations/planner-strategies.ts
|
|
18
19
|
/**
|
|
19
20
|
* Look up a storage table by its explicit namespace coordinate. Returns
|
|
@@ -343,8 +344,7 @@ const notNullAddColumnCallStrategy = (issues, ctx) => {
|
|
|
343
344
|
}));
|
|
344
345
|
continue;
|
|
345
346
|
}
|
|
346
|
-
|
|
347
|
-
calls.push(new AddNotNullColumnDirectCall(schemaForTable, issue.table, issue.column, buildAddColumnSql(qualified, issue.column, column, mutableCodecHooks, void 0, mutableStorageTypes)));
|
|
347
|
+
calls.push(new AddNotNullColumnDirectCall(schemaForTable, issue.table, issue.column, buildColumnSpec(namespaceId, issue.table, issue.column, ctx)));
|
|
348
348
|
}
|
|
349
349
|
if (matched.length === 0) return { kind: "no_match" };
|
|
350
350
|
return {
|
|
@@ -397,6 +397,24 @@ const postgresPlannerStrategies = [
|
|
|
397
397
|
];
|
|
398
398
|
//#endregion
|
|
399
399
|
//#region src/core/migrations/issue-planner.ts
|
|
400
|
+
/**
|
|
401
|
+
* Deterministic name for the element-non-null CHECK constraint on a scalar-array
|
|
402
|
+
* column. Distinct `_elem_not_null` suffix avoids collision with the enum
|
|
403
|
+
* value-set `_check` constraints. Re-emitting the same schema produces the same
|
|
404
|
+
* name, so `pg_get_constraintdef`-based verify sees no drift.
|
|
405
|
+
*/
|
|
406
|
+
function elementNonNullCheckName(tableName, columnName) {
|
|
407
|
+
return `${tableName}_${columnName}_elem_not_null`;
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Predicate enforcing that a scalar-array column carries no NULL element. The
|
|
411
|
+
* array column itself may be NULL (container nullability is the column's NOT NULL
|
|
412
|
+
* clause); `array_position` over a NULL array yields NULL, which a CHECK treats
|
|
413
|
+
* as satisfied, so a nullable array column is unaffected.
|
|
414
|
+
*/
|
|
415
|
+
function elementNonNullCheckExpression(columnName) {
|
|
416
|
+
return `array_position(${quoteIdentifier(columnName)}, NULL) IS NULL`;
|
|
417
|
+
}
|
|
400
418
|
const ISSUE_KIND_ORDER = {
|
|
401
419
|
missing_schema: 1,
|
|
402
420
|
type_missing: 2,
|
|
@@ -471,8 +489,12 @@ function mapIssueToCall(issue, ctx) {
|
|
|
471
489
|
const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);
|
|
472
490
|
if (!contractTable) return notOk(issueConflict("unsupportedOperation", `Table "${issue.table}" in namespace "${namespaceId}" reported missing but not found in destination contract`));
|
|
473
491
|
const schemaForTable = tableSchema(issue);
|
|
492
|
+
const missingTableName = issue.table;
|
|
474
493
|
const ddlColumns = Object.entries(contractTable.columns).map(([name, column]) => toDdlColumn(name, column, codecHooks, storageTypes));
|
|
475
|
-
const
|
|
494
|
+
const primaryKeyConstraints = contractTable.primaryKey ? [contractFree.primaryKey(contractTable.primaryKey.columns, { ...contractTable.primaryKey.name ? { name: contractTable.primaryKey.name } : {} })] : [];
|
|
495
|
+
const elementNonNullChecks = Object.entries(contractTable.columns).filter(([, column]) => column.many === true).map(([columnName]) => contractFree.checkExpression(elementNonNullCheckName(missingTableName, columnName), elementNonNullCheckExpression(columnName)));
|
|
496
|
+
const allTableConstraints = [...primaryKeyConstraints, ...elementNonNullChecks];
|
|
497
|
+
const ddlConstraints = allTableConstraints.length > 0 ? allTableConstraints : void 0;
|
|
476
498
|
const calls = [new CreateTableCall(schemaForTable, issue.table, ddlColumns, ddlConstraints)];
|
|
477
499
|
for (const index of contractTable.indexes) {
|
|
478
500
|
const indexName = index.name ?? `${issue.table}_${index.columns.join("_")}_idx`;
|
|
@@ -679,6 +701,9 @@ function classifyCall(call) {
|
|
|
679
701
|
case "dropDefault": return "drop";
|
|
680
702
|
case "addCheckConstraint": return "unique";
|
|
681
703
|
case "createTable": return "table";
|
|
704
|
+
case "enableRowLevelSecurity": return "rlsEnable";
|
|
705
|
+
case "createRlsPolicy": return "rlsPolicy";
|
|
706
|
+
case "dropRlsPolicy": return "drop";
|
|
682
707
|
case "addColumn": return "column";
|
|
683
708
|
case "alterColumnType":
|
|
684
709
|
case "setNotNull":
|
|
@@ -821,4 +846,4 @@ function planIssues(options) {
|
|
|
821
846
|
//#endregion
|
|
822
847
|
export { postgresPlannerStrategies as n, planIssues as t };
|
|
823
848
|
|
|
824
|
-
//# sourceMappingURL=issue-planner-
|
|
849
|
+
//# sourceMappingURL=issue-planner-DbFvaAgu.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-planner-DbFvaAgu.mjs","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"sourcesContent":["/**\n * Migration strategies.\n *\n * Each strategy examines the issue list, consumes issues it handles, and\n * returns the `PostgresOpFactoryCall[]` to address them. The issue planner\n * runs each strategy in order and routes whatever's left through\n * `mapIssueToCall`.\n *\n * The full ordered list is exported as `postgresPlannerStrategies` and is\n * used unchanged by both `migration plan` and `db update` / `db init`. The\n * two journeys differ only in `policy.allowedOperationClasses`:\n *\n * - When `'data'` is in the policy, data-safe strategies (NOT NULL backfill,\n * nullability tightening, unsafe type changes) emit\n * `DataTransformCall` placeholders that the user fills in.\n * - When `'data'` is excluded, those strategies short-circuit so the\n * downstream walk-schema strategies (codec-hook type ops and temp-default\n * backfill) and `mapIssueToCall` defaults emit direct DDL instead.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport { resolveValueSetValues } from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport {\n type SqlStorage,\n StorageTable,\n type StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport type { CodecRef, DdlColumn } from '@prisma-next/sql-relational-core/ast';\nimport { col } from '@prisma-next/sql-relational-core/contract-free';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { JsonValue } from '@prisma-next/utils/json';\nimport { isPostgresSchema } from '../postgres-schema';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddNotNullColumnDirectCall,\n AddNotNullColumnWithTempDefaultCall,\n AlterColumnTypeCall,\n DataTransformCall,\n DropCheckConstraintCall,\n type PostgresOpFactoryCall,\n postgresDefaultToDdlColumnDefault,\n RawSqlCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { buildColumnTypeSql } from './planner-ddl-builders';\nimport { resolveIdentityValue } from './planner-identity-values';\nimport { buildSchemaLookupMap, hasForeignKey, hasUniqueConstraint } from './planner-schema-lookup';\nimport { buildExpectedFormatType } from './planner-sql-checks';\nimport { buildTargetDetails, type PostgresPlanTargetDetails } from './planner-target-details';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\n/**\n * Look up a storage table by its explicit namespace coordinate. Returns\n * `undefined` when the namespace has no table by that name (or no such\n * namespace exists). Callers that get `undefined` MUST treat it as an\n * explicit conflict — never silently fall back to a global default\n * schema or a name-only walk, because that footgun would resolve a\n * stale or duplicate table name to whichever namespace the iteration\n * order surfaced first (a real data-loss hazard in multi-namespace\n * contracts where two namespaces can carry the same table name).\n */\nexport function tableAt(\n storage: SqlStorage,\n namespaceId: string,\n tableName: string,\n): StorageTable | undefined {\n const ns = storage.namespaces[namespaceId];\n if (ns === undefined) return undefined;\n return ns.entries.table?.[tableName];\n}\n\n/**\n * Default namespace coordinate for an issue that does not carry one\n * explicitly. Hand-crafted unit-test issues and `extra_table` issues\n * fall back to `__unbound__`, the only namespace any single-namespace\n * contract carries — verifier-emitted issues for legacy\n * single-namespace contracts already stamp this id explicitly. Typed\n * structurally so issue variants without a `namespaceId` slot\n * (e.g. `EnumValuesChangedIssue`) flow through to the same fallback.\n */\nexport function resolveNamespaceIdForIssue(issue: { readonly namespaceId?: string }): string {\n return issue.namespaceId ?? UNBOUND_NAMESPACE_ID;\n}\n\n/**\n * Resolve the DDL schema name for a namespace coordinate. Postgres-aware\n * namespaces dispatch to their polymorphic `ddlSchemaName` override —\n * named schemas return their own id; the unbound singleton returns\n * `UNBOUND_NAMESPACE_ID`. Legacy single-namespace contracts whose\n * `__unbound__` slot is the framework-default `SqlUnboundNamespace`\n * (rather than the Postgres-aware `PostgresUnboundSchema`) flow the\n * coordinate through unchanged so downstream `qualifyTableName`\n * resolves polymorphically.\n */\nexport function resolveDdlSchemaForNamespace(ctx: StrategyContext, namespaceId: string): string {\n const namespace = ctx.toContract.storage.namespaces[namespaceId];\n if (isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(ctx.toContract.storage);\n }\n return namespaceId;\n}\n\n// ============================================================================\n// Strategy types\n// ============================================================================\n\n/**\n * Context passed to each migration strategy.\n *\n * Strategies read the source (`fromContract`), target (`toContract`), current\n * database state (`schema`), operation policy (`policy`), and component list\n * (`frameworkComponents`) to make planning decisions. `fromContract` is null\n * when no prior contract is available (e.g. `db update`, where the current\n * DB state is approximated via `schema`).\n */\nexport interface StrategyContext {\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly schemaName: string;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n readonly schema: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n// ============================================================================\n// Call strategies (for issue planner)\n// ============================================================================\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaIssue[];\n calls: readonly PostgresOpFactoryCall[];\n /**\n * `true` for strategies that emit cohesive sequential recipes whose\n * calls must stay contiguous and in the returned order — e.g.\n * `notNullBackfillCallStrategy` (addColumn → dataTransform → setNotNull).\n * Defaults to `false`, which lets `planIssues` hoist individual calls\n * into their DDL sequencing bucket.\n */\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\nfunction buildColumnSpec(\n namespaceId: string,\n table: string,\n column: string,\n ctx: StrategyContext,\n overrides?: { nullable?: boolean },\n): DdlColumn {\n const storageCol = tableAt(ctx.toContract.storage, namespaceId, table)?.columns[column];\n if (!storageCol)\n throw new Error(`Column \"${table}\".\"${column}\" not found in destination contract`);\n const mutableHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableTypes = ctx.storageTypes as Record<string, StorageTypeInstance>;\n const typeSql = buildColumnTypeSql(storageCol, mutableHooks, mutableTypes);\n const ddlDefault = postgresDefaultToDdlColumnDefault(storageCol.default);\n const resolved = resolveColumnTypeMetadata(storageCol, mutableTypes);\n const typeParams =\n resolved.typeParams === undefined\n ? undefined\n : blindCast<\n JsonValue,\n 'resolved.typeParams is JsonValue-shaped storage metadata; the narrowed value lands in CodecRef.typeParams which is JsonValue'\n >(resolved.typeParams);\n const codecRef: CodecRef | undefined = resolved.codecId\n ? {\n codecId: resolved.codecId,\n ...ifDefined('typeParams', typeParams),\n }\n : undefined;\n const nullable = overrides?.nullable ?? storageCol.nullable;\n return col(column, typeSql, {\n ...(!nullable ? { notNull: true } : {}),\n ...ifDefined('default', ddlDefault),\n ...ifDefined('codecRef', codecRef),\n });\n}\n\nfunction buildAlterTypeOptions(\n namespaceId: string,\n table: string,\n column: string,\n ctx: StrategyContext,\n using?: string,\n) {\n const col = tableAt(ctx.toContract.storage, namespaceId, table)?.columns[column];\n if (!col) throw new Error(`Column \"${table}\".\"${column}\" not found in destination contract`);\n const mutableHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableTypes = ctx.storageTypes as Record<string, StorageTypeInstance>;\n const qualifiedTargetType = buildColumnTypeSql(col, mutableHooks, mutableTypes, false);\n const formatTypeExpected = buildExpectedFormatType(col, mutableHooks, mutableTypes);\n return {\n qualifiedTargetType,\n formatTypeExpected,\n rawTargetTypeForLabel: qualifiedTargetType,\n ...(using !== undefined ? { using } : {}),\n };\n}\n\nexport const notNullBackfillCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // `DataTransformCall` is operation class `'data'`. When the policy excludes\n // it (`db update` / `db init`), skip so `notNullAddColumnCallStrategy`\n // (temp-default backfill) or `mapIssueToCall` can take the issue.\n if (!ctx.policy.allowedOperationClasses.includes('data')) return { kind: 'no_match' };\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'missing_column' || !issue.table || !issue.column) continue;\n\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[issue.column];\n if (!column) continue;\n if (column.nullable === true || column.default !== undefined) continue;\n\n matched.push(issue);\n const spec = buildColumnSpec(namespaceId, issue.table, issue.column, ctx, { nullable: true });\n const schemaForTable = resolveDdlSchemaForNamespace(ctx, namespaceId);\n calls.push(\n new AddColumnCall(schemaForTable, issue.table, spec),\n new DataTransformCall(\n `backfill-${issue.table}-${issue.column}`,\n `backfill-${issue.table}-${issue.column}:check`,\n `backfill-${issue.table}-${issue.column}:run`,\n ),\n new SetNotNullCall(schemaForTable, issue.table, issue.column),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\nconst SAFE_WIDENINGS = new Set(['int2→int4', 'int2→int8', 'int4→int8', 'float4→float8']);\n\nexport const typeChangeCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // For unsafe widenings this strategy emits a `DataTransformCall` placeholder\n // (operation class `'data'`); when the policy excludes `'data'`\n // (`db update` / `db init`), skip those issues so `mapIssueToCall` can\n // emit a direct `ALTER COLUMN TYPE`. Safe widenings still flow through\n // here because the resulting `AlterColumnTypeCall` is `widening`-class.\n const dataAllowed = ctx.policy.allowedOperationClasses.includes('data');\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'type_mismatch') continue;\n if (!issue.table || !issue.column) continue;\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const fromColumn = ctx.fromContract\n ? tableAt(ctx.fromContract.storage, namespaceId, issue.table)?.columns[issue.column]\n : undefined;\n const toColumn = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!fromColumn || !toColumn) continue;\n const fromType = fromColumn.nativeType;\n const toType = toColumn.nativeType;\n if (fromType === toType) continue;\n const isSafeWidening = SAFE_WIDENINGS.has(`${fromType}→${toType}`);\n if (!isSafeWidening && !dataAllowed) continue;\n matched.push(issue);\n const alterOpts = buildAlterTypeOptions(namespaceId, issue.table, issue.column, ctx);\n const schemaForTable = resolveDdlSchemaForNamespace(ctx, namespaceId);\n if (isSafeWidening) {\n calls.push(new AlterColumnTypeCall(schemaForTable, issue.table, issue.column, alterOpts));\n } else {\n calls.push(\n new DataTransformCall(\n `typechange-${issue.table}-${issue.column}`,\n `typechange-${issue.table}-${issue.column}:check`,\n `typechange-${issue.table}-${issue.column}:run`,\n ),\n new AlterColumnTypeCall(schemaForTable, issue.table, issue.column, alterOpts),\n );\n }\n }\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\nexport const nullableTighteningCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // `DataTransformCall` is operation class `'data'`. When the policy excludes\n // it (`db update` / `db init`), skip so `mapIssueToCall` emits a direct\n // `SET NOT NULL` instead.\n if (!ctx.policy.allowedOperationClasses.includes('data')) return { kind: 'no_match' };\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'nullability_mismatch' || !issue.table || !issue.column) continue;\n\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[issue.column];\n if (!column) continue;\n if (column.nullable === true) continue;\n\n matched.push(issue);\n const schemaForTable = resolveDdlSchemaForNamespace(ctx, namespaceId);\n calls.push(\n new DataTransformCall(\n `handle-nulls-${issue.table}-${issue.column}`,\n `handle-nulls-${issue.table}-${issue.column}:check`,\n `handle-nulls-${issue.table}-${issue.column}:run`,\n ),\n new SetNotNullCall(schemaForTable, issue.table, issue.column),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\n/**\n * Collects every check constraint from a table in the contract storage.\n * Returns an empty array when the table has no checks or the table is absent.\n */\nfunction collectContractChecks(\n storage: SqlStorage,\n namespaceId: string,\n tableName: string,\n): ReadonlyArray<{ name: string; column: string; permittedValues: readonly string[] }> {\n const ns = storage.namespaces[namespaceId];\n const tableRaw = ns !== undefined ? ns.entries.table?.[tableName] : undefined;\n if (!(tableRaw instanceof StorageTable)) return [];\n const checks = tableRaw.checks;\n if (!checks || checks.length === 0) return [];\n return checks.map((c) => ({\n name: c.name,\n column: c.column,\n permittedValues: resolveValueSetValues(\n c.valueSet,\n storage,\n `check \"${c.name}\" on \"${tableName}\"`,\n ),\n }));\n}\n\n/**\n * Compares two value arrays as unordered sets.\n */\nfunction checkValueSetsEqual(a: readonly string[], b: readonly string[]): boolean {\n if (a.length !== b.length) return false;\n const bSet = new Set(b);\n return a.every((v) => bSet.has(v));\n}\n\n/**\n * Plans check-constraint migrations for `enumType`-authored columns.\n *\n * Walks every namespace's tables in the target contract. For each table that\n * carries `checks`, diffs the contract-expected checks against the live\n * schema's checks:\n *\n * - Check in contract, absent from live DB → `AddCheckConstraintCall`.\n * - Check in live DB, absent from contract → `DropCheckConstraintCall`.\n * - Check on both sides but value sets differ → `DropCheckConstraintCall`\n * then `AddCheckConstraintCall` (drop + recreate; a check predicate cannot\n * be altered in place).\n *\n * Consumes `check_missing`, `check_removed`, and `check_mismatch` issues.\n */\nexport const checkConstraintPlanCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const calls: PostgresOpFactoryCall[] = [];\n const handledIssueKeys = new Set<string>();\n\n for (const [namespaceId, ns] of Object.entries(ctx.toContract.storage.namespaces)) {\n for (const tableName of Object.keys(ns.entries.table ?? {})) {\n const contractChecks = collectContractChecks(ctx.toContract.storage, namespaceId, tableName);\n if (contractChecks.length === 0) continue;\n\n const schemaTable = ctx.schema.tables[tableName];\n const liveChecks = schemaTable?.checks ?? [];\n const ddlSchema = resolveDdlSchemaForNamespace(ctx, namespaceId);\n\n for (const contractCheck of contractChecks) {\n const liveCheck = liveChecks.find((c) => c.name === contractCheck.name);\n const issueKey = `${tableName}\u0000${contractCheck.name}`;\n if (!liveCheck) {\n calls.push(\n new AddCheckConstraintCall(\n ddlSchema,\n tableName,\n contractCheck.name,\n contractCheck.column,\n contractCheck.permittedValues,\n ),\n );\n handledIssueKeys.add(issueKey);\n } else if (!checkValueSetsEqual(contractCheck.permittedValues, liveCheck.permittedValues)) {\n calls.push(\n new DropCheckConstraintCall(ddlSchema, tableName, contractCheck.name),\n new AddCheckConstraintCall(\n ddlSchema,\n tableName,\n contractCheck.name,\n contractCheck.column,\n contractCheck.permittedValues,\n ),\n );\n handledIssueKeys.add(issueKey);\n }\n // else: values match — no op needed, still consume the issue\n else {\n handledIssueKeys.add(issueKey);\n }\n }\n\n // Emit drops for checks that are live but not in the contract.\n for (const liveCheck of liveChecks) {\n const inContract = contractChecks.some((c) => c.name === liveCheck.name);\n if (!inContract) {\n const issueKey = `${tableName}\u0000${liveCheck.name}`;\n calls.push(new DropCheckConstraintCall(ddlSchema, tableName, liveCheck.name));\n handledIssueKeys.add(issueKey);\n }\n }\n }\n }\n\n if (calls.length === 0 && handledIssueKeys.size === 0) return { kind: 'no_match' };\n\n const remaining = issues.filter((issue) => {\n if (\n issue.kind !== 'check_missing' &&\n issue.kind !== 'check_removed' &&\n issue.kind !== 'check_mismatch'\n ) {\n return true;\n }\n if (!issue.table || !issue.indexOrConstraint) return true;\n const key = `${issue.table}\u0000${issue.indexOrConstraint}`;\n return !handledIssueKeys.has(key);\n });\n\n return { kind: 'match', issues: remaining, calls };\n};\n\n/**\n * Dispatches codec-typed storage types through their codec's\n * `planTypeOperations` hook (the authoritative source for codec-driven DDL\n * such as custom type creation).\n */\nexport const storageTypePlanCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const storageTypes = ctx.toContract.storage.types ?? {};\n if (Object.keys(storageTypes).length === 0) return { kind: 'no_match' };\n\n const calls: PostgresOpFactoryCall[] = [];\n const handledTypeNames = new Set<string>();\n\n for (const [typeName, typeInstance] of Object.entries(storageTypes).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n const codecInstance = typeInstance as StorageTypeInstance;\n const hook = ctx.codecHooks.get(codecInstance.codecId);\n if (!hook?.planTypeOperations) continue;\n const planResult = hook.planTypeOperations({\n typeName,\n typeInstance: codecInstance,\n contract: ctx.toContract,\n schema: ctx.schema,\n schemaName: ctx.schemaName,\n policy: ctx.policy,\n });\n if (!planResult) continue;\n if (planResult.operations.length === 0) {\n handledTypeNames.add(typeName);\n continue;\n }\n handledTypeNames.add(typeName);\n for (const op of planResult.operations) {\n calls.push(\n new RawSqlCall({\n ...op,\n target: {\n id: op.target.id,\n details: buildTargetDetails('type', typeName, ctx.schemaName),\n },\n } as SqlMigrationPlanOperation<PostgresPlanTargetDetails>),\n );\n }\n }\n\n const remaining = issues.filter(\n (issue) =>\n !(\n (issue.kind === 'type_missing' || issue.kind === 'enum_values_changed') &&\n issue.typeName &&\n handledTypeNames.has(issue.typeName)\n ),\n );\n\n if (calls.length === 0 && remaining.length === issues.length) {\n return { kind: 'no_match' };\n }\n\n return { kind: 'match', issues: remaining, calls };\n};\n\n/**\n * Handles `missing_column` issues for NOT NULL columns without a contract\n * default. Replaces the walk-schema `buildAddColumnItem` non-default branches.\n *\n * Two shapes:\n * - Shared-temp-default safe: emit a single atomic composite op (add\n * nullable → backfill identity value → `SET NOT NULL` → `DROP DEFAULT`).\n * - Empty-table guarded: emit a hand-built op with a `tableIsEmptyCheck`\n * precheck so the failure message is \"table is not empty\" rather than the\n * raw PG NOT NULL violation.\n *\n * \"Normal\" missing_column cases (nullable or has a contract default) are left\n * for `mapIssueToCall`'s default `AddColumnCall` emission.\n */\nexport const notNullAddColumnCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n const schemaLookups = buildSchemaLookupMap(ctx.schema);\n\n const mutableCodecHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableStorageTypes = ctx.storageTypes as Record<string, StorageTypeInstance>;\n\n for (const issue of issues) {\n if (issue.kind !== 'missing_column' || !issue.table || !issue.column) continue;\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);\n const column = contractTable?.columns[issue.column];\n if (!column) continue;\n\n const notNull = column.nullable !== true;\n const hasDefault = column.default !== undefined;\n if (!notNull || hasDefault) continue;\n\n const schemaTable = ctx.schema.tables[issue.table];\n if (!schemaTable) continue;\n\n const temporaryDefault = resolveIdentityValue(column, mutableCodecHooks, mutableStorageTypes);\n const schemaLookup = schemaLookups.get(issue.table);\n const canUseSharedTempDefault =\n temporaryDefault !== null &&\n canUseSharedTemporaryDefaultStrategy({\n table: contractTable,\n schemaTable,\n schemaLookup,\n columnName: issue.column,\n });\n\n matched.push(issue);\n\n const schemaForTable = resolveDdlSchemaForNamespace(ctx, namespaceId);\n\n if (canUseSharedTempDefault && temporaryDefault !== null) {\n calls.push(\n new AddNotNullColumnWithTempDefaultCall({\n schemaName: schemaForTable,\n tableName: issue.table,\n columnName: issue.column,\n column,\n codecHooks: mutableCodecHooks,\n storageTypes: mutableStorageTypes,\n temporaryDefault,\n }),\n );\n continue;\n }\n\n calls.push(\n new AddNotNullColumnDirectCall(\n schemaForTable,\n issue.table,\n issue.column,\n buildColumnSpec(namespaceId, issue.table, issue.column, ctx),\n ),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n };\n};\n\n// ============================================================================\n// Strategy helpers\n// ============================================================================\n\nfunction canUseSharedTemporaryDefaultStrategy(options: {\n readonly table: StorageTable;\n readonly schemaTable: SqlSchemaIR['tables'][string];\n readonly schemaLookup: ReturnType<typeof buildSchemaLookupMap> extends ReadonlyMap<\n string,\n infer V\n >\n ? V | undefined\n : never;\n readonly columnName: string;\n}): boolean {\n const { table, schemaTable, schemaLookup, columnName } = options;\n\n if (table.primaryKey?.columns.includes(columnName) && !schemaTable.primaryKey) {\n return false;\n }\n\n for (const unique of table.uniques) {\n if (!unique.columns.includes(columnName)) continue;\n if (!schemaLookup || !hasUniqueConstraint(schemaLookup, unique.columns)) return false;\n }\n\n for (const foreignKey of table.foreignKeys) {\n if (foreignKey.constraint === false || !foreignKey.source.columns.includes(columnName))\n continue;\n if (!schemaLookup || !hasForeignKey(schemaLookup, foreignKey)) return false;\n }\n\n return true;\n}\n\n/**\n * Ordered list of Postgres planner strategies, shared by `migration plan`\n * and `db update` / `db init`. The issue planner runs each strategy in\n * order, letting it consume any issues it handles, and routes whatever's\n * left through `mapIssueToCall`. Behavior diverges purely on\n * `policy.allowedOperationClasses`:\n *\n * - When `'data'` is allowed (`migration plan`), the data-safe strategies\n * (`notNullBackfillCallStrategy`, `typeChangeCallStrategy`,\n * `nullableTighteningCallStrategy`) consume their matching issues and emit\n * `DataTransformCall` placeholders or recipe ops.\n *\n * - When `'data'` is not allowed (`db update` / `db init`), the\n * placeholder-emitting strategies short-circuit to `no_match`, leaving\n * the issue for the downstream walk-schema strategies\n * (`storageTypePlanCallStrategy`, `notNullAddColumnCallStrategy`) or the\n * `mapIssueToCall` default to handle with direct DDL.\n *\n * Codec-typed storage type entries are dispatched through\n * `storageTypePlanCallStrategy`.\n */\nexport const postgresPlannerStrategies: readonly CallMigrationStrategy[] = [\n notNullBackfillCallStrategy,\n typeChangeCallStrategy,\n nullableTighteningCallStrategy,\n checkConstraintPlanCallStrategy,\n storageTypePlanCallStrategy,\n notNullAddColumnCallStrategy,\n];\n","/**\n * Postgres migration planner.\n *\n * Takes schema issues (from verifySqlSchema) and emits migration IR\n * (`PostgresOpFactoryCall[]`). Strategies consume issues they recognize and\n * produce specialized call sequences (e.g. NOT NULL backfill →\n * addColumn(nullable) + dataTransform + setNotNull); remaining issues flow\n * through `mapIssueToCall` for the default case.\n */\n\nimport type { Contract, JsonValue } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport { arraysEqual } from '@prisma-next/family-sql/diff';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\n SqlStorage,\n StorageColumn,\n StorageTable,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport type { CodecRef, DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport * as contractFree from '@prisma-next/sql-relational-core/contract-free';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { quoteIdentifier } from '../sql-utils';\nimport {\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n CreateIndexCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n type PostgresOpFactoryCall,\n postgresDefaultToDdlColumnDefault,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport type { ForeignKeySpec } from './operations/shared';\nimport { buildColumnDefaultSql, buildColumnTypeSql } from './planner-ddl-builders';\nimport { buildExpectedFormatType } from './planner-sql-checks';\nimport {\n type CallMigrationStrategy,\n postgresPlannerStrategies,\n resolveDdlSchemaForNamespace,\n resolveNamespaceIdForIssue,\n type StrategyContext,\n tableAt,\n} from './planner-strategies';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n/**\n * Deterministic name for the element-non-null CHECK constraint on a scalar-array\n * column. Distinct `_elem_not_null` suffix avoids collision with the enum\n * value-set `_check` constraints. Re-emitting the same schema produces the same\n * name, so `pg_get_constraintdef`-based verify sees no drift.\n */\nfunction elementNonNullCheckName(tableName: string, columnName: string): string {\n return `${tableName}_${columnName}_elem_not_null`;\n}\n\n/**\n * Predicate enforcing that a scalar-array column carries no NULL element. The\n * array column itself may be NULL (container nullability is the column's NOT NULL\n * clause); `array_position` over a NULL array yields NULL, which a CHECK treats\n * as satisfied, so a nullable array column is unaffected.\n */\nfunction elementNonNullCheckExpression(columnName: string): string {\n return `array_position(${quoteIdentifier(columnName)}, NULL) IS NULL`;\n}\n\n// ============================================================================\n// Issue kind ordering (dependency order)\n// ============================================================================\n\nconst ISSUE_KIND_ORDER: Record<string, number> = {\n // Schemas first — the database container must exist before any DDL\n // that targets it can run.\n missing_schema: 1,\n\n // Types next\n type_missing: 2,\n type_values_mismatch: 3,\n enum_values_changed: 3,\n\n // Drops (reconciliation — clear the way for creates)\n // FKs dropped first (they depend on other constraints)\n extra_foreign_key: 10,\n extra_unique_constraint: 11,\n extra_primary_key: 12,\n extra_index: 13,\n extra_default: 14,\n extra_column: 15,\n extra_table: 16,\n\n // Tables before columns\n missing_table: 20,\n\n // Columns before constraints\n missing_column: 30,\n\n // Reconciliation alters (on existing objects)\n type_mismatch: 40,\n nullability_mismatch: 41,\n default_missing: 42,\n default_mismatch: 43,\n\n // Constraints after columns exist\n primary_key_mismatch: 50,\n unique_constraint_mismatch: 51,\n index_mismatch: 52,\n foreign_key_mismatch: 60,\n\n // Check constraints\n check_missing: 53,\n check_mismatch: 54,\n check_removed: 55,\n};\n\nfunction issueOrder(issue: SchemaIssue): number {\n return ISSUE_KIND_ORDER[issue.kind] ?? 99;\n}\n\n// ============================================================================\n// Conflict helpers\n// ============================================================================\n\nfunction issueConflict(\n kind: SqlPlannerConflict['kind'],\n summary: string,\n location?: SqlPlannerConflict['location'],\n): SqlPlannerConflict {\n return {\n kind,\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction isMissing(issue: SchemaIssue): boolean {\n if (issue.kind === 'enum_values_changed') return false;\n return issue.actual === undefined;\n}\n\n// ============================================================================\n// Issue planner\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaIssue[];\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly schemaName: string;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;\n /**\n * Current database schema IR. Strategies read this to detect whether a\n * structure already exists (e.g. `buildSchemaLookupMap` for shared-temp-\n * default safety, extension dependency checks). Defaults to an empty schema\n * when omitted so the planner can still run over \"fresh DB\" contract\n * snapshots.\n */\n readonly schema?: SqlSchemaIR;\n /**\n * Operation-class policy. `planIssues` filters calls whose `operationClass`\n * is not in `policy.allowedOperationClasses` and surfaces them as conflicts\n * instead of emitting disallowed DDL. Defaults to additive-only.\n */\n readonly policy?: MigrationOperationPolicy;\n /**\n * Framework components participating in this composition. Available to\n * future strategies that may consult component metadata at plan time.\n */\n readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n readonly strategies?: readonly CallMigrationStrategy[];\n}\n\nexport interface IssuePlannerValue {\n readonly calls: readonly PostgresOpFactoryCall[];\n}\n\nfunction toDdlColumn(\n name: string,\n column: StorageColumn,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n storageTypes: Readonly<Record<string, StorageTypeInstance>>,\n): DdlColumn {\n const typeSql = buildColumnTypeSql(column, codecHooks, storageTypes);\n const ddlDefault = postgresDefaultToDdlColumnDefault(column.default);\n const resolved = resolveColumnTypeMetadata(\n column,\n storageTypes as Record<string, StorageTypeInstance>,\n );\n const codecRef: CodecRef | undefined = resolved.codecId\n ? {\n codecId: resolved.codecId,\n ...(resolved.typeParams !== undefined\n ? {\n typeParams: blindCast<\n JsonValue,\n 'resolved.typeParams is JsonValue-shaped storage metadata; the narrowed (non-undefined) value lands in CodecRef.typeParams which is JsonValue'\n >(resolved.typeParams),\n }\n : {}),\n }\n : undefined;\n return contractFree.col(name, typeSql, {\n ...(!column.nullable ? { notNull: true } : {}),\n ...ifDefined('default', ddlDefault),\n ...ifDefined('codecRef', codecRef),\n });\n}\n\nfunction mapIssueToCall(\n issue: SchemaIssue,\n ctx: StrategyContext,\n): Result<readonly PostgresOpFactoryCall[], SqlPlannerConflict> {\n const { schemaName, codecHooks, storageTypes } = ctx;\n // Per-table effective schema. `extra_table` issues intentionally\n // omit `namespaceId` — the live DB carries a table that\n // is not claimed by any contract namespace, so there is no contract\n // coordinate to project from. Those issues fall back to the planner's\n // global `ctx.schemaName`; every other issue dispatches through the\n // resolved namespace's polymorphic `ddlSchemaName`.\n const tableSchema = (issue: SchemaIssue): string => {\n if (issue.kind === 'extra_table') return schemaName;\n if (!('table' in issue) || !issue.table) return schemaName;\n return resolveDdlSchemaForNamespace(ctx, resolveNamespaceIdForIssue(issue));\n };\n\n switch (issue.kind) {\n case 'missing_schema': {\n const namespaceId = issue.namespaceId;\n if (!namespaceId)\n return notOk(\n issueConflict('unsupportedOperation', 'Missing schema issue has no namespaceId'),\n );\n const ddlSchemaName = resolveDdlSchemaForNamespace(ctx, namespaceId);\n return ok([new CreateSchemaCall(ddlSchemaName)]);\n }\n\n case 'missing_table': {\n if (!issue.table)\n return notOk(\n issueConflict('unsupportedOperation', 'Missing table issue has no table name'),\n );\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const contractTable = tableAt(ctx.toContract.storage, namespaceId, issue.table);\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" in namespace \"${namespaceId}\" reported missing but not found in destination contract`,\n ),\n );\n }\n const schemaForTable = tableSchema(issue);\n const missingTableName = issue.table;\n const ddlColumns: DdlColumn[] = Object.entries(contractTable.columns).map(([name, column]) =>\n toDdlColumn(name, column, codecHooks, storageTypes),\n );\n const primaryKeyConstraints: DdlTableConstraint[] = contractTable.primaryKey\n ? [\n contractFree.primaryKey(contractTable.primaryKey.columns, {\n ...(contractTable.primaryKey.name ? { name: contractTable.primaryKey.name } : {}),\n }),\n ]\n : [];\n const elementNonNullChecks: DdlTableConstraint[] = Object.entries(contractTable.columns)\n .filter(([, column]) => column.many === true)\n .map(([columnName]) =>\n contractFree.checkExpression(\n elementNonNullCheckName(missingTableName, columnName),\n elementNonNullCheckExpression(columnName),\n ),\n );\n const allTableConstraints = [...primaryKeyConstraints, ...elementNonNullChecks];\n const ddlConstraints: DdlTableConstraint[] | undefined =\n allTableConstraints.length > 0 ? allTableConstraints : undefined;\n const calls: PostgresOpFactoryCall[] = [\n new CreateTableCall(schemaForTable, issue.table, ddlColumns, ddlConstraints),\n ];\n for (const index of contractTable.indexes) {\n const indexName = index.name ?? `${issue.table}_${index.columns.join('_')}_idx`;\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (index.type !== undefined) extras.type = index.type;\n if (index.options !== undefined) extras.options = index.options;\n calls.push(\n new CreateIndexCall(schemaForTable, issue.table, indexName, [...index.columns], extras),\n );\n }\n const explicitIndexColumnSets = new Set(\n contractTable.indexes.map((idx) => idx.columns.join(',')),\n );\n for (const fk of contractTable.foreignKeys) {\n if (fk.constraint) {\n const fkName = fk.name ?? `${issue.table}_${fk.source.columns.join('_')}_fkey`;\n const fkSpec: ForeignKeySpec = {\n name: fkName,\n columns: fk.source.columns,\n references: {\n schema: fk.target.namespaceId,\n table: fk.target.tableName,\n columns: fk.target.columns,\n },\n ...(fk.onDelete !== undefined && { onDelete: fk.onDelete }),\n ...(fk.onUpdate !== undefined && { onUpdate: fk.onUpdate }),\n };\n calls.push(new AddForeignKeyCall(schemaForTable, issue.table, fkSpec));\n }\n if (fk.index && !explicitIndexColumnSets.has(fk.source.columns.join(','))) {\n const indexName = `${issue.table}_${fk.source.columns.join('_')}_idx`;\n calls.push(\n new CreateIndexCall(schemaForTable, issue.table, indexName, [...fk.source.columns]),\n );\n }\n }\n for (const unique of contractTable.uniques) {\n const constraintName = unique.name ?? `${issue.table}_${unique.columns.join('_')}_key`;\n calls.push(\n new AddUniqueCall(schemaForTable, issue.table, constraintName, [...unique.columns]),\n );\n }\n return ok(calls);\n }\n\n case 'missing_column':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Missing column issue has no table/column name'),\n );\n {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!column)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n return ok([\n new AddColumnCall(\n tableSchema(issue),\n issue.table,\n toDdlColumn(issue.column, column, codecHooks, storageTypes),\n ),\n ]);\n }\n\n case 'default_missing':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Default missing issue has no table/column name'),\n );\n {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!column?.default) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" has no default in contract`,\n ),\n );\n }\n const defaultSql = buildColumnDefaultSql(column.default, column);\n if (!defaultSql) return ok([]);\n return ok([new SetDefaultCall(tableSchema(issue), issue.table, issue.column, defaultSql)]);\n }\n\n case 'extra_table':\n if (!issue.table)\n return notOk(issueConflict('unsupportedOperation', 'Extra table issue has no table name'));\n return ok([new DropTableCall(tableSchema(issue), issue.table)]);\n\n case 'extra_column':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra column issue has no table/column name'),\n );\n return ok([new DropColumnCall(tableSchema(issue), issue.table, issue.column)]);\n\n case 'extra_index':\n if (!issue.table || !issue.indexOrConstraint)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra index issue has no table/index name'),\n );\n return ok([new DropIndexCall(tableSchema(issue), issue.table, issue.indexOrConstraint)]);\n\n case 'extra_unique_constraint':\n case 'extra_foreign_key':\n case 'extra_primary_key': {\n if (!issue.table)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Extra constraint issue has no table/constraint name',\n ),\n );\n // `extra_primary_key` issues don't carry a constraint name — the\n // verifier only has the table. Fall back to `<table>_pkey`, matching\n // Postgres' default PK constraint naming and the old reconciliation\n // planner's behavior.\n const constraintName =\n issue.indexOrConstraint ??\n (issue.kind === 'extra_primary_key' ? `${issue.table}_pkey` : undefined);\n if (!constraintName)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Extra constraint issue has no table/constraint name',\n ),\n );\n const kindMap = {\n extra_unique_constraint: 'unique' as const,\n extra_foreign_key: 'foreignKey' as const,\n extra_primary_key: 'primaryKey' as const,\n };\n return ok([\n new DropConstraintCall(\n tableSchema(issue),\n issue.table,\n constraintName,\n kindMap[issue.kind],\n ),\n ]);\n }\n\n case 'extra_default':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra default issue has no table/column name'),\n );\n return ok([new DropDefaultCall(tableSchema(issue), issue.table, issue.column)]);\n\n case 'nullability_mismatch': {\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('nullabilityConflict', 'Nullability mismatch has no table/column name'),\n );\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!column)\n return notOk(\n issueConflict(\n 'nullabilityConflict',\n `Column \"${issue.table}\".\"${issue.column}\" not found in destination contract`,\n ),\n );\n const schemaForTable = tableSchema(issue);\n return ok(\n column.nullable\n ? [new DropNotNullCall(schemaForTable, issue.table, issue.column)]\n : [new SetNotNullCall(schemaForTable, issue.table, issue.column)],\n );\n }\n\n case 'type_mismatch':\n if (!issue.table || !issue.column)\n return notOk(issueConflict('typeMismatch', 'Type mismatch has no table/column name'));\n {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!column)\n return notOk(\n issueConflict(\n 'typeMismatch',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n const hooksMap = codecHooks as Map<string, CodecControlHooks>;\n const typesMap = storageTypes as Record<string, StorageTypeInstance>;\n const qualifiedTargetType = buildColumnTypeSql(column, hooksMap, typesMap, false);\n const formatTypeExpected = buildExpectedFormatType(column, hooksMap, typesMap);\n return ok([\n new AlterColumnTypeCall(tableSchema(issue), issue.table, issue.column, {\n qualifiedTargetType,\n formatTypeExpected,\n rawTargetTypeForLabel: qualifiedTargetType,\n }),\n ]);\n }\n\n case 'default_mismatch':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Default mismatch has no table/column name'),\n );\n {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const column = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.columns[\n issue.column\n ];\n if (!column?.default) return ok([]);\n const defaultSql = buildColumnDefaultSql(column.default, column);\n if (!defaultSql) return ok([]);\n return ok([\n new SetDefaultCall(tableSchema(issue), issue.table, issue.column, defaultSql, 'widening'),\n ]);\n }\n\n case 'primary_key_mismatch':\n if (!issue.table)\n return notOk(issueConflict('indexIncompatible', 'Primary key issue has no table name'));\n if (isMissing(issue)) {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const pk = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.primaryKey;\n if (!pk)\n return notOk(\n issueConflict('indexIncompatible', `No primary key in contract for \"${issue.table}\"`),\n );\n const constraintName = pk.name ?? `${issue.table}_pkey`;\n return ok([\n new AddPrimaryKeyCall(tableSchema(issue), issue.table, constraintName, pk.columns),\n ]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Primary key on \"${issue.table}\" has different columns (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'unique_constraint_mismatch':\n if (!issue.table)\n return notOk(\n issueConflict('indexIncompatible', 'Unique constraint issue has no table name'),\n );\n if (isMissing(issue) && issue.expected) {\n const columns = issue.expected.split(', ');\n const constraintName = `${issue.table}_${columns.join('_')}_key`;\n return ok([new AddUniqueCall(tableSchema(issue), issue.table, constraintName, columns)]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Unique constraint on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'index_mismatch':\n if (!issue.table)\n return notOk(issueConflict('indexIncompatible', 'Index issue has no table name'));\n if (isMissing(issue) && issue.expected) {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const columns = issue.expected.split(', ');\n const contractIndex = tableAt(\n ctx.toContract.storage,\n namespaceId,\n issue.table,\n )?.indexes.find((idx: StorageTable['indexes'][number]) =>\n arraysEqual(idx.columns, columns),\n );\n const indexName = contractIndex?.name ?? `${issue.table}_${columns.join('_')}_idx`;\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (contractIndex?.type !== undefined) extras.type = contractIndex.type;\n if (contractIndex?.options !== undefined) extras.options = contractIndex.options;\n return ok([\n new CreateIndexCall(tableSchema(issue), issue.table, indexName, columns, extras),\n ]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Index on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'check_missing': {\n if (!issue.table || !issue.indexOrConstraint)\n return notOk(\n issueConflict('unsupportedOperation', 'Check missing issue has no table/constraint name'),\n );\n // check_missing is normally consumed by checkConstraintPlanCallStrategy.\n // This case handles any that arrive here (e.g. in tests that invoke\n // mapIssueToCall directly or skip the strategy).\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Check constraint \"${issue.indexOrConstraint}\" missing on \"${issue.table}\" — handled by checkConstraintPlanCallStrategy`,\n ),\n );\n }\n\n case 'check_mismatch': {\n if (!issue.table || !issue.indexOrConstraint)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Check mismatch issue has no table/constraint name',\n ),\n );\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Check constraint \"${issue.indexOrConstraint}\" values mismatch on \"${issue.table}\" — handled by checkConstraintPlanCallStrategy`,\n ),\n );\n }\n\n case 'check_removed': {\n if (!issue.table || !issue.indexOrConstraint)\n return notOk(\n issueConflict('unsupportedOperation', 'Check removed issue has no table/constraint name'),\n );\n return ok([\n new DropCheckConstraintCall(tableSchema(issue), issue.table, issue.indexOrConstraint),\n ]);\n }\n\n case 'foreign_key_mismatch':\n if (!issue.table)\n return notOk(issueConflict('foreignKeyConflict', 'Foreign key issue has no table name'));\n if (isMissing(issue) && issue.expected) {\n const arrowIdx = issue.expected.indexOf(' -> ');\n if (arrowIdx >= 0) {\n const namespaceId = resolveNamespaceIdForIssue(issue);\n const columns = issue.expected.slice(0, arrowIdx).split(', ');\n const fkName = `${issue.table}_${columns.join('_')}_fkey`;\n const fk = tableAt(ctx.toContract.storage, namespaceId, issue.table)?.foreignKeys.find(\n (k) => k.source.columns.join(', ') === columns.join(', '),\n );\n if (fk) {\n const fkSpec: ForeignKeySpec = {\n name: fkName,\n columns: fk.source.columns,\n references: {\n schema: fk.target.namespaceId,\n table: fk.target.tableName,\n columns: fk.target.columns,\n },\n ...(fk.onDelete !== undefined && { onDelete: fk.onDelete }),\n ...(fk.onUpdate !== undefined && { onUpdate: fk.onUpdate }),\n };\n return ok([new AddForeignKeyCall(tableSchema(issue), issue.table, fkSpec)]);\n }\n return notOk(\n issueConflict(\n 'foreignKeyConflict',\n `Foreign key on \"${issue.table}\" (${columns.join(', ')}) not found in destination contract`,\n { table: issue.table },\n ),\n );\n }\n }\n return notOk(\n issueConflict(\n 'foreignKeyConflict',\n `Foreign key on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'type_missing': {\n if (!issue.typeName)\n return notOk(issueConflict('unsupportedOperation', 'Type missing issue has no typeName'));\n const typeInstance = ctx.toContract.storage.types?.[issue.typeName];\n if (!typeInstance) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName}\" reported missing but not found in destination contract`,\n ),\n );\n }\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName}\" uses codec \"${typeInstance.codecId}\" — only value-set types are supported`,\n ),\n );\n }\n\n case 'type_values_mismatch':\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName ?? 'unknown'}\" values differ — type alteration not yet supported`,\n ),\n );\n\n default:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Unhandled issue kind: ${(issue as SchemaIssue).kind}`,\n ),\n );\n }\n}\n\n/**\n * Classifies calls into dependency order categories for correct DDL sequencing.\n */\ntype CallCategory =\n | 'dep'\n | 'drop'\n | 'table'\n | 'rlsEnable'\n | 'rlsPolicy'\n | 'column'\n | 'alter'\n | 'primaryKey'\n | 'unique'\n | 'index'\n | 'foreignKey';\n\n/**\n * Classifies calls into DDL sequencing buckets. The order matches the\n * legacy walk-schema planner's emission order so `db init` and `db update`\n * produce byte-identical plans for the shared shape (deps → drops → tables\n * → columns → alters → PKs → uniques → indexes → FKs).\n */\nfunction classifyCall(call: PostgresOpFactoryCall): CallCategory {\n switch (call.factoryName) {\n case 'createExtension':\n case 'createSchema':\n return 'dep';\n case 'dropTable':\n case 'dropColumn':\n case 'dropConstraint':\n case 'dropCheckConstraint':\n case 'dropIndex':\n case 'dropDefault':\n return 'drop';\n case 'addCheckConstraint':\n return 'unique'; // after uniques, before indexes\n case 'createTable':\n return 'table';\n case 'enableRowLevelSecurity':\n return 'rlsEnable';\n case 'createRlsPolicy':\n return 'rlsPolicy';\n case 'dropRlsPolicy':\n return 'drop';\n case 'addColumn':\n return 'column';\n case 'alterColumnType':\n case 'setNotNull':\n case 'dropNotNull':\n case 'setDefault':\n return 'alter';\n case 'addPrimaryKey':\n return 'primaryKey';\n case 'addUnique':\n return 'unique';\n case 'createIndex':\n return 'index';\n case 'addForeignKey':\n return 'foreignKey';\n case 'rawSql': {\n // Type ops lifted through `RawSqlCall` by `storageTypePlanCallStrategy`\n // to preserve the codec-emitted label and precheck/postcheck.\n // Classification falls back to inspecting the underlying op's target\n // details (`objectType: 'type'`).\n const op = (\n call as {\n op?: {\n target?: { details?: { objectType?: string } };\n };\n }\n ).op;\n const objectType = op?.target?.details?.objectType;\n if (objectType === 'type') return 'dep';\n return 'alter';\n }\n default:\n return 'alter';\n }\n}\n\n/** Stable lexical key used to order issues within the same kind bucket. */\nfunction issueKey(issue: SchemaIssue): string {\n const table = 'table' in issue && typeof issue.table === 'string' ? issue.table : '';\n const column = 'column' in issue && typeof issue.column === 'string' ? issue.column : '';\n const name =\n 'indexOrConstraint' in issue && typeof issue.indexOrConstraint === 'string'\n ? issue.indexOrConstraint\n : '';\n return `${table}\\u0000${column}\\u0000${name}`;\n}\n\n// When no policy is explicitly supplied (test-only path; production callers\n// always pass one), allow every class so strategies that gate on\n// `'data'` (data-safe placeholders) still fire — the test is treated as\n// trusted. Filtering of actual emitted calls only runs when a policy was\n// explicitly provided (see `policyProvided` below).\nconst DEFAULT_POLICY: MigrationOperationPolicy = {\n allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'],\n};\n\nfunction emptySchemaIR(): SqlSchemaIR {\n return { tables: {} };\n}\n\nfunction conflictKindForCall(call: PostgresOpFactoryCall): SqlPlannerConflict['kind'] {\n switch (call.factoryName) {\n case 'alterColumnType':\n return 'typeMismatch';\n case 'setNotNull':\n case 'dropNotNull':\n return 'nullabilityConflict';\n case 'addForeignKey':\n case 'dropConstraint':\n return 'foreignKeyConflict';\n case 'createIndex':\n case 'dropIndex':\n return 'indexIncompatible';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction locationForCall(call: PostgresOpFactoryCall): SqlPlannerConflict['location'] | undefined {\n // Most Postgres call classes expose `tableName`/`columnName`/`indexName`/\n // `constraintName` as readonly fields. We avoid `toOp()` here because a\n // `DataTransformCall` intentionally throws from `toOp`.\n const anyCall = call as unknown as {\n tableName?: string;\n columnName?: string;\n indexName?: string;\n constraintName?: string;\n typeName?: string;\n };\n const location: {\n table?: string;\n column?: string;\n index?: string;\n constraint?: string;\n type?: string;\n } = {};\n if (anyCall.tableName) location.table = anyCall.tableName;\n if (anyCall.columnName) location.column = anyCall.columnName;\n if (anyCall.indexName) location.index = anyCall.indexName;\n if (anyCall.constraintName) location.constraint = anyCall.constraintName;\n if (anyCall.typeName) location.type = anyCall.typeName;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction conflictForDisallowedCall(\n call: PostgresOpFactoryCall,\n allowed: readonly string[],\n): SqlPlannerConflict {\n const summary = `Operation \"${call.label}\" requires class \"${call.operationClass}\", but policy allows only: ${allowed.join(', ')}`;\n const location = locationForCall(call);\n return {\n kind: conflictKindForCall(call),\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nexport function planIssues(\n options: IssuePlannerOptions,\n): Result<IssuePlannerValue, readonly SqlPlannerConflict[]> {\n // When no policy is supplied, `planIssues` treats the call as trusted (the\n // caller — typically a test — has already vetted the issues). Only explicit\n // policies gate operation classes into conflicts.\n // `PostgresMigrationPlanner` always passes an explicit policy.\n const policyProvided = options.policy !== undefined;\n const policy = options.policy ?? DEFAULT_POLICY;\n const schema = options.schema ?? emptySchemaIR();\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n toContract: options.toContract,\n fromContract: options.fromContract,\n schemaName: options.schemaName,\n codecHooks: options.codecHooks,\n storageTypes: options.storageTypes,\n schema,\n policy,\n frameworkComponents,\n };\n\n const strategies = options.strategies ?? postgresPlannerStrategies;\n\n let remaining = options.issues;\n const recipeCalls: PostgresOpFactoryCall[] = [];\n const bucketablePatternCalls: PostgresOpFactoryCall[] = [];\n\n for (const strategy of strategies) {\n const result = strategy(remaining, context);\n if (result.kind === 'match') {\n remaining = result.issues;\n if (result.recipe) {\n recipeCalls.push(...result.calls);\n } else {\n bucketablePatternCalls.push(...result.calls);\n }\n }\n }\n\n const sorted = [...remaining].sort((a, b) => {\n const kindDelta = issueOrder(a) - issueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = issueKey(a);\n const keyB = issueKey(b);\n return keyA < keyB ? -1 : keyA > keyB ? 1 : 0;\n });\n\n const defaultCalls: PostgresOpFactoryCall[] = [];\n const conflicts: SqlPlannerConflict[] = [];\n\n for (const issue of sorted) {\n const result = mapIssueToCall(issue, context);\n if (result.ok) {\n defaultCalls.push(...result.value);\n } else {\n conflicts.push(result.failure);\n }\n }\n\n // Policy gating: drop calls whose operation class is not allowed and\n // surface a conflict describing the disallowed op. Applies to both strategy\n // output and default-mapped output. Only active when the caller explicitly\n // supplied a policy — direct unit-test invocations (which pass no policy)\n // stay as pass-through and keep destructive recipe steps intact.\n const allowed = policy.allowedOperationClasses;\n let gatedDefault = defaultCalls;\n let gatedRecipe = recipeCalls;\n let gatedBucketable = bucketablePatternCalls;\n if (policyProvided) {\n const keepIfAllowed = (bucket: PostgresOpFactoryCall[]) => (call: PostgresOpFactoryCall) => {\n if (allowed.includes(call.operationClass)) {\n bucket.push(call);\n return;\n }\n conflicts.push(conflictForDisallowedCall(call, allowed));\n };\n const gatedDefaultBucket: PostgresOpFactoryCall[] = [];\n const gatedRecipeBucket: PostgresOpFactoryCall[] = [];\n const gatedBucketableBucket: PostgresOpFactoryCall[] = [];\n defaultCalls.forEach(keepIfAllowed(gatedDefaultBucket));\n recipeCalls.forEach(keepIfAllowed(gatedRecipeBucket));\n bucketablePatternCalls.forEach(keepIfAllowed(gatedBucketableBucket));\n gatedDefault = gatedDefaultBucket;\n gatedRecipe = gatedRecipeBucket;\n gatedBucketable = gatedBucketableBucket;\n }\n\n if (conflicts.length > 0) {\n return notOk(conflicts);\n }\n\n // Recipe strategies (`notNullBackfillCallStrategy`,\n // `nullableTighteningCallStrategy`, etc.) emit a cohesive sequence that must\n // stay contiguous. They are inserted at a single pattern slot. Non-recipe\n // pattern strategies (`checkConstraintPlanCallStrategy`,\n // `storageTypePlanCallStrategy`, `notNullAddColumnCallStrategy`) produce\n // individually classifiable calls that slot into DDL buckets alongside\n // default-mapped calls.\n const combinedBucketable = [...gatedDefault, ...gatedBucketable];\n const byCategory = (cat: CallCategory) =>\n combinedBucketable.filter((c) => classifyCall(c) === cat);\n\n const calls: PostgresOpFactoryCall[] = [\n ...byCategory('dep'),\n ...byCategory('drop'),\n ...byCategory('table'),\n ...byCategory('column'),\n ...gatedRecipe,\n ...byCategory('alter'),\n ...byCategory('primaryKey'),\n ...byCategory('unique'),\n ...byCategory('index'),\n ...byCategory('foreignKey'),\n ];\n\n return ok({ calls });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwEA,SAAgB,QACd,SACA,aACA,WAC0B;CAC1B,MAAM,KAAK,QAAQ,WAAW;CAC9B,IAAI,OAAO,KAAA,GAAW,OAAO,KAAA;CAC7B,OAAO,GAAG,QAAQ,QAAQ;AAC5B;;;;;;;;;;AAWA,SAAgB,2BAA2B,OAAkD;CAC3F,OAAO,MAAM,eAAe;AAC9B;;;;;;;;;;;AAYA,SAAgB,6BAA6B,KAAsB,aAA6B;CAC9F,MAAM,YAAY,IAAI,WAAW,QAAQ,WAAW;CACpD,IAAI,iBAAiB,SAAS,GAC5B,OAAO,UAAU,cAAc,IAAI,WAAW,OAAO;CAEvD,OAAO;AACT;AAiDA,SAAS,gBACP,aACA,OACA,QACA,KACA,WACW;CACX,MAAM,aAAa,QAAQ,IAAI,WAAW,SAAS,aAAa,KAAK,CAAC,EAAE,QAAQ;CAChF,IAAI,CAAC,YACH,MAAM,IAAI,MAAM,WAAW,MAAM,KAAK,OAAO,oCAAoC;CACnF,MAAM,eAAe,IAAI;CACzB,MAAM,eAAe,IAAI;CACzB,MAAM,UAAU,mBAAmB,YAAY,cAAc,YAAY;CACzE,MAAM,aAAa,kCAAkC,WAAW,OAAO;CACvE,MAAM,WAAW,0BAA0B,YA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AAM,SAAS;CAUxB,MAAM,qBAAqB,CAAC,GAAG,cAAc,GAAG,eAAe;CAC/D,MAAM,cAAc,QAClB,mBAAmB,QAAQ,MAAM,aAAa,CAAC,MAAM,GAAG;CAe1D,OAAO,GAAG,EAAE,OAAA;EAZV,GAAG,WAAW,KAAK;EACnB,GAAG,WAAW,MAAM;EACpB,GAAG,WAAW,OAAO;EACrB,GAAG,WAAW,QAAQ;EACtB,GAAG;EACH,GAAG,WAAW,OAAO;EACrB,GAAG,WAAW,YAAY;EAC1B,GAAG,WAAW,QAAQ;EACtB,GAAG,WAAW,OAAO;EACrB,GAAG,WAAW,YAAY;CAGZ,EAAE,CAAC;AACrB"}
|
package/dist/issue-planner.d.mts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { b as PostgresOpFactoryCall } from "./op-factory-call-
|
|
1
|
+
import { b as PostgresOpFactoryCall } from "./op-factory-call-CJWUxyUW.mjs";
|
|
2
2
|
import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma-next/family-sql/control";
|
|
3
|
-
import { Result } from "@prisma-next/utils/result";
|
|
4
3
|
import { SqlStorage, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
4
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
5
5
|
import { SchemaIssue } from "@prisma-next/framework-components/control";
|
|
6
|
+
import { Result } from "@prisma-next/utils/result";
|
|
6
7
|
import { Contract } from "@prisma-next/contract/types";
|
|
7
8
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
8
|
-
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
9
9
|
|
|
10
10
|
//#region src/core/migrations/planner-strategies.d.ts
|
|
11
11
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UA8HiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;AAAA,KAOlC,qBAAA,IACV,MAAA,WAAiB,WAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,WAAA;EACjB,KAAA,WAAgB,qBAAA;
|
|
1
|
+
{"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UA8HiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;AAAA,KAOlC,qBAAA,IACV,MAAA,WAAiB,WAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,WAAA;EACjB,KAAA,WAAgB,qBAAA;ECuBG;;;;;;;EDfnB,MAAA;AAAA;EAEA,IAAA;AAAA;;;UCUW,mBAAA;EAAA,SACN,MAAA,WAAiB,WAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EDxCJ;;;;;;;EAAA,SCgDlC,MAAA,GAAS,WAAA;EDrDT;;;;;EAAA,SC2DA,MAAA,GAAS,wBAAA;EDzDc;;;;EAAA,SC8DvB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;AAAA,UAGhB,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;AAAA,iBA+qBhC,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
|
package/dist/issue-planner.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as planIssues } from "./issue-planner-
|
|
1
|
+
import { t as planIssues } from "./issue-planner-DbFvaAgu.mjs";
|
|
2
2
|
export { planIssues };
|
package/dist/migration.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-
|
|
2
|
-
import { T as Op } from "./op-factory-call-
|
|
3
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
4
|
-
import { col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
|
|
1
|
+
import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-qKy1U5V9.mjs";
|
|
2
|
+
import { T as Op } from "./op-factory-call-CJWUxyUW.mjs";
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-D7kNVWVG.mjs";
|
|
4
|
+
import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
5
|
import { placeholder } from "@prisma-next/errors/migration";
|
|
6
6
|
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
|
7
7
|
import { ExecuteRequestLowerer } from "@prisma-next/family-sql/control-adapter";
|
|
@@ -22,5 +22,5 @@ declare function createExtension(extensionName: string): Op;
|
|
|
22
22
|
*/
|
|
23
23
|
declare function rawSql(op: Op): Op;
|
|
24
24
|
//#endregion
|
|
25
|
-
export { type DataTransformClosure, type DataTransformOptions, PostgresMigration as Migration, MigrationCLI, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
|
|
25
|
+
export { type DataTransformClosure, type DataTransformOptions, PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };
|
|
26
26
|
//# sourceMappingURL=migration.d.mts.map
|