@prisma-next/target-postgres 0.13.0 → 0.14.0

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.
Files changed (190) hide show
  1. package/dist/{codec-ids-CTikp1if.mjs → codec-ids-BvytN2P8.mjs} +3 -3
  2. package/dist/codec-ids-BvytN2P8.mjs.map +1 -0
  3. package/dist/{codec-ids-B1vOchLE.d.mts → codec-ids-CnXu9Qy3.d.mts} +3 -3
  4. package/dist/codec-ids-CnXu9Qy3.d.mts.map +1 -0
  5. package/dist/codec-ids.d.mts +2 -2
  6. package/dist/codec-ids.mjs +2 -2
  7. package/dist/{codec-types-CnFiNML4.d.mts → codec-types-DHCkwPKE.d.mts} +3 -3
  8. package/dist/{codec-types-CnFiNML4.d.mts.map → codec-types-DHCkwPKE.d.mts.map} +1 -1
  9. package/dist/codec-types.d.mts +1 -1
  10. package/dist/{codecs-CBpEv4s5.d.mts → codecs--0A5_4Bq.d.mts} +26 -23
  11. package/dist/codecs--0A5_4Bq.d.mts.map +1 -0
  12. package/dist/codecs.d.mts +2 -2
  13. package/dist/codecs.mjs +28 -35
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.d.mts +163 -15
  16. package/dist/contract-free.d.mts.map +1 -1
  17. package/dist/contract-free.mjs +4 -17
  18. package/dist/contract-free.mjs.map +1 -1
  19. package/dist/control.d.mts.map +1 -1
  20. package/dist/control.mjs +21 -27
  21. package/dist/control.mjs.map +1 -1
  22. package/dist/{data-transform-D25tLeYU.mjs → data-transform-BOWpliq8.mjs} +9 -17
  23. package/dist/data-transform-BOWpliq8.mjs.map +1 -0
  24. package/dist/{data-transform-DGOqcLrf.d.mts → data-transform-DDgWdB5o.d.mts} +2 -2
  25. package/dist/data-transform-DDgWdB5o.d.mts.map +1 -0
  26. package/dist/data-transform.d.mts +1 -1
  27. package/dist/data-transform.mjs +1 -1
  28. package/dist/ddl-QDyOSeLc.mjs +251 -0
  29. package/dist/ddl-QDyOSeLc.mjs.map +1 -0
  30. package/dist/ddl.d.mts +2 -2
  31. package/dist/ddl.mjs +2 -2
  32. package/dist/descriptor-meta-CpGygXpI.mjs +140 -0
  33. package/dist/descriptor-meta-CpGygXpI.mjs.map +1 -0
  34. package/dist/{issue-planner-Br0pt1Ea.mjs → issue-planner-DL6g3CmE.mjs} +52 -366
  35. package/dist/issue-planner-DL6g3CmE.mjs.map +1 -0
  36. package/dist/issue-planner.d.mts +8 -11
  37. package/dist/issue-planner.d.mts.map +1 -1
  38. package/dist/issue-planner.mjs +1 -1
  39. package/dist/migration.d.mts +5 -92
  40. package/dist/migration.d.mts.map +1 -1
  41. package/dist/migration.mjs +4 -4
  42. package/dist/{nodes-DZk2JZG3.mjs → nodes-Bbhs2rwj.mjs} +31 -2
  43. package/dist/nodes-Bbhs2rwj.mjs.map +1 -0
  44. package/dist/{nodes-779hmCfL.d.mts → nodes-pLeLgdis.d.mts} +30 -3
  45. package/dist/nodes-pLeLgdis.d.mts.map +1 -0
  46. package/dist/{op-factory-call-D2aAUhmS.mjs → op-factory-call-D_p5vxwt.mjs} +601 -418
  47. package/dist/op-factory-call-D_p5vxwt.mjs.map +1 -0
  48. package/dist/{op-factory-call-DMA86_2D.d.mts → op-factory-call-DmQEc3XV.d.mts} +119 -72
  49. package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -0
  50. package/dist/op-factory-call.d.mts +2 -2
  51. package/dist/op-factory-call.mjs +2 -2
  52. package/dist/pack.d.mts +36 -15
  53. package/dist/pack.d.mts.map +1 -1
  54. package/dist/pack.mjs +1 -1
  55. package/dist/{planner-CAYPJObw.mjs → planner-Bs_baQax.mjs} +25 -45
  56. package/dist/planner-Bs_baQax.mjs.map +1 -0
  57. package/dist/{planner-ddl-builders-Cw2n2llW.mjs → planner-ddl-builders-B2wOwLqI.mjs} +2 -2
  58. package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +1 -0
  59. package/dist/planner-ddl-builders.d.mts +4 -4
  60. package/dist/planner-ddl-builders.d.mts.map +1 -1
  61. package/dist/planner-ddl-builders.mjs +1 -1
  62. package/dist/{planner-identity-values-BIpa5p2I.mjs → planner-identity-values-CJPha2Sz.mjs} +3 -9
  63. package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -0
  64. package/dist/planner-identity-values.d.mts +1 -1
  65. package/dist/planner-identity-values.d.mts.map +1 -1
  66. package/dist/planner-identity-values.mjs +1 -1
  67. package/dist/{planner-produced-postgres-migration-NSEhWL0L.mjs → planner-produced-postgres-migration-Cji5vxUf.mjs} +6 -4
  68. package/dist/planner-produced-postgres-migration-Cji5vxUf.mjs.map +1 -0
  69. package/dist/{planner-produced-postgres-migration-B4EDvLdz.d.mts → planner-produced-postgres-migration-QqHa2C2l.d.mts} +5 -6
  70. package/dist/planner-produced-postgres-migration-QqHa2C2l.d.mts.map +1 -0
  71. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  72. package/dist/planner-produced-postgres-migration.mjs +1 -1
  73. package/dist/planner-sql-checks-jqUUGyQR.mjs +152 -0
  74. package/dist/planner-sql-checks-jqUUGyQR.mjs.map +1 -0
  75. package/dist/planner-sql-checks.d.mts +3 -49
  76. package/dist/planner-sql-checks.d.mts.map +1 -1
  77. package/dist/planner-sql-checks.mjs +2 -2
  78. package/dist/{planner-type-resolution-836DExFN.mjs → planner-type-resolution-Bt2f_q-F.mjs} +1 -6
  79. package/dist/planner-type-resolution-Bt2f_q-F.mjs.map +1 -0
  80. package/dist/planner.d.mts +4 -4
  81. package/dist/planner.d.mts.map +1 -1
  82. package/dist/planner.mjs +1 -1
  83. package/dist/{postgres-contract-serializer-DYTyXjPf.mjs → postgres-contract-serializer-k3TAcPMY.mjs} +30 -37
  84. package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +1 -0
  85. package/dist/postgres-migration-B5jKrXv3.mjs +145 -0
  86. package/dist/postgres-migration-B5jKrXv3.mjs.map +1 -0
  87. package/dist/postgres-migration-Y4YBJqkS.d.mts +181 -0
  88. package/dist/postgres-migration-Y4YBJqkS.d.mts.map +1 -0
  89. package/dist/{postgres-schema-BuxCxbvB.mjs → postgres-schema-COGZ1ark.mjs} +82 -23
  90. package/dist/postgres-schema-COGZ1ark.mjs.map +1 -0
  91. package/dist/{render-ops-BpjstrKQ.mjs → render-ops-BREh1kHe.mjs} +10 -5
  92. package/dist/render-ops-BREh1kHe.mjs.map +1 -0
  93. package/dist/render-ops.d.mts +2 -2
  94. package/dist/render-ops.d.mts.map +1 -1
  95. package/dist/render-ops.mjs +1 -1
  96. package/dist/runtime.d.mts +1 -0
  97. package/dist/runtime.d.mts.map +1 -1
  98. package/dist/runtime.mjs +2 -2
  99. package/dist/table-source-BvFo7gVs.d.mts +15 -0
  100. package/dist/table-source-BvFo7gVs.d.mts.map +1 -0
  101. package/dist/types.d.mts +34 -19
  102. package/dist/types.d.mts.map +1 -1
  103. package/dist/types.mjs +2 -3
  104. package/package.json +17 -18
  105. package/src/contract-free/checks.ts +363 -0
  106. package/src/contract-free/ddl.ts +28 -1
  107. package/src/core/authoring.ts +43 -44
  108. package/src/core/codec-helpers.ts +0 -17
  109. package/src/core/codec-ids.ts +1 -1
  110. package/src/core/codec-type-map.ts +2 -2
  111. package/src/core/codecs.ts +43 -48
  112. package/src/core/ddl/nodes.ts +59 -1
  113. package/src/core/migrations/control-policy.ts +17 -47
  114. package/src/core/migrations/issue-planner.ts +34 -70
  115. package/src/core/migrations/op-factory-call.ts +486 -215
  116. package/src/core/migrations/operations/columns.ts +175 -140
  117. package/src/core/migrations/operations/constraints.ts +79 -108
  118. package/src/core/migrations/operations/data-transform.ts +15 -18
  119. package/src/core/migrations/operations/dependencies.ts +16 -14
  120. package/src/core/migrations/operations/indexes.ts +31 -28
  121. package/src/core/migrations/operations/shared.ts +2 -2
  122. package/src/core/migrations/operations/tables.ts +13 -14
  123. package/src/core/migrations/planner-ddl-builders.ts +3 -4
  124. package/src/core/migrations/planner-identity-values.ts +4 -28
  125. package/src/core/migrations/planner-produced-postgres-migration.ts +15 -7
  126. package/src/core/migrations/planner-recipes.ts +44 -39
  127. package/src/core/migrations/planner-sql-checks.ts +3 -178
  128. package/src/core/migrations/planner-strategies.ts +76 -449
  129. package/src/core/migrations/planner-type-resolution.ts +2 -20
  130. package/src/core/migrations/planner.ts +6 -6
  131. package/src/core/migrations/postgres-migration.ts +287 -7
  132. package/src/core/migrations/render-ops.ts +26 -13
  133. package/src/core/migrations/runner.ts +26 -20
  134. package/src/core/postgres-contract-serializer.ts +37 -54
  135. package/src/core/postgres-enum-type-schema.ts +17 -0
  136. package/src/core/postgres-schema.ts +86 -46
  137. package/src/exports/codecs.ts +2 -2
  138. package/src/exports/contract-free.ts +22 -1
  139. package/src/exports/control.ts +0 -22
  140. package/src/exports/ddl.ts +4 -0
  141. package/src/exports/migration.ts +1 -29
  142. package/src/exports/op-factory-call.ts +0 -4
  143. package/src/exports/planner-sql-checks.ts +0 -7
  144. package/src/exports/types.ts +0 -1
  145. package/dist/codec-ids-B1vOchLE.d.mts.map +0 -1
  146. package/dist/codec-ids-CTikp1if.mjs.map +0 -1
  147. package/dist/codecs-CBpEv4s5.d.mts.map +0 -1
  148. package/dist/data-transform-D25tLeYU.mjs.map +0 -1
  149. package/dist/data-transform-DGOqcLrf.d.mts.map +0 -1
  150. package/dist/ddl-77SyXgFt.mjs +0 -30
  151. package/dist/ddl-77SyXgFt.mjs.map +0 -1
  152. package/dist/descriptor-meta-DKmj-IMN.mjs +0 -14
  153. package/dist/descriptor-meta-DKmj-IMN.mjs.map +0 -1
  154. package/dist/descriptor-meta-runtime-My8_s4cs.mjs +0 -130
  155. package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +0 -1
  156. package/dist/enum-planning-BCyvlFHk.mjs +0 -0
  157. package/dist/enum-planning-BCyvlFHk.mjs.map +0 -1
  158. package/dist/enum-planning.d.mts +0 -86
  159. package/dist/enum-planning.d.mts.map +0 -1
  160. package/dist/enum-planning.mjs +0 -2
  161. package/dist/issue-planner-Br0pt1Ea.mjs.map +0 -1
  162. package/dist/nodes-779hmCfL.d.mts.map +0 -1
  163. package/dist/nodes-DZk2JZG3.mjs.map +0 -1
  164. package/dist/op-factory-call-D2aAUhmS.mjs.map +0 -1
  165. package/dist/op-factory-call-DMA86_2D.d.mts.map +0 -1
  166. package/dist/planner-CAYPJObw.mjs.map +0 -1
  167. package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +0 -1
  168. package/dist/planner-identity-values-BIpa5p2I.mjs.map +0 -1
  169. package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +0 -1
  170. package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +0 -1
  171. package/dist/planner-sql-checks-DAdhnI2c.mjs +0 -272
  172. package/dist/planner-sql-checks-DAdhnI2c.mjs.map +0 -1
  173. package/dist/planner-type-resolution-836DExFN.mjs.map +0 -1
  174. package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +0 -1
  175. package/dist/postgres-enum-type-BVn63a89.d.mts +0 -72
  176. package/dist/postgres-enum-type-BVn63a89.d.mts.map +0 -1
  177. package/dist/postgres-enum-type-DPKqCBem.mjs +0 -62
  178. package/dist/postgres-enum-type-DPKqCBem.mjs.map +0 -1
  179. package/dist/postgres-migration-COore9Mz.mjs +0 -71
  180. package/dist/postgres-migration-COore9Mz.mjs.map +0 -1
  181. package/dist/postgres-migration-DZ_gLUOW.d.mts +0 -72
  182. package/dist/postgres-migration-DZ_gLUOW.d.mts.map +0 -1
  183. package/dist/postgres-schema-BuxCxbvB.mjs.map +0 -1
  184. package/dist/render-ops-BpjstrKQ.mjs.map +0 -1
  185. package/dist/shared-DarONYBZ.d.mts +0 -43
  186. package/dist/shared-DarONYBZ.d.mts.map +0 -1
  187. package/src/core/migrations/enum-planning.ts +0 -213
  188. package/src/core/migrations/operations/enums.ts +0 -114
  189. package/src/core/postgres-enum-type.ts +0 -89
  190. package/src/exports/enum-planning.ts +0 -11
@@ -1,272 +0,0 @@
1
- import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
2
- import { i as postgresCreateNamespace } from "./postgres-schema-BuxCxbvB.mjs";
3
- import { t as resolveColumnTypeMetadata } from "./planner-type-resolution-836DExFN.mjs";
4
- //#region src/core/migrations/planner-sql-checks.ts
5
- /**
6
- * String-keyed entry points the migration ops use to render
7
- * schema-qualified DDL and catalog checks. The `schema` argument is
8
- * interpreted as a namespace coordinate: the framework `__unbound__`
9
- * sentinel resolves to the late-bound `PostgresUnboundSchema` singleton
10
- * (which elides the qualifier so `search_path` decides at runtime); any
11
- * other id materialises a `PostgresSchema(id)` whose qualifier is the
12
- * named schema. Helpers route through these `Namespace` concretions so
13
- * the unbound branch lives in the polymorphic override, not the call
14
- * site.
15
- */
16
- function qualifyTableName(schema, table) {
17
- return postgresCreateNamespace({
18
- id: schema,
19
- entries: { table: {} }
20
- }).qualifyTable(table);
21
- }
22
- function toRegclassLiteral(schema, name) {
23
- return postgresCreateNamespace({
24
- id: schema,
25
- entries: { table: {} }
26
- }).regclassLiteral(name);
27
- }
28
- /**
29
- * When `table` is omitted the check matches by name + schema across all tables.
30
- * Pass `table` to scope the check to a single table (prevents false matches on
31
- * identically-named constraints in different tables).
32
- */
33
- function constraintExistsCheck({ constraintName, schema, table, exists = true }) {
34
- const namespace = postgresCreateNamespace({
35
- id: schema,
36
- entries: { table: {} }
37
- });
38
- const existsClause = exists ? "EXISTS" : "NOT EXISTS";
39
- const tableFilter = table ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})` : "";
40
- return `SELECT ${existsClause} (
41
- SELECT 1 FROM pg_constraint c
42
- JOIN pg_namespace n ON c.connamespace = n.oid
43
- WHERE c.conname = '${escapeLiteral(constraintName)}'
44
- AND n.nspname = ${namespace.schemaSqlExpression()}
45
- ${tableFilter}
46
- )`;
47
- }
48
- function columnExistsCheck({ schema, table, column, exists = true }) {
49
- const namespace = postgresCreateNamespace({
50
- id: schema,
51
- entries: { table: {} }
52
- });
53
- return `SELECT ${exists ? "" : "NOT "}EXISTS (
54
- SELECT 1
55
- FROM information_schema.columns
56
- WHERE table_schema = ${namespace.schemaSqlExpression()}
57
- AND table_name = '${escapeLiteral(table)}'
58
- AND column_name = '${escapeLiteral(column)}'
59
- )`;
60
- }
61
- function columnNullabilityCheck({ schema, table, column, nullable }) {
62
- const namespace = postgresCreateNamespace({
63
- id: schema,
64
- entries: { table: {} }
65
- });
66
- const expected = nullable ? "YES" : "NO";
67
- return `SELECT EXISTS (
68
- SELECT 1
69
- FROM information_schema.columns
70
- WHERE table_schema = ${namespace.schemaSqlExpression()}
71
- AND table_name = '${escapeLiteral(table)}'
72
- AND column_name = '${escapeLiteral(column)}'
73
- AND is_nullable = '${expected}'
74
- )`;
75
- }
76
- function tableIsEmptyCheck(qualifiedTableName) {
77
- return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;
78
- }
79
- function columnHasNoDefaultCheck(opts) {
80
- return `SELECT NOT EXISTS (
81
- SELECT 1
82
- FROM information_schema.columns
83
- WHERE table_schema = ${postgresCreateNamespace({
84
- id: opts.schema,
85
- entries: { table: {} }
86
- }).schemaSqlExpression()}
87
- AND table_name = '${escapeLiteral(opts.table)}'
88
- AND column_name = '${escapeLiteral(opts.column)}'
89
- AND column_default IS NOT NULL
90
- )`;
91
- }
92
- const FORMAT_TYPE_DISPLAY = new Map([
93
- ["int2", "smallint"],
94
- ["int4", "integer"],
95
- ["int8", "bigint"],
96
- ["float4", "real"],
97
- ["float8", "double precision"],
98
- ["bool", "boolean"],
99
- ["timestamp", "timestamp without time zone"],
100
- ["timestamptz", "timestamp with time zone"],
101
- ["time", "time without time zone"],
102
- ["timetz", "time with time zone"]
103
- ]);
104
- const UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;
105
- const POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([
106
- "all",
107
- "analyse",
108
- "analyze",
109
- "and",
110
- "any",
111
- "array",
112
- "as",
113
- "asc",
114
- "asymmetric",
115
- "authorization",
116
- "between",
117
- "binary",
118
- "both",
119
- "case",
120
- "cast",
121
- "check",
122
- "collate",
123
- "column",
124
- "constraint",
125
- "create",
126
- "current_catalog",
127
- "current_date",
128
- "current_role",
129
- "current_time",
130
- "current_timestamp",
131
- "current_user",
132
- "default",
133
- "deferrable",
134
- "desc",
135
- "distinct",
136
- "do",
137
- "else",
138
- "end",
139
- "except",
140
- "false",
141
- "fetch",
142
- "for",
143
- "foreign",
144
- "freeze",
145
- "from",
146
- "full",
147
- "grant",
148
- "group",
149
- "having",
150
- "ilike",
151
- "in",
152
- "initially",
153
- "inner",
154
- "intersect",
155
- "into",
156
- "is",
157
- "isnull",
158
- "join",
159
- "lateral",
160
- "leading",
161
- "left",
162
- "like",
163
- "limit",
164
- "localtime",
165
- "localtimestamp",
166
- "natural",
167
- "not",
168
- "notnull",
169
- "null",
170
- "offset",
171
- "on",
172
- "only",
173
- "or",
174
- "order",
175
- "outer",
176
- "overlaps",
177
- "placing",
178
- "primary",
179
- "references",
180
- "right",
181
- "select",
182
- "session_user",
183
- "similar",
184
- "some",
185
- "symmetric",
186
- "table",
187
- "then",
188
- "to",
189
- "trailing",
190
- "true",
191
- "union",
192
- "unique",
193
- "user",
194
- "using",
195
- "variadic",
196
- "verbose",
197
- "when",
198
- "where",
199
- "window",
200
- "with"
201
- ]);
202
- function formatUserDefinedTypeName(identifier) {
203
- if (UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) && !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)) return identifier;
204
- return quoteIdentifier(identifier);
205
- }
206
- function buildExpectedFormatType(column, codecHooks, storageTypes = {}) {
207
- const resolved = resolveColumnTypeMetadata(column, storageTypes);
208
- if (resolved.typeParams && resolved.codecId) {
209
- const hooks = codecHooks.get(resolved.codecId);
210
- if (hooks?.expandNativeType) return hooks.expandNativeType({
211
- nativeType: resolved.nativeType,
212
- codecId: resolved.codecId,
213
- typeParams: resolved.typeParams
214
- });
215
- }
216
- if (column.typeRef) return formatUserDefinedTypeName(resolved.nativeType);
217
- return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;
218
- }
219
- function columnTypeCheck({ schema, table, column, expectedType }) {
220
- return `SELECT EXISTS (
221
- SELECT 1
222
- FROM pg_attribute a
223
- JOIN pg_class c ON c.oid = a.attrelid
224
- JOIN pg_namespace n ON n.oid = c.relnamespace
225
- WHERE n.nspname = ${postgresCreateNamespace({
226
- id: schema,
227
- entries: { table: {} }
228
- }).schemaSqlExpression()}
229
- AND c.relname = '${escapeLiteral(table)}'
230
- AND a.attname = '${escapeLiteral(column)}'
231
- AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'
232
- AND NOT a.attisdropped
233
- )`;
234
- }
235
- function columnDefaultExistsCheck({ schema, table, column, exists = true }) {
236
- const namespace = postgresCreateNamespace({
237
- id: schema,
238
- entries: { table: {} }
239
- });
240
- const nullCheck = exists ? "IS NOT NULL" : "IS NULL";
241
- return `SELECT EXISTS (
242
- SELECT 1
243
- FROM information_schema.columns
244
- WHERE table_schema = ${namespace.schemaSqlExpression()}
245
- AND table_name = '${escapeLiteral(table)}'
246
- AND column_name = '${escapeLiteral(column)}'
247
- AND column_default ${nullCheck}
248
- )`;
249
- }
250
- function tableHasPrimaryKeyCheck(schema, table, exists, constraintName) {
251
- const namespace = postgresCreateNamespace({
252
- id: schema,
253
- entries: { table: {} }
254
- });
255
- const comparison = exists ? "" : "NOT ";
256
- const constraintFilter = constraintName ? `AND c2.relname = '${escapeLiteral(constraintName)}'` : "";
257
- return `SELECT ${comparison}EXISTS (
258
- SELECT 1
259
- FROM pg_index i
260
- JOIN pg_class c ON c.oid = i.indrelid
261
- JOIN pg_namespace n ON n.oid = c.relnamespace
262
- LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid
263
- WHERE n.nspname = ${namespace.schemaSqlExpression()}
264
- AND c.relname = '${escapeLiteral(table)}'
265
- AND i.indisprimary
266
- ${constraintFilter}
267
- )`;
268
- }
269
- //#endregion
270
- export { columnNullabilityCheck as a, qualifyTableName as c, toRegclassLiteral as d, columnHasNoDefaultCheck as i, tableHasPrimaryKeyCheck as l, columnDefaultExistsCheck as n, columnTypeCheck as o, columnExistsCheck as r, constraintExistsCheck as s, buildExpectedFormatType as t, tableIsEmptyCheck as u };
271
-
272
- //# sourceMappingURL=planner-sql-checks-DAdhnI2c.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-sql-checks-DAdhnI2c.mjs","names":[],"sources":["../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { postgresCreateNamespace } from '../postgres-schema';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\n/**\n * String-keyed entry points the migration ops use to render\n * schema-qualified DDL and catalog checks. The `schema` argument is\n * interpreted as a namespace coordinate: the framework `__unbound__`\n * sentinel resolves to the late-bound `PostgresUnboundSchema` singleton\n * (which elides the qualifier so `search_path` decides at runtime); any\n * other id materialises a `PostgresSchema(id)` whose qualifier is the\n * named schema. Helpers route through these `Namespace` concretions so\n * the unbound branch lives in the polymorphic override, not the call\n * site.\n */\nexport function qualifyTableName(schema: string, table: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).qualifyTable(table);\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n return postgresCreateNamespace({ id: schema, entries: { table: {} } }).regclassLiteral(name);\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${namespace.regclassLiteral(table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = ${namespace.schemaSqlExpression()}\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: opts.schema, entries: { table: {} } });\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance | PostgresEnumStorageEntry> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = ${namespace.schemaSqlExpression()}\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const namespace = postgresCreateNamespace({ id: schema, entries: { table: {} } });\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = ${namespace.schemaSqlExpression()}\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":";;;;;;;;;;;;;;;AAqBA,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,aAAa,KAAK;AAC3F;AAEA,SAAgB,kBAAkB,QAAgB,MAAsB;CACtE,OAAO,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC,CAAC,CAAC,gBAAgB,IAAI;AAC7F;;;;;;AAOA,SAAgB,sBAAsB,EACpC,gBACA,QACA,OACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,eAAe,SAAS,WAAW;CACzC,MAAM,cAAc,QAChB,gCAAgC,UAAU,gBAAgB,KAAK,EAAE,KACjE;CACJ,OAAO,UAAU,aAAa;;;uBAGT,cAAc,cAAc,EAAE;oBACjC,UAAU,oBAAoB,EAAE;IAChD,YAAY;;AAEhB;AAEA,SAAgB,kBAAkB,EAChC,QACA,OACA,QACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAEhF,OAAO,UADc,SAAS,KAAK,OACL;;;yBAGP,UAAU,oBAAoB,EAAE;wBACjC,cAAc,KAAK,EAAE;yBACpB,cAAc,MAAM,EAAE;;AAE/C;AAEA,SAAgB,uBAAuB,EACrC,QACA,OACA,QACA,YAMS;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,WAAW,WAAW,QAAQ;CACpC,OAAO;;;yBAGgB,UAAU,oBAAoB,EAAE;wBACjC,cAAc,KAAK,EAAE;yBACpB,cAAc,MAAM,EAAE;yBACtB,SAAS;;AAElC;AAEA,SAAgB,kBAAkB,oBAAoC;CACpE,OAAO,oCAAoC,mBAAmB;AAChE;AAEA,SAAgB,wBAAwB,MAI7B;CAET,OAAO;;;yBADW,wBAAwB;EAAE,IAAI,KAAK;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAIrD,CAAC,CAAC,oBAAoB,EAAE;wBACjC,cAAc,KAAK,KAAK,EAAE;yBACzB,cAAc,KAAK,MAAM,EAAE;;;AAGpD;AAEA,MAAM,sBAAmD,IAAI,IAAI;CAC/D,CAAC,QAAQ,UAAU;CACnB,CAAC,QAAQ,SAAS;CAClB,CAAC,QAAQ,QAAQ;CACjB,CAAC,UAAU,MAAM;CACjB,CAAC,UAAU,kBAAkB;CAC7B,CAAC,QAAQ,SAAS;CAClB,CAAC,aAAa,6BAA6B;CAC3C,CAAC,eAAe,0BAA0B;CAC1C,CAAC,QAAQ,wBAAwB;CACjC,CAAC,UAAU,qBAAqB;AAClC,CAAC;AAED,MAAM,uCAAuC;AAE7C,MAAM,qCAAqC,IAAI,IAAI;CACjD;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;AAED,SAAS,0BAA0B,YAA4B;CAC7D,IACE,qCAAqC,KAAK,UAAU,KACpD,CAAC,mCAAmC,IAAI,UAAU,GAElD,OAAO;CAGT,OAAO,gBAAgB,UAAU;AACnC;AAEA,SAAgB,wBACd,QACA,YACA,eAA+E,CAAC,GACxE;CACR,MAAM,WAAW,0BAA0B,QAAQ,YAAY;CAE/D,IAAI,SAAS,cAAc,SAAS,SAAS;EAC3C,MAAM,QAAQ,WAAW,IAAI,SAAS,OAAO;EAC7C,IAAI,OAAO,kBACT,OAAO,MAAM,iBAAiB;GAC5B,YAAY,SAAS;GACrB,SAAS,SAAS;GAClB,YAAY,SAAS;EACvB,CAAC;CAEL;CAEA,IAAI,OAAO,SACT,OAAO,0BAA0B,SAAS,UAAU;CAGtD,OAAO,oBAAoB,IAAI,SAAS,UAAU,KAAK,SAAS;AAClE;AAEA,SAAgB,gBAAgB,EAC9B,QACA,OACA,QACA,gBAMS;CAET,OAAO;;;;;sBADW,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAMnD,CAAC,CAAC,oBAAoB,EAAE;uBAC/B,cAAc,KAAK,EAAE;uBACrB,cAAc,MAAM,EAAE;kDACK,cAAc,YAAY,EAAE;;;AAG9E;AAEA,SAAgB,yBAAyB,EACvC,QACA,OACA,QACA,SAAS,QAMA;CACT,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,YAAY,SAAS,gBAAgB;CAC3C,OAAO;;;yBAGgB,UAAU,oBAAoB,EAAE;wBACjC,cAAc,KAAK,EAAE;yBACpB,cAAc,MAAM,EAAE;yBACtB,UAAU;;AAEnC;AAEA,SAAgB,wBACd,QACA,OACA,QACA,gBACQ;CACR,MAAM,YAAY,wBAAwB;EAAE,IAAI;EAAQ,SAAS,EAAE,OAAO,CAAC,EAAE;CAAE,CAAC;CAChF,MAAM,aAAa,SAAS,KAAK;CACjC,MAAM,mBAAmB,iBACrB,qBAAqB,cAAc,cAAc,EAAE,KACnD;CACJ,OAAO,UAAU,WAAW;;;;;;sBAMR,UAAU,oBAAoB,EAAE;uBAC/B,cAAc,KAAK,EAAE;;MAEtC,iBAAiB;;AAEvB"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-type-resolution-836DExFN.mjs","names":[],"sources":["../src/core/migrations/planner-type-resolution.ts"],"sourcesContent":["import {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n type StorageColumn,\n type StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n if (isPostgresEnumStorageEntry(referencedType)) {\n // Enum types are referenced by name (`quoteIdentifier(nativeType)`),\n // not via parameterised codec expansion. The structural shape\n // carries `codecId` as an enumerable property (mirroring the\n // codec-typed view); `typeParams` is intentionally omitted here so\n // `expandParameterizedTypeSql` does not try to look up a\n // (deliberately absent) `expandNativeType` hook for `pg/enum@*`.\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n };\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n"],"mappings":";;AAYA,SAAgB,0BACd,QACA,cAC4B;CAC5B,IAAI,CAAC,OAAO,SACV,OAAO;CAGT,MAAM,iBAAiB,aAAa,OAAO;CAC3C,IAAI,CAAC,gBACH,OAAO;CAGT,IAAI,2BAA2B,cAAc,GAO3C,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;CAC7B;CAGF,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;EAC3B,YAAY,eAAe;CAC7B;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-contract-serializer-DYTyXjPf.mjs","names":["rawRecord"],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport {\n type AuthoringEntityContext,\n type AuthoringEntityTypeFactoryOutput,\n type AuthoringEntityTypeNamespace,\n isAuthoringEntityTypeDescriptor,\n} from '@prisma-next/framework-components/authoring';\nimport {\n type Namespace,\n NamespaceBase,\n UNBOUND_NAMESPACE_ID,\n} from '@prisma-next/framework-components/ir';\nimport type { SqlNamespaceTablesInput, SqlStorage } from '@prisma-next/sql-contract/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { JsonObject } from '@prisma-next/utils/json';\nimport type { Type } from 'arktype';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport type { PostgresEnumType } from './postgres-enum-type';\nimport { isPostgresSchema, PostgresSchema } from './postgres-schema';\n\nconst POSTGRES_AUTHORING_CTX: AuthoringEntityContext = {\n family: 'sql',\n target: 'postgres',\n};\n\nfunction isAuthoringEntityTypeFactoryOutput(\n output: unknown,\n): output is AuthoringEntityTypeFactoryOutput<unknown, unknown> {\n return (\n typeof output === 'object' &&\n output !== null &&\n typeof (output as AuthoringEntityTypeFactoryOutput).factory === 'function'\n );\n}\n\n/**\n * Walks a pack's entity-type namespace tree and emits the maps the\n * family base consumes — hydrators and validator-schema fragments, both\n * keyed by the descriptor's `discriminator`.\n */\nfunction collectEntityRegistryContributions(namespace: AuthoringEntityTypeNamespace): {\n readonly entityTypeRegistry: ReadonlyMap<string, SqlEntityHydrationFactory>;\n readonly validatorFragments: ReadonlyMap<string, Type<unknown>>;\n} {\n const entityTypeRegistry = new Map<string, SqlEntityHydrationFactory>();\n const validatorFragments = new Map<string, Type<unknown>>();\n const walk = (node: AuthoringEntityTypeNamespace): void => {\n for (const value of Object.values(node)) {\n if (isAuthoringEntityTypeDescriptor(value)) {\n if (isAuthoringEntityTypeFactoryOutput(value.output)) {\n const { factory } = value.output;\n entityTypeRegistry.set(value.discriminator, (raw) =>\n factory(raw, POSTGRES_AUTHORING_CTX),\n );\n }\n if (value.validatorSchema !== undefined) {\n validatorFragments.set(value.discriminator, value.validatorSchema);\n }\n continue;\n }\n if (typeof value === 'object' && value !== null) {\n walk(value);\n }\n }\n };\n walk(namespace);\n return { entityTypeRegistry, validatorFragments };\n}\n\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n const { entityTypeRegistry, validatorFragments } = collectEntityRegistryContributions(\n postgresAuthoringEntityTypes,\n );\n super(entityTypeRegistry, validatorFragments);\n }\n\n protected override hydrateSqlNamespaceEntry(\n nsId: string,\n raw: Namespace | Record<string, unknown>,\n ): Namespace | SqlNamespaceTablesInput {\n if (raw instanceof NamespaceBase) {\n return raw;\n }\n const hydrated = blindCast<\n SqlNamespaceTablesInput,\n 'super.hydrateSqlNamespaceEntry returns the tables form when raw is not a NamespaceBase'\n >(super.hydrateSqlNamespaceEntry(nsId, raw));\n const { id, entries } = hydrated;\n\n // Extract the postgres-specific `type` slot directly from raw input.\n // The family base handles the `table` slot; the postgres target owns `type`.\n const rawRecord = raw as Record<string, unknown>;\n const rawEntries = rawRecord['entries'];\n let typeSlot: Record<string, PostgresEnumType> | undefined;\n if (rawEntries !== null && typeof rawEntries === 'object' && !Array.isArray(rawEntries)) {\n const rawTypeSlot = (rawEntries as Record<string, unknown>)['type'];\n if (rawTypeSlot !== null && typeof rawTypeSlot === 'object' && !Array.isArray(rawTypeSlot)) {\n const enumFactory = this.entityTypeRegistry.get('postgres-enum');\n typeSlot = Object.fromEntries(\n Object.entries(rawTypeSlot as Record<string, unknown>).map(([name, entry]) => [\n name,\n blindCast<PostgresEnumType, 'postgres-enum factory returns PostgresEnumType'>(\n enumFactory !== undefined ? enumFactory(entry) : entry,\n ),\n ]),\n );\n }\n }\n\n const emptyTables = Object.keys(entries.table).length === 0;\n const emptyTypes = !typeSlot || Object.keys(typeSlot).length === 0;\n if (id === UNBOUND_NAMESPACE_ID && emptyTables && emptyTypes) {\n return PostgresSchema.unbound;\n }\n return new PostgresSchema({\n id,\n entries: {\n table: entries.table,\n type: typeSlot ?? {},\n },\n });\n }\n\n override serializeContract(contract: Contract<SqlStorage>): JsonObject {\n const { storage, ...rest } = contract;\n const namespacesJson: Record<string, JsonObject> = {};\n for (const [nsId, ns] of Object.entries(storage.namespaces)) {\n if (isPostgresSchema(ns)) {\n namespacesJson[nsId] = this.serializePostgresNamespace(ns, ns.id === UNBOUND_NAMESPACE_ID);\n } else {\n const isUnboundSlot = nsId === UNBOUND_NAMESPACE_ID;\n namespacesJson[nsId] = {\n id: nsId,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: Object.fromEntries(\n Object.entries(ns.entries.table).map(([tableName, table]) => [\n tableName,\n this.serializeJsonValue(table) as JsonObject,\n ]),\n ),\n },\n };\n }\n }\n const storageOut: Record<string, unknown> = {\n storageHash: String(storage.storageHash),\n namespaces: namespacesJson,\n };\n if (storage.types !== undefined) {\n const typesOut: Record<string, JsonObject> = {};\n for (const [name, entry] of Object.entries(storage.types)) {\n typesOut[name] = this.serializeJsonValue(entry) as JsonObject;\n }\n storageOut['types'] = typesOut;\n }\n return {\n ...rest,\n storage: storageOut,\n } as unknown as JsonObject;\n }\n\n private serializePostgresNamespace(ns: PostgresSchema, isUnboundSlot: boolean): JsonObject {\n const tablesOut: Record<string, JsonObject> = {};\n for (const [tableName, table] of Object.entries(ns.entries.table)) {\n tablesOut[tableName] = this.serializeJsonValue(table) as JsonObject;\n }\n const typeOut: Record<string, JsonObject> = {};\n for (const [typeName, ty] of Object.entries(ns.entries.type)) {\n typeOut[typeName] = this.serializeJsonValue(ty) as JsonObject;\n }\n return {\n id: ns.id,\n kind: isUnboundSlot ? 'postgres-unbound-schema' : 'postgres-schema',\n entries: {\n table: tablesOut,\n type: typeOut,\n },\n };\n }\n\n private serializeJsonValue(value: unknown): unknown {\n return JSON.parse(JSON.stringify(value)) as unknown;\n }\n}\n"],"mappings":";;;;;;;AAwBA,MAAM,yBAAiD;CACrD,QAAQ;CACR,QAAQ;AACV;AAEA,SAAS,mCACP,QAC8D;CAC9D,OACE,OAAO,WAAW,YAClB,WAAW,QACX,OAAQ,OAA4C,YAAY;AAEpE;;;;;;AAOA,SAAS,mCAAmC,WAG1C;CACA,MAAM,qCAAqB,IAAI,IAAuC;CACtE,MAAM,qCAAqB,IAAI,IAA2B;CAC1D,MAAM,QAAQ,SAA6C;EACzD,KAAK,MAAM,SAAS,OAAO,OAAO,IAAI,GAAG;GACvC,IAAI,gCAAgC,KAAK,GAAG;IAC1C,IAAI,mCAAmC,MAAM,MAAM,GAAG;KACpD,MAAM,EAAE,YAAY,MAAM;KAC1B,mBAAmB,IAAI,MAAM,gBAAgB,QAC3C,QAAQ,KAAK,sBAAsB,CACrC;IACF;IACA,IAAI,MAAM,oBAAoB,KAAA,GAC5B,mBAAmB,IAAI,MAAM,eAAe,MAAM,eAAe;IAEnE;GACF;GACA,IAAI,OAAO,UAAU,YAAY,UAAU,MACzC,KAAK,KAAK;EAEd;CACF;CACA,KAAK,SAAS;CACd,OAAO;EAAE;EAAoB;CAAmB;AAClD;AAEA,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,cAAc;EACZ,MAAM,EAAE,oBAAoB,uBAAuB,mCACjD,4BACF;EACA,MAAM,oBAAoB,kBAAkB;CAC9C;CAEA,yBACE,MACA,KACqC;EACrC,IAAI,eAAe,eACjB,OAAO;EAMT,MAAM,EAAE,IAAI,YAJK,UAGf,MAAM,yBAAyB,MAAM,GAAG,CACX;EAK/B,MAAM,aAAaA,IAAU;EAC7B,IAAI;EACJ,IAAI,eAAe,QAAQ,OAAO,eAAe,YAAY,CAAC,MAAM,QAAQ,UAAU,GAAG;GACvF,MAAM,cAAe,WAAuC;GAC5D,IAAI,gBAAgB,QAAQ,OAAO,gBAAgB,YAAY,CAAC,MAAM,QAAQ,WAAW,GAAG;IAC1F,MAAM,cAAc,KAAK,mBAAmB,IAAI,eAAe;IAC/D,WAAW,OAAO,YAChB,OAAO,QAAQ,WAAsC,CAAC,CAAC,KAAK,CAAC,MAAM,WAAW,CAC5E,MACA,UACE,gBAAgB,KAAA,IAAY,YAAY,KAAK,IAAI,KACnD,CACF,CAAC,CACH;GACF;EACF;EAEA,MAAM,cAAc,OAAO,KAAK,QAAQ,KAAK,CAAC,CAAC,WAAW;EAC1D,MAAM,aAAa,CAAC,YAAY,OAAO,KAAK,QAAQ,CAAC,CAAC,WAAW;EACjE,IAAI,OAAO,wBAAwB,eAAe,YAChD,OAAO,eAAe;EAExB,OAAO,IAAI,eAAe;GACxB;GACA,SAAS;IACP,OAAO,QAAQ;IACf,MAAM,YAAY,CAAC;GACrB;EACF,CAAC;CACH;CAEA,kBAA2B,UAA4C;EACrE,MAAM,EAAE,SAAS,GAAG,SAAS;EAC7B,MAAM,iBAA6C,CAAC;EACpD,KAAK,MAAM,CAAC,MAAM,OAAO,OAAO,QAAQ,QAAQ,UAAU,GACxD,IAAI,iBAAiB,EAAE,GACrB,eAAe,QAAQ,KAAK,2BAA2B,IAAI,GAAG,OAAO,oBAAoB;OAGzF,eAAe,QAAQ;GACrB,IAAI;GACJ,MAHoB,SAAS,uBAGP,4BAA4B;GAClD,SAAS,EACP,OAAO,OAAO,YACZ,OAAO,QAAQ,GAAG,QAAQ,KAAK,CAAC,CAAC,KAAK,CAAC,WAAW,WAAW,CAC3D,WACA,KAAK,mBAAmB,KAAK,CAC/B,CAAC,CACH,EACF;EACF;EAGJ,MAAM,aAAsC;GAC1C,aAAa,OAAO,QAAQ,WAAW;GACvC,YAAY;EACd;EACA,IAAI,QAAQ,UAAU,KAAA,GAAW;GAC/B,MAAM,WAAuC,CAAC;GAC9C,KAAK,MAAM,CAAC,MAAM,UAAU,OAAO,QAAQ,QAAQ,KAAK,GACtD,SAAS,QAAQ,KAAK,mBAAmB,KAAK;GAEhD,WAAW,WAAW;EACxB;EACA,OAAO;GACL,GAAG;GACH,SAAS;EACX;CACF;CAEA,2BAAmC,IAAoB,eAAoC;EACzF,MAAM,YAAwC,CAAC;EAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,GAAG,QAAQ,KAAK,GAC9D,UAAU,aAAa,KAAK,mBAAmB,KAAK;EAEtD,MAAM,UAAsC,CAAC;EAC7C,KAAK,MAAM,CAAC,UAAU,OAAO,OAAO,QAAQ,GAAG,QAAQ,IAAI,GACzD,QAAQ,YAAY,KAAK,mBAAmB,EAAE;EAEhD,OAAO;GACL,IAAI,GAAG;GACP,MAAM,gBAAgB,4BAA4B;GAClD,SAAS;IACP,OAAO;IACP,MAAM;GACR;EACF;CACF;CAEA,mBAA2B,OAAyB;EAClD,OAAO,KAAK,MAAM,KAAK,UAAU,KAAK,CAAC;CACzC;AACF"}
@@ -1,72 +0,0 @@
1
- import { SqlNode } from "@prisma-next/sql-contract/types";
2
- import { ControlPolicy } from "@prisma-next/contract/types";
3
-
4
- //#region src/core/postgres-enum-type.d.ts
5
- interface PostgresEnumTypeInput<TName extends string = string, TValues extends readonly string[] = readonly string[]> {
6
- /**
7
- * Contract-level enum name (e.g. `'Role'`). Used as the key in
8
- * `SqlStorage.types` and as the contract-facing identifier in
9
- * planner / verifier diagnostics.
10
- */
11
- readonly name: TName;
12
- /**
13
- * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.
14
- * Defaults to `name` when not overridden via PSL `@map(...)` or the
15
- * TS authoring surface.
16
- */
17
- readonly nativeType?: string;
18
- readonly values: TValues;
19
- readonly control?: ControlPolicy;
20
- }
21
- /** Codec id used by Postgres enum-typed columns (text wire format). */
22
- declare const PG_ENUM_CODEC_ID = "pg/enum@1";
23
- /**
24
- * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.
25
- *
26
- * Per Decision 18, enum is a target-only concept (Postgres alone today;
27
- * SQLite emulates via CHECK constraints). There is no family-layer
28
- * enum abstract — the abstract-earns-existence rule keeps the IR class
29
- * hierarchy minimal: this class extends `SqlNode` directly and is the
30
- * single concrete representation of the polymorphic `'postgres-enum'`
31
- * slot variant.
32
- *
33
- * Carries Postgres-specific resolution (`nativeType` defaults to
34
- * `name`; `values` is frozen at construction time). Constructor calls
35
- * `freezeNode(this)` per Decision 8 — the instance is fully immutable,
36
- * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`
37
- * literal.
38
- *
39
- * The family-layer slot dispatch (verifier, planner, lowering, etc.)
40
- * narrows polymorphic `StorageType` entries via the `kind` literal
41
- * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import
42
- * `target-postgres` directly (cross-domain layering rule). The
43
- * structural interface lives at the family layer for that purpose;
44
- * this class is the runtime concrete that satisfies it.
45
- */
46
- declare class PostgresEnumType<TName extends string = string, TValues extends readonly string[] = readonly string[]> extends SqlNode {
47
- readonly kind: "postgres-enum";
48
- readonly name: TName;
49
- readonly nativeType: string;
50
- readonly values: TValues;
51
- /**
52
- * Enumerable own property so the persisted JSON envelope carries
53
- * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The
54
- * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)
55
- * receives JSON-shaped contracts (e.g. inside a user-written
56
- * `migration.ts` that loads `endContract` from `end-contract.json`)
57
- * and reads `codecId` directly from the envelope rather than
58
- * dispatching through the prototype-only `codecBinding` accessor.
59
- */
60
- readonly codecId: typeof PG_ENUM_CODEC_ID;
61
- readonly control?: ControlPolicy;
62
- constructor(input: PostgresEnumTypeInput<TName, TValues>);
63
- get codecBinding(): {
64
- readonly codecId: typeof PG_ENUM_CODEC_ID;
65
- readonly typeParams: {
66
- readonly values: TValues;
67
- };
68
- };
69
- }
70
- //#endregion
71
- export { PostgresEnumTypeInput as n, PostgresEnumType as t };
72
- //# sourceMappingURL=postgres-enum-type-BVn63a89.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-enum-type-BVn63a89.d.mts","names":[],"sources":["../src/core/postgres-enum-type.ts"],"mappings":";;;;UAIiB,qBAAA;;AAAjB;;;;WASW,IAAA,EAAM,KAAA;EAQI;;;;;EAAA,SAFV,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAAA,SACR,OAAA,GAAU,aAAA;AAAA;;cAIf,gBAAA;;;AAJ4B;AACjC;;;;AAGqB;AAyBtB;;;;;;;;;;;;;;;cAAa,gBAAA,+FAGH,OAAA;EAAA,SACU,IAAA;EAAA,SACT,IAAA,EAAM,KAAA;EAAA,SACN,UAAA;EAAA,SACA,MAAA,EAAQ,OAAA;EAFF;;;;;;;;;EAAA,SAYN,OAAA,SAAgB,gBAAA;EAAA,SACR,OAAA,GAAU,aAAA;cAEf,KAAA,EAAO,qBAAA,CAAsB,KAAA,EAAO,OAAA;EAAA,IAY5C,YAAA;IAAA,SACO,OAAA,SAAgB,gBAAA;IAAA,SAChB,UAAA;MAAA,SAAuB,MAAA,EAAQ,OAAA;IAAA;EAAA;AAAA"}
@@ -1,62 +0,0 @@
1
- import { freezeNode } from "@prisma-next/framework-components/ir";
2
- import { SqlNode } from "@prisma-next/sql-contract/types";
3
- //#region src/core/postgres-enum-type.ts
4
- /** Codec id used by Postgres enum-typed columns (text wire format). */
5
- const PG_ENUM_CODEC_ID = "pg/enum@1";
6
- /**
7
- * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.
8
- *
9
- * Per Decision 18, enum is a target-only concept (Postgres alone today;
10
- * SQLite emulates via CHECK constraints). There is no family-layer
11
- * enum abstract — the abstract-earns-existence rule keeps the IR class
12
- * hierarchy minimal: this class extends `SqlNode` directly and is the
13
- * single concrete representation of the polymorphic `'postgres-enum'`
14
- * slot variant.
15
- *
16
- * Carries Postgres-specific resolution (`nativeType` defaults to
17
- * `name`; `values` is frozen at construction time). Constructor calls
18
- * `freezeNode(this)` per Decision 8 — the instance is fully immutable,
19
- * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`
20
- * literal.
21
- *
22
- * The family-layer slot dispatch (verifier, planner, lowering, etc.)
23
- * narrows polymorphic `StorageType` entries via the `kind` literal
24
- * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import
25
- * `target-postgres` directly (cross-domain layering rule). The
26
- * structural interface lives at the family layer for that purpose;
27
- * this class is the runtime concrete that satisfies it.
28
- */
29
- var PostgresEnumType = class extends SqlNode {
30
- kind = "postgres-enum";
31
- name;
32
- nativeType;
33
- values;
34
- /**
35
- * Enumerable own property so the persisted JSON envelope carries
36
- * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The
37
- * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)
38
- * receives JSON-shaped contracts (e.g. inside a user-written
39
- * `migration.ts` that loads `endContract` from `end-contract.json`)
40
- * and reads `codecId` directly from the envelope rather than
41
- * dispatching through the prototype-only `codecBinding` accessor.
42
- */
43
- codecId = PG_ENUM_CODEC_ID;
44
- constructor(input) {
45
- super();
46
- this.name = input.name;
47
- this.nativeType = input.nativeType ?? input.name;
48
- this.values = Object.freeze([...input.values]);
49
- if (input.control !== void 0) this.control = input.control;
50
- freezeNode(this);
51
- }
52
- get codecBinding() {
53
- return {
54
- codecId: PG_ENUM_CODEC_ID,
55
- typeParams: { values: this.values }
56
- };
57
- }
58
- };
59
- //#endregion
60
- export { PostgresEnumType as t };
61
-
62
- //# sourceMappingURL=postgres-enum-type-DPKqCBem.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-enum-type-DPKqCBem.mjs","names":[],"sources":["../src/core/postgres-enum-type.ts"],"sourcesContent":["import type { ControlPolicy } from '@prisma-next/contract/types';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { SqlNode } from '@prisma-next/sql-contract/types';\n\nexport interface PostgresEnumTypeInput<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> {\n /**\n * Contract-level enum name (e.g. `'Role'`). Used as the key in\n * `SqlStorage.types` and as the contract-facing identifier in\n * planner / verifier diagnostics.\n */\n readonly name: TName;\n /**\n * Postgres-side native type name created by `CREATE TYPE … AS ENUM`.\n * Defaults to `name` when not overridden via PSL `@map(...)` or the\n * TS authoring surface.\n */\n readonly nativeType?: string;\n readonly values: TValues;\n readonly control?: ControlPolicy;\n}\n\n/** Codec id used by Postgres enum-typed columns (text wire format). */\nconst PG_ENUM_CODEC_ID = 'pg/enum@1';\n\n/**\n * Postgres IR class for the `CREATE TYPE … AS ENUM` concept.\n *\n * Per Decision 18, enum is a target-only concept (Postgres alone today;\n * SQLite emulates via CHECK constraints). There is no family-layer\n * enum abstract — the abstract-earns-existence rule keeps the IR class\n * hierarchy minimal: this class extends `SqlNode` directly and is the\n * single concrete representation of the polymorphic `'postgres-enum'`\n * slot variant.\n *\n * Carries Postgres-specific resolution (`nativeType` defaults to\n * `name`; `values` is frozen at construction time). Constructor calls\n * `freezeNode(this)` per Decision 8 — the instance is fully immutable,\n * JSON-clean, and dispatchable on its enumerable `kind: 'postgres-enum'`\n * literal.\n *\n * The family-layer slot dispatch (verifier, planner, lowering, etc.)\n * narrows polymorphic `StorageType` entries via the `kind` literal\n * (e.g. `isPostgresEnumStorageEntry`) — SQL-domain code must not import\n * `target-postgres` directly (cross-domain layering rule). The\n * structural interface lives at the family layer for that purpose;\n * this class is the runtime concrete that satisfies it.\n */\nexport class PostgresEnumType<\n TName extends string = string,\n TValues extends readonly string[] = readonly string[],\n> extends SqlNode {\n override readonly kind = 'postgres-enum' as const;\n readonly name: TName;\n readonly nativeType: string;\n readonly values: TValues;\n /**\n * Enumerable own property so the persisted JSON envelope carries\n * `codecId: 'pg/enum@1'` alongside `kind: 'postgres-enum'`. The\n * runtime path (`codecRefForStorageColumn`, `assertColumnCodecIntegrity`)\n * receives JSON-shaped contracts (e.g. inside a user-written\n * `migration.ts` that loads `endContract` from `end-contract.json`)\n * and reads `codecId` directly from the envelope rather than\n * dispatching through the prototype-only `codecBinding` accessor.\n */\n readonly codecId: typeof PG_ENUM_CODEC_ID = PG_ENUM_CODEC_ID;\n declare readonly control?: ControlPolicy;\n\n constructor(input: PostgresEnumTypeInput<TName, TValues>) {\n super();\n this.name = input.name;\n this.nativeType = input.nativeType ?? input.name;\n // `Object.freeze` returns `Readonly<string[]>`, widening past the\n // `TValues` literal tuple. Cast preserves the caller-supplied\n // tuple shape so inferred contract types retain literal narrowing.\n this.values = Object.freeze([...input.values] as unknown as TValues);\n if (input.control !== undefined) this.control = input.control;\n freezeNode(this);\n }\n\n get codecBinding(): {\n readonly codecId: typeof PG_ENUM_CODEC_ID;\n readonly typeParams: { readonly values: TValues };\n } {\n return { codecId: PG_ENUM_CODEC_ID, typeParams: { values: this.values } };\n }\n}\n"],"mappings":";;;;AAyBA,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;AAyBzB,IAAa,mBAAb,cAGU,QAAQ;CAChB,OAAyB;CACzB;CACA;CACA;;;;;;;;;;CAUA,UAA4C;CAG5C,YAAY,OAA8C;EACxD,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,aAAa,MAAM,cAAc,MAAM;EAI5C,KAAK,SAAS,OAAO,OAAO,CAAC,GAAG,MAAM,MAAM,CAAuB;EACnE,IAAI,MAAM,YAAY,KAAA,GAAW,KAAK,UAAU,MAAM;EACtD,WAAW,IAAI;CACjB;CAEA,IAAI,eAGF;EACA,OAAO;GAAE,SAAS;GAAkB,YAAY,EAAE,QAAQ,KAAK,OAAO;EAAE;CAC1E;AACF"}
@@ -1,71 +0,0 @@
1
- import { d as CreateSchemaCall, f as CreateTableCall } from "./op-factory-call-D2aAUhmS.mjs";
2
- import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
3
- import { t as dataTransform } from "./data-transform-D25tLeYU.mjs";
4
- import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
5
- import { Migration } from "@prisma-next/family-sql/migration";
6
- //#region src/core/migrations/postgres-migration.ts
7
- /**
8
- * Target-owned base class for Postgres migrations.
9
- *
10
- * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
11
- * abstract `targetId` to the Postgres target-id string literal, so both
12
- * user-authored migrations and renderer-generated scaffolds (the output of
13
- * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
14
- * redeclaring target-local identity.
15
- *
16
- * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
17
- * emits `extends Migration` against a facade re-export of this class
18
- * from `@prisma-next/postgres/migration`, keeping the authoring surface
19
- * target-scoped rather than family-scoped.
20
- *
21
- * The constructor materializes a single Postgres `SqlControlAdapter` from
22
- * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
23
- * instance method forwards to the free `dataTransform` factory with that
24
- * stored adapter, so user migrations can write `this.dataTransform(...)`
25
- * without threading the adapter through every call.
26
- */
27
- var PostgresMigration = class extends Migration {
28
- targetId = "postgres";
29
- /**
30
- * Materialized Postgres control adapter, created once per migration
31
- * instance from the injected stack. `undefined` only when the migration
32
- * was instantiated without a stack (test fixtures); `dataTransform`
33
- * throws in that case to surface the misuse.
34
- */
35
- controlAdapter;
36
- constructor(stack) {
37
- super(stack);
38
- this.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;
39
- }
40
- /**
41
- * Instance-method wrapper around the free `dataTransform` factory that
42
- * supplies the stored control adapter. Authors call this from inside
43
- * `get operations()`; the adapter argument is hidden from the call site.
44
- */
45
- dataTransform(contract, name, options) {
46
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
47
- return dataTransform(contract, name, options, this.controlAdapter);
48
- }
49
- /**
50
- * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
51
- * the supplied options and lowers it through the stored control adapter.
52
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
53
- */
54
- createTable(options) {
55
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
56
- return new CreateTableCall(options.schema ?? UNBOUND_NAMESPACE_ID, options.table, options.columns, options.constraints).toOp(this.controlAdapter);
57
- }
58
- /**
59
- * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
60
- * the supplied options and lowers it through the stored control adapter.
61
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
62
- */
63
- createSchema(options) {
64
- if (!this.controlAdapter) throw errorPostgresMigrationStackMissing();
65
- return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);
66
- }
67
- };
68
- //#endregion
69
- export { PostgresMigration as t };
70
-
71
- //# sourceMappingURL=postgres-migration-COore9Mz.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-migration-COore9Mz.mjs","names":["SqlMigration"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { CreateSchemaCall, CreateTableCall } from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n */\nexport abstract class PostgresMigration extends SqlMigration<\n PostgresPlanTargetDetails,\n 'postgres'\n> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `dataTransform`\n * throws in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return dataTransform(contract, name, options, this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema?: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateTableCall(\n options.schema ?? UNBOUND_NAMESPACE_ID,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapter);\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing();\n }\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapter);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAsB,oBAAtB,cAAgDA,UAG9C;CACA,WAAoB;;;;;;;CAQpB;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,cACE,UACA,MACA,SACsD;EACtD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,cAAc;CACnE;;;;;;CAOA,YAAsB,SAMmC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,gBACT,QAAQ,UAAU,sBAClB,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,cAAc;CAC5B;;;;;;CAOA,aAAuB,SAGkC;EACvD,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC;EAE3C,OAAO,IAAI,iBAAiB,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,cAAc;CACtE;AACF"}
@@ -1,72 +0,0 @@
1
- import { t as PostgresPlanTargetDetails } from "./planner-target-details-CIY6tLeo.mjs";
2
- import { n as DataTransformOptions } from "./data-transform-DGOqcLrf.mjs";
3
- import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
4
- import { SqlMigrationPlanOperation } from "@prisma-next/family-sql/control";
5
- import { SqlStorage } from "@prisma-next/sql-contract/types";
6
- import { Migration } from "@prisma-next/family-sql/migration";
7
- import { ControlStack } from "@prisma-next/framework-components/control";
8
- import { Contract } from "@prisma-next/contract/types";
9
- import { SqlControlAdapter } from "@prisma-next/family-sql/control-adapter";
10
-
11
- //#region src/core/migrations/postgres-migration.d.ts
12
- /**
13
- * Target-owned base class for Postgres migrations.
14
- *
15
- * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the
16
- * abstract `targetId` to the Postgres target-id string literal, so both
17
- * user-authored migrations and renderer-generated scaffolds (the output of
18
- * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without
19
- * redeclaring target-local identity.
20
- *
21
- * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer
22
- * emits `extends Migration` against a facade re-export of this class
23
- * from `@prisma-next/postgres/migration`, keeping the authoring surface
24
- * target-scoped rather than family-scoped.
25
- *
26
- * The constructor materializes a single Postgres `SqlControlAdapter` from
27
- * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`
28
- * instance method forwards to the free `dataTransform` factory with that
29
- * stored adapter, so user migrations can write `this.dataTransform(...)`
30
- * without threading the adapter through every call.
31
- */
32
- declare abstract class PostgresMigration extends Migration<PostgresPlanTargetDetails, 'postgres'> {
33
- readonly targetId: "postgres";
34
- /**
35
- * Materialized Postgres control adapter, created once per migration
36
- * instance from the injected stack. `undefined` only when the migration
37
- * was instantiated without a stack (test fixtures); `dataTransform`
38
- * throws in that case to surface the misuse.
39
- */
40
- protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;
41
- constructor(stack?: ControlStack<'sql', 'postgres'>);
42
- /**
43
- * Instance-method wrapper around the free `dataTransform` factory that
44
- * supplies the stored control adapter. Authors call this from inside
45
- * `get operations()`; the adapter argument is hidden from the call site.
46
- */
47
- protected dataTransform<TContract extends Contract<SqlStorage>>(contract: TContract, name: string, options: DataTransformOptions): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
48
- /**
49
- * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from
50
- * the supplied options and lowers it through the stored control adapter.
51
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
52
- */
53
- protected createTable(options: {
54
- readonly schema?: string;
55
- readonly table: string;
56
- readonly ifNotExists?: boolean;
57
- readonly columns: readonly DdlColumn[];
58
- readonly constraints?: readonly DdlTableConstraint[];
59
- }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
60
- /**
61
- * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from
62
- * the supplied options and lowers it through the stored control adapter.
63
- * Throws if no adapter is present (i.e. migration instantiated without a stack).
64
- */
65
- protected createSchema(options: {
66
- readonly schema: string;
67
- readonly ifNotExists?: boolean;
68
- }): SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
69
- }
70
- //#endregion
71
- export { PostgresMigration as t };
72
- //# sourceMappingURL=postgres-migration-DZ_gLUOW.d.mts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-migration-DZ_gLUOW.d.mts","names":[],"sources":["../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;AAiCA;;;;;;;;;;;;;;;;;;uBAAsB,iBAAA,SAA0B,SAAA,CAC9C,yBAAA;EAAA,SAGS,QAAA;EAJiD;;;;;;EAAA,mBAYvC,cAAA,EAAgB,iBAAA;cAEvB,KAAA,GAAQ,YAAA;EAAR;;;;;EAAA,UAeF,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,yBAAA,CAA0B,yBAAA;EAH3B;;;;;EAAA,UAeQ,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,yBAAA,CAA0B,yBAAA;EADnB;;;;;EAAA,UAkBD,YAAA,CAAa,OAAA;IAAA,SACZ,MAAA;IAAA,SACA,WAAA;EAAA,IACP,yBAAA,CAA0B,yBAAA;AAAA"}