@prisma-next/target-postgres 0.12.0 → 0.13.0-dev.1

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 (207) hide show
  1. package/dist/{codec-ids-D9fJ4HP5.d.mts → codec-ids-B1vOchLE.d.mts} +3 -2
  2. package/dist/codec-ids-B1vOchLE.d.mts.map +1 -0
  3. package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-CTikp1if.mjs} +3 -2
  4. package/dist/codec-ids-CTikp1if.mjs.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-CRlHq7Cz.d.mts → codec-types-CnFiNML4.d.mts} +8 -9
  8. package/dist/codec-types-CnFiNML4.d.mts.map +1 -0
  9. package/dist/codec-types.d.mts +2 -2
  10. package/dist/{codecs-Dud5KDNk.d.mts → codecs-CBpEv4s5.d.mts} +33 -35
  11. package/dist/codecs-CBpEv4s5.d.mts.map +1 -0
  12. package/dist/codecs.d.mts +1 -1
  13. package/dist/codecs.mjs +37 -2
  14. package/dist/codecs.mjs.map +1 -1
  15. package/dist/contract-free.d.mts +80 -0
  16. package/dist/contract-free.d.mts.map +1 -0
  17. package/dist/contract-free.mjs +117 -0
  18. package/dist/contract-free.mjs.map +1 -0
  19. package/dist/control.d.mts +1 -1
  20. package/dist/control.d.mts.map +1 -1
  21. package/dist/control.mjs +66 -40
  22. package/dist/control.mjs.map +1 -1
  23. package/dist/{data-transform-CdtGUWp2.mjs → data-transform-D25tLeYU.mjs} +1 -1
  24. package/dist/{data-transform-CdtGUWp2.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
  25. package/dist/{data-transform-bmOKkygi.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
  26. package/dist/{data-transform-bmOKkygi.d.mts.map → data-transform-DGOqcLrf.d.mts.map} +1 -1
  27. package/dist/data-transform.d.mts +1 -1
  28. package/dist/data-transform.mjs +1 -1
  29. package/dist/ddl-77SyXgFt.mjs +30 -0
  30. package/dist/ddl-77SyXgFt.mjs.map +1 -0
  31. package/dist/ddl.d.mts +2 -0
  32. package/dist/ddl.mjs +2 -0
  33. package/dist/{default-normalizer-CRscvhS5.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
  34. package/dist/{default-normalizer-CRscvhS5.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
  35. package/dist/default-normalizer.mjs +1 -1
  36. package/dist/descriptor-meta-DKmj-IMN.mjs +14 -0
  37. package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
  38. package/dist/{descriptor-meta-DLA2xV6B.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +82 -78
  39. package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +1 -0
  40. package/dist/{enum-planning-Dz0Ye3Lb.mjs → enum-planning-BCyvlFHk.mjs} +0 -0
  41. package/dist/{enum-planning-Dz0Ye3Lb.mjs.map → enum-planning-BCyvlFHk.mjs.map} +1 -1
  42. package/dist/enum-planning.d.mts +1 -1
  43. package/dist/enum-planning.mjs +1 -1
  44. package/dist/{errors--zafB5_n.mjs → errors-CUk87ByX.mjs} +1 -1
  45. package/dist/{errors--zafB5_n.mjs.map → errors-CUk87ByX.mjs.map} +1 -1
  46. package/dist/errors.d.mts.map +1 -1
  47. package/dist/errors.mjs +1 -1
  48. package/dist/{issue-planner-ByQhUzS4.mjs → issue-planner-Br0pt1Ea.mjs} +130 -28
  49. package/dist/issue-planner-Br0pt1Ea.mjs.map +1 -0
  50. package/dist/issue-planner.d.mts +1 -1
  51. package/dist/issue-planner.d.mts.map +1 -1
  52. package/dist/issue-planner.mjs +1 -1
  53. package/dist/migration.d.mts +7 -8
  54. package/dist/migration.d.mts.map +1 -1
  55. package/dist/migration.mjs +5 -4
  56. package/dist/migration.mjs.map +1 -1
  57. package/dist/{native-type-normalizer-ClNPq__-.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
  58. package/dist/{native-type-normalizer-ClNPq__-.mjs.map → native-type-normalizer-Bc9XJzWC.mjs.map} +1 -1
  59. package/dist/native-type-normalizer.mjs +1 -1
  60. package/dist/nodes-779hmCfL.d.mts +40 -0
  61. package/dist/nodes-779hmCfL.d.mts.map +1 -0
  62. package/dist/nodes-DZk2JZG3.mjs +47 -0
  63. package/dist/nodes-DZk2JZG3.mjs.map +1 -0
  64. package/dist/op-factory-call-D2aAUhmS.mjs +1307 -0
  65. package/dist/op-factory-call-D2aAUhmS.mjs.map +1 -0
  66. package/dist/{op-factory-call-Drccm_JD.d.mts → op-factory-call-DMA86_2D.d.mts} +39 -14
  67. package/dist/op-factory-call-DMA86_2D.d.mts.map +1 -0
  68. package/dist/op-factory-call.d.mts +2 -2
  69. package/dist/op-factory-call.mjs +2 -2
  70. package/dist/pack.d.mts +13 -12
  71. package/dist/pack.d.mts.map +1 -1
  72. package/dist/pack.mjs +1 -1
  73. package/dist/planner-CAYPJObw.mjs +344 -0
  74. package/dist/planner-CAYPJObw.mjs.map +1 -0
  75. package/dist/{planner-ddl-builders-BxRCSn_b.mjs → planner-ddl-builders-Cw2n2llW.mjs} +7 -30
  76. package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +1 -0
  77. package/dist/planner-ddl-builders.d.mts +6 -7
  78. package/dist/planner-ddl-builders.d.mts.map +1 -1
  79. package/dist/planner-ddl-builders.mjs +2 -2
  80. package/dist/{planner-identity-values-ojX-6cPV.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
  81. package/dist/{planner-identity-values-ojX-6cPV.mjs.map → planner-identity-values-BIpa5p2I.mjs.map} +1 -1
  82. package/dist/planner-identity-values.mjs +1 -1
  83. package/dist/{planner-produced-postgres-migration-p-VKkCia.d.mts → planner-produced-postgres-migration-B4EDvLdz.d.mts} +5 -4
  84. package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +1 -0
  85. package/dist/{planner-produced-postgres-migration-N1yqYg20.mjs → planner-produced-postgres-migration-NSEhWL0L.mjs} +8 -6
  86. package/dist/planner-produced-postgres-migration-NSEhWL0L.mjs.map +1 -0
  87. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  88. package/dist/planner-produced-postgres-migration.mjs +1 -1
  89. package/dist/{planner-schema-lookup-BGyukuzG.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
  90. package/dist/{planner-schema-lookup-BGyukuzG.mjs.map → planner-schema-lookup-CiVaAQP-.mjs.map} +1 -1
  91. package/dist/planner-schema-lookup.mjs +1 -1
  92. package/dist/{planner-sql-checks-D3H-xOO1.mjs → planner-sql-checks-DAdhnI2c.mjs} +41 -30
  93. package/dist/planner-sql-checks-DAdhnI2c.mjs.map +1 -0
  94. package/dist/planner-sql-checks.d.mts.map +1 -1
  95. package/dist/planner-sql-checks.mjs +1 -1
  96. package/dist/{planner-target-details-CIj61DUj.d.mts → planner-target-details-CIY6tLeo.d.mts} +2 -2
  97. package/dist/planner-target-details-CIY6tLeo.d.mts.map +1 -0
  98. package/dist/planner-target-details.d.mts +2 -2
  99. package/dist/planner-type-resolution-836DExFN.mjs +20 -0
  100. package/dist/planner-type-resolution-836DExFN.mjs.map +1 -0
  101. package/dist/planner.d.mts +7 -3
  102. package/dist/planner.d.mts.map +1 -1
  103. package/dist/planner.mjs +1 -1
  104. package/dist/{postgres-contract-serializer-YJvjKrmo.mjs → postgres-contract-serializer-DYTyXjPf.mjs} +33 -24
  105. package/dist/postgres-contract-serializer-DYTyXjPf.mjs.map +1 -0
  106. package/dist/{postgres-enum-type-CNhPTDhy.d.mts → postgres-enum-type-BVn63a89.d.mts} +4 -1
  107. package/dist/postgres-enum-type-BVn63a89.d.mts.map +1 -0
  108. package/dist/{postgres-enum-type-DS-KLVRH.mjs → postgres-enum-type-DPKqCBem.mjs} +2 -1
  109. package/dist/postgres-enum-type-DPKqCBem.mjs.map +1 -0
  110. package/dist/{postgres-migration-uADmx0dW.mjs → postgres-migration-COore9Mz.mjs} +23 -3
  111. package/dist/postgres-migration-COore9Mz.mjs.map +1 -0
  112. package/dist/{postgres-migration-Fd4fQkBw.d.mts → postgres-migration-DZ_gLUOW.d.mts} +25 -3
  113. package/dist/postgres-migration-DZ_gLUOW.d.mts.map +1 -0
  114. package/dist/{postgres-schema-Bm7vjlOv.mjs → postgres-schema-BuxCxbvB.mjs} +29 -14
  115. package/dist/postgres-schema-BuxCxbvB.mjs.map +1 -0
  116. package/dist/{render-ops-BC2PtCkj.mjs → render-ops-BpjstrKQ.mjs} +4 -3
  117. package/dist/{render-ops-BC2PtCkj.mjs.map → render-ops-BpjstrKQ.mjs.map} +1 -1
  118. package/dist/render-ops.d.mts +3 -2
  119. package/dist/render-ops.d.mts.map +1 -1
  120. package/dist/render-ops.mjs +1 -1
  121. package/dist/{render-typescript-CPk7hhWH.mjs → render-typescript-KMgosran.mjs} +5 -2
  122. package/dist/render-typescript-KMgosran.mjs.map +1 -0
  123. package/dist/render-typescript.mjs +1 -1
  124. package/dist/runtime.d.mts.map +1 -1
  125. package/dist/runtime.mjs +3 -3
  126. package/dist/runtime.mjs.map +1 -1
  127. package/dist/{shared-ByhSooBS.d.mts → shared-DarONYBZ.d.mts} +5 -5
  128. package/dist/{shared-ByhSooBS.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
  129. package/dist/{sql-utils-B_ruBD-M.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
  130. package/dist/{sql-utils-B_ruBD-M.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
  131. package/dist/sql-utils.mjs +1 -1
  132. package/dist/{types-D-XIpzHA.d.mts → types-BDKkx8MA.d.mts} +1 -1
  133. package/dist/types-BDKkx8MA.d.mts.map +1 -0
  134. package/dist/types.d.mts +16 -11
  135. package/dist/types.d.mts.map +1 -1
  136. package/dist/types.mjs +2 -2
  137. package/package.json +21 -20
  138. package/src/contract-free/columns.ts +49 -0
  139. package/src/contract-free/control-bootstrap.ts +55 -0
  140. package/src/contract-free/ddl.ts +37 -0
  141. package/src/core/ast/table-source.ts +23 -0
  142. package/src/core/authoring.ts +1 -1
  143. package/src/core/codec-ids.ts +1 -0
  144. package/src/core/codecs.ts +44 -0
  145. package/src/core/ddl/nodes.ts +72 -0
  146. package/src/core/descriptor-meta-runtime.ts +28 -0
  147. package/src/core/descriptor-meta.ts +3 -6
  148. package/src/core/migrations/control-policy.ts +234 -0
  149. package/src/core/migrations/issue-planner.ts +81 -13
  150. package/src/core/migrations/op-factory-call.ts +289 -46
  151. package/src/core/migrations/operations/constraints.ts +79 -10
  152. package/src/core/migrations/operations/dependencies.ts +0 -17
  153. package/src/core/migrations/operations/shared.ts +3 -3
  154. package/src/core/migrations/operations/tables.ts +1 -39
  155. package/src/core/migrations/planner-ddl-builders.ts +7 -48
  156. package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
  157. package/src/core/migrations/planner-sql-checks.ts +9 -9
  158. package/src/core/migrations/planner-strategies.ts +149 -11
  159. package/src/core/migrations/planner-target-details.ts +2 -1
  160. package/src/core/migrations/planner.ts +66 -8
  161. package/src/core/migrations/postgres-migration.ts +41 -0
  162. package/src/core/migrations/render-ops.ts +7 -2
  163. package/src/core/migrations/render-typescript.ts +5 -1
  164. package/src/core/migrations/runner.ts +78 -50
  165. package/src/core/postgres-contract-serializer.ts +52 -46
  166. package/src/core/postgres-enum-type.ts +4 -0
  167. package/src/core/postgres-schema.ts +43 -25
  168. package/src/exports/contract-free.ts +7 -0
  169. package/src/exports/control.ts +6 -8
  170. package/src/exports/ddl.ts +7 -0
  171. package/src/exports/migration.ts +11 -2
  172. package/src/exports/op-factory-call.ts +2 -0
  173. package/src/exports/planner-ddl-builders.ts +0 -1
  174. package/src/exports/runtime.ts +2 -2
  175. package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
  176. package/dist/codec-ids-D9fJ4HP5.d.mts.map +0 -1
  177. package/dist/codec-types-CRlHq7Cz.d.mts.map +0 -1
  178. package/dist/codecs-Dud5KDNk.d.mts.map +0 -1
  179. package/dist/descriptor-meta-DLA2xV6B.mjs.map +0 -1
  180. package/dist/issue-planner-ByQhUzS4.mjs.map +0 -1
  181. package/dist/op-factory-call-B0WNg30h.mjs +0 -625
  182. package/dist/op-factory-call-B0WNg30h.mjs.map +0 -1
  183. package/dist/op-factory-call-Drccm_JD.d.mts.map +0 -1
  184. package/dist/planner-ClF0y0YR.mjs +0 -177
  185. package/dist/planner-ClF0y0YR.mjs.map +0 -1
  186. package/dist/planner-ddl-builders-BxRCSn_b.mjs.map +0 -1
  187. package/dist/planner-produced-postgres-migration-N1yqYg20.mjs.map +0 -1
  188. package/dist/planner-produced-postgres-migration-p-VKkCia.d.mts.map +0 -1
  189. package/dist/planner-sql-checks-D3H-xOO1.mjs.map +0 -1
  190. package/dist/planner-target-details-CIj61DUj.d.mts.map +0 -1
  191. package/dist/postgres-contract-serializer-YJvjKrmo.mjs.map +0 -1
  192. package/dist/postgres-enum-type-CNhPTDhy.d.mts.map +0 -1
  193. package/dist/postgres-enum-type-DS-KLVRH.mjs.map +0 -1
  194. package/dist/postgres-migration-Fd4fQkBw.d.mts.map +0 -1
  195. package/dist/postgres-migration-uADmx0dW.mjs.map +0 -1
  196. package/dist/postgres-schema-Bm7vjlOv.mjs.map +0 -1
  197. package/dist/render-typescript-CPk7hhWH.mjs.map +0 -1
  198. package/dist/statement-builders-vImtdfmM.mjs +0 -131
  199. package/dist/statement-builders-vImtdfmM.mjs.map +0 -1
  200. package/dist/statement-builders.d.mts +0 -51
  201. package/dist/statement-builders.d.mts.map +0 -1
  202. package/dist/statement-builders.mjs +0 -2
  203. package/dist/tables-Dcb2q9zV.mjs +0 -516
  204. package/dist/tables-Dcb2q9zV.mjs.map +0 -1
  205. package/dist/types-D-XIpzHA.d.mts.map +0 -1
  206. package/src/core/migrations/statement-builders.ts +0 -183
  207. package/src/exports/statement-builders.ts +0 -8
@@ -1,625 +0,0 @@
1
- import { S as setNotNull, _ as alterColumnType, a as addEnumValues, b as dropNotNull, c as renameType, f as addForeignKey, g as addColumn, h as dropConstraint, i as dropIndex, l as createExtension, m as addUnique, n as dropTable, o as createEnumType, p as addPrimaryKey, r as createIndex, s as dropEnumType, t as createTable, u as createSchema, v as dropColumn, x as setDefault, y as dropDefault } from "./tables-Dcb2q9zV.mjs";
2
- import { errorUnfilledPlaceholder } from "@prisma-next/errors/migration";
3
- import { TsExpression, jsonToTsSource } from "@prisma-next/ts-render";
4
- //#region src/core/migrations/op-factory-call.ts
5
- /**
6
- * Postgres migration IR: one concrete `*Call` class per pure factory under
7
- * `operations/`, plus a shared `PostgresOpFactoryCallNode` abstract base.
8
- *
9
- * Every call class carries the literal arguments its backing factory would
10
- * receive, computes a human-readable `label` in its constructor, and
11
- * implements two polymorphic hooks:
12
- *
13
- * - `toOp()` — converts the IR node to a runtime
14
- * `SqlMigrationPlanOperation` by delegating to the matching pure factory
15
- * under `operations/`. `DataTransformCall.toOp()` always throws
16
- * `PN-MIG-2001` because a planner-generated data transform is an
17
- * unfilled authoring stub by construction.
18
- * - `renderTypeScript()` / `importRequirements()` — inherited from
19
- * `TsExpression`. Used by `renderCallsToTypeScript` to emit the call as
20
- * a TypeScript expression inside the scaffolded `migration.ts`.
21
- *
22
- * The abstract base and all concrete classes are package-private. External
23
- * consumers see only the framework-level `OpFactoryCall` interface and the
24
- * `PostgresOpFactoryCall` union.
25
- */
26
- const TARGET_MIGRATION_MODULE = "@prisma-next/postgres/migration";
27
- var PostgresOpFactoryCallNode = class extends TsExpression {
28
- importRequirements() {
29
- return [{
30
- moduleSpecifier: TARGET_MIGRATION_MODULE,
31
- symbol: this.factoryName
32
- }];
33
- }
34
- freeze() {
35
- Object.freeze(this);
36
- }
37
- };
38
- var CreateTableCall = class extends PostgresOpFactoryCallNode {
39
- factoryName = "createTable";
40
- operationClass = "additive";
41
- schemaName;
42
- tableName;
43
- columns;
44
- primaryKey;
45
- label;
46
- constructor(schemaName, tableName, columns, primaryKey) {
47
- super();
48
- this.schemaName = schemaName;
49
- this.tableName = tableName;
50
- this.columns = columns;
51
- this.primaryKey = primaryKey;
52
- this.label = `Create table "${tableName}"`;
53
- this.freeze();
54
- }
55
- toOp() {
56
- return createTable(this.schemaName, this.tableName, this.columns, this.primaryKey);
57
- }
58
- renderTypeScript() {
59
- const args = [
60
- jsonToTsSource(this.schemaName),
61
- jsonToTsSource(this.tableName),
62
- jsonToTsSource(this.columns)
63
- ];
64
- if (this.primaryKey) args.push(jsonToTsSource(this.primaryKey));
65
- return `createTable(${args.join(", ")})`;
66
- }
67
- };
68
- var DropTableCall = class extends PostgresOpFactoryCallNode {
69
- factoryName = "dropTable";
70
- operationClass = "destructive";
71
- schemaName;
72
- tableName;
73
- label;
74
- constructor(schemaName, tableName) {
75
- super();
76
- this.schemaName = schemaName;
77
- this.tableName = tableName;
78
- this.label = `Drop table "${tableName}"`;
79
- this.freeze();
80
- }
81
- toOp() {
82
- return dropTable(this.schemaName, this.tableName);
83
- }
84
- renderTypeScript() {
85
- return `dropTable(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
86
- }
87
- };
88
- var AddColumnCall = class extends PostgresOpFactoryCallNode {
89
- factoryName = "addColumn";
90
- operationClass = "additive";
91
- schemaName;
92
- tableName;
93
- column;
94
- label;
95
- constructor(schemaName, tableName, column) {
96
- super();
97
- this.schemaName = schemaName;
98
- this.tableName = tableName;
99
- this.column = column;
100
- this.label = `Add column "${column.name}" to "${tableName}"`;
101
- this.freeze();
102
- }
103
- toOp() {
104
- return addColumn(this.schemaName, this.tableName, this.column);
105
- }
106
- renderTypeScript() {
107
- return `addColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.column)})`;
108
- }
109
- };
110
- var DropColumnCall = class extends PostgresOpFactoryCallNode {
111
- factoryName = "dropColumn";
112
- operationClass = "destructive";
113
- schemaName;
114
- tableName;
115
- columnName;
116
- label;
117
- constructor(schemaName, tableName, columnName) {
118
- super();
119
- this.schemaName = schemaName;
120
- this.tableName = tableName;
121
- this.columnName = columnName;
122
- this.label = `Drop column "${columnName}" from "${tableName}"`;
123
- this.freeze();
124
- }
125
- toOp() {
126
- return dropColumn(this.schemaName, this.tableName, this.columnName);
127
- }
128
- renderTypeScript() {
129
- return `dropColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
130
- }
131
- };
132
- var AlterColumnTypeCall = class extends PostgresOpFactoryCallNode {
133
- factoryName = "alterColumnType";
134
- operationClass = "destructive";
135
- schemaName;
136
- tableName;
137
- columnName;
138
- options;
139
- label;
140
- constructor(schemaName, tableName, columnName, options) {
141
- super();
142
- this.schemaName = schemaName;
143
- this.tableName = tableName;
144
- this.columnName = columnName;
145
- this.options = options;
146
- this.label = `Alter type of "${tableName}"."${columnName}" to ${options.rawTargetTypeForLabel}`;
147
- this.freeze();
148
- }
149
- toOp() {
150
- return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options);
151
- }
152
- renderTypeScript() {
153
- return `alterColumnType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)}, ${jsonToTsSource(this.options)})`;
154
- }
155
- };
156
- var SetNotNullCall = class extends PostgresOpFactoryCallNode {
157
- factoryName = "setNotNull";
158
- operationClass = "destructive";
159
- schemaName;
160
- tableName;
161
- columnName;
162
- label;
163
- constructor(schemaName, tableName, columnName) {
164
- super();
165
- this.schemaName = schemaName;
166
- this.tableName = tableName;
167
- this.columnName = columnName;
168
- this.label = `Set NOT NULL on "${tableName}"."${columnName}"`;
169
- this.freeze();
170
- }
171
- toOp() {
172
- return setNotNull(this.schemaName, this.tableName, this.columnName);
173
- }
174
- renderTypeScript() {
175
- return `setNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
176
- }
177
- };
178
- var DropNotNullCall = class extends PostgresOpFactoryCallNode {
179
- factoryName = "dropNotNull";
180
- operationClass = "widening";
181
- schemaName;
182
- tableName;
183
- columnName;
184
- label;
185
- constructor(schemaName, tableName, columnName) {
186
- super();
187
- this.schemaName = schemaName;
188
- this.tableName = tableName;
189
- this.columnName = columnName;
190
- this.label = `Drop NOT NULL on "${tableName}"."${columnName}"`;
191
- this.freeze();
192
- }
193
- toOp() {
194
- return dropNotNull(this.schemaName, this.tableName, this.columnName);
195
- }
196
- renderTypeScript() {
197
- return `dropNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
198
- }
199
- };
200
- var SetDefaultCall = class extends PostgresOpFactoryCallNode {
201
- factoryName = "setDefault";
202
- operationClass;
203
- schemaName;
204
- tableName;
205
- columnName;
206
- defaultSql;
207
- label;
208
- constructor(schemaName, tableName, columnName, defaultSql, operationClass = "additive") {
209
- super();
210
- this.schemaName = schemaName;
211
- this.tableName = tableName;
212
- this.columnName = columnName;
213
- this.defaultSql = defaultSql;
214
- this.operationClass = operationClass;
215
- this.label = `Set default on "${tableName}"."${columnName}"`;
216
- this.freeze();
217
- }
218
- toOp() {
219
- return setDefault(this.schemaName, this.tableName, this.columnName, this.defaultSql, this.operationClass);
220
- }
221
- renderTypeScript() {
222
- const args = [
223
- jsonToTsSource(this.schemaName),
224
- jsonToTsSource(this.tableName),
225
- jsonToTsSource(this.columnName),
226
- jsonToTsSource(this.defaultSql)
227
- ];
228
- if (this.operationClass !== "additive") args.push(jsonToTsSource(this.operationClass));
229
- return `setDefault(${args.join(", ")})`;
230
- }
231
- };
232
- var DropDefaultCall = class extends PostgresOpFactoryCallNode {
233
- factoryName = "dropDefault";
234
- operationClass = "destructive";
235
- schemaName;
236
- tableName;
237
- columnName;
238
- label;
239
- constructor(schemaName, tableName, columnName) {
240
- super();
241
- this.schemaName = schemaName;
242
- this.tableName = tableName;
243
- this.columnName = columnName;
244
- this.label = `Drop default on "${tableName}"."${columnName}"`;
245
- this.freeze();
246
- }
247
- toOp() {
248
- return dropDefault(this.schemaName, this.tableName, this.columnName);
249
- }
250
- renderTypeScript() {
251
- return `dropDefault(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
252
- }
253
- };
254
- var AddPrimaryKeyCall = class extends PostgresOpFactoryCallNode {
255
- factoryName = "addPrimaryKey";
256
- operationClass = "additive";
257
- schemaName;
258
- tableName;
259
- constraintName;
260
- columns;
261
- label;
262
- constructor(schemaName, tableName, constraintName, columns) {
263
- super();
264
- this.schemaName = schemaName;
265
- this.tableName = tableName;
266
- this.constraintName = constraintName;
267
- this.columns = columns;
268
- this.label = `Add primary key on "${tableName}"`;
269
- this.freeze();
270
- }
271
- toOp() {
272
- return addPrimaryKey(this.schemaName, this.tableName, this.constraintName, this.columns);
273
- }
274
- renderTypeScript() {
275
- return `addPrimaryKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;
276
- }
277
- };
278
- var AddUniqueCall = class extends PostgresOpFactoryCallNode {
279
- factoryName = "addUnique";
280
- operationClass = "additive";
281
- schemaName;
282
- tableName;
283
- constraintName;
284
- columns;
285
- label;
286
- constructor(schemaName, tableName, constraintName, columns) {
287
- super();
288
- this.schemaName = schemaName;
289
- this.tableName = tableName;
290
- this.constraintName = constraintName;
291
- this.columns = columns;
292
- this.label = `Add unique constraint on "${tableName}" (${columns.join(", ")})`;
293
- this.freeze();
294
- }
295
- toOp() {
296
- return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns);
297
- }
298
- renderTypeScript() {
299
- return `addUnique(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;
300
- }
301
- };
302
- var AddForeignKeyCall = class extends PostgresOpFactoryCallNode {
303
- factoryName = "addForeignKey";
304
- operationClass = "additive";
305
- schemaName;
306
- tableName;
307
- fk;
308
- label;
309
- constructor(schemaName, tableName, fk) {
310
- super();
311
- this.schemaName = schemaName;
312
- this.tableName = tableName;
313
- this.fk = fk;
314
- this.label = `Add foreign key "${fk.name}" on "${tableName}"`;
315
- this.freeze();
316
- }
317
- toOp() {
318
- return addForeignKey(this.schemaName, this.tableName, this.fk);
319
- }
320
- renderTypeScript() {
321
- return `addForeignKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.fk)})`;
322
- }
323
- };
324
- var DropConstraintCall = class extends PostgresOpFactoryCallNode {
325
- factoryName = "dropConstraint";
326
- operationClass = "destructive";
327
- schemaName;
328
- tableName;
329
- constraintName;
330
- kind;
331
- label;
332
- constructor(schemaName, tableName, constraintName, kind = "unique") {
333
- super();
334
- this.schemaName = schemaName;
335
- this.tableName = tableName;
336
- this.constraintName = constraintName;
337
- this.kind = kind;
338
- this.label = `Drop constraint "${constraintName}" on "${tableName}"`;
339
- this.freeze();
340
- }
341
- toOp() {
342
- return dropConstraint(this.schemaName, this.tableName, this.constraintName, this.kind);
343
- }
344
- renderTypeScript() {
345
- const args = [
346
- jsonToTsSource(this.schemaName),
347
- jsonToTsSource(this.tableName),
348
- jsonToTsSource(this.constraintName)
349
- ];
350
- if (this.kind !== "unique") args.push(jsonToTsSource(this.kind));
351
- return `dropConstraint(${args.join(", ")})`;
352
- }
353
- };
354
- var CreateIndexCall = class extends PostgresOpFactoryCallNode {
355
- factoryName = "createIndex";
356
- operationClass = "additive";
357
- schemaName;
358
- tableName;
359
- indexName;
360
- columns;
361
- indexType;
362
- options;
363
- label;
364
- constructor(schemaName, tableName, indexName, columns, extras) {
365
- super();
366
- this.schemaName = schemaName;
367
- this.tableName = tableName;
368
- this.indexName = indexName;
369
- this.columns = columns;
370
- this.indexType = extras?.type;
371
- this.options = extras?.options;
372
- this.label = `Create index "${indexName}" on "${tableName}"`;
373
- this.freeze();
374
- }
375
- toOp() {
376
- const extras = {};
377
- if (this.indexType !== void 0) extras.type = this.indexType;
378
- if (this.options !== void 0) extras.options = this.options;
379
- return createIndex(this.schemaName, this.tableName, this.indexName, this.columns, extras);
380
- }
381
- renderTypeScript() {
382
- const args = [
383
- jsonToTsSource(this.schemaName),
384
- jsonToTsSource(this.tableName),
385
- jsonToTsSource(this.indexName),
386
- jsonToTsSource(this.columns)
387
- ];
388
- if (this.indexType !== void 0 || this.options !== void 0) {
389
- const extrasParts = [];
390
- if (this.indexType !== void 0) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);
391
- if (this.options !== void 0) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);
392
- args.push(`{ ${extrasParts.join(", ")} }`);
393
- }
394
- return `createIndex(${args.join(", ")})`;
395
- }
396
- };
397
- var DropIndexCall = class extends PostgresOpFactoryCallNode {
398
- factoryName = "dropIndex";
399
- operationClass = "destructive";
400
- schemaName;
401
- tableName;
402
- indexName;
403
- label;
404
- constructor(schemaName, tableName, indexName) {
405
- super();
406
- this.schemaName = schemaName;
407
- this.tableName = tableName;
408
- this.indexName = indexName;
409
- this.label = `Drop index "${indexName}"`;
410
- this.freeze();
411
- }
412
- toOp() {
413
- return dropIndex(this.schemaName, this.tableName, this.indexName);
414
- }
415
- renderTypeScript() {
416
- return `dropIndex(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.indexName)})`;
417
- }
418
- };
419
- var CreateEnumTypeCall = class extends PostgresOpFactoryCallNode {
420
- factoryName = "createEnumType";
421
- operationClass = "additive";
422
- schemaName;
423
- typeName;
424
- nativeType;
425
- values;
426
- label;
427
- constructor(schemaName, typeName, values, nativeType = typeName) {
428
- super();
429
- this.schemaName = schemaName;
430
- this.typeName = typeName;
431
- this.nativeType = nativeType;
432
- this.values = values;
433
- this.label = `Create enum type "${typeName}"`;
434
- this.freeze();
435
- }
436
- toOp() {
437
- return createEnumType(this.schemaName, this.typeName, this.values, this.nativeType);
438
- }
439
- renderTypeScript() {
440
- const nativeArg = this.nativeType === this.typeName ? "" : `, ${jsonToTsSource(this.nativeType)}`;
441
- return `createEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.values)}${nativeArg})`;
442
- }
443
- };
444
- var AddEnumValuesCall = class extends PostgresOpFactoryCallNode {
445
- factoryName = "addEnumValues";
446
- operationClass = "additive";
447
- schemaName;
448
- typeName;
449
- nativeType;
450
- values;
451
- label;
452
- constructor(schemaName, typeName, nativeType, values) {
453
- super();
454
- this.schemaName = schemaName;
455
- this.typeName = typeName;
456
- this.nativeType = nativeType;
457
- this.values = values;
458
- this.label = `Add values to enum type "${typeName}": ${values.join(", ")}`;
459
- this.freeze();
460
- }
461
- toOp() {
462
- return addEnumValues(this.schemaName, this.typeName, this.nativeType, this.values);
463
- }
464
- renderTypeScript() {
465
- return `addEnumValues(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.nativeType)}, ${jsonToTsSource(this.values)})`;
466
- }
467
- };
468
- var DropEnumTypeCall = class extends PostgresOpFactoryCallNode {
469
- factoryName = "dropEnumType";
470
- operationClass = "destructive";
471
- schemaName;
472
- typeName;
473
- label;
474
- constructor(schemaName, typeName) {
475
- super();
476
- this.schemaName = schemaName;
477
- this.typeName = typeName;
478
- this.label = `Drop enum type "${typeName}"`;
479
- this.freeze();
480
- }
481
- toOp() {
482
- return dropEnumType(this.schemaName, this.typeName);
483
- }
484
- renderTypeScript() {
485
- return `dropEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)})`;
486
- }
487
- };
488
- var RenameTypeCall = class extends PostgresOpFactoryCallNode {
489
- factoryName = "renameType";
490
- operationClass = "destructive";
491
- schemaName;
492
- fromName;
493
- toName;
494
- label;
495
- constructor(schemaName, fromName, toName) {
496
- super();
497
- this.schemaName = schemaName;
498
- this.fromName = fromName;
499
- this.toName = toName;
500
- this.label = `Rename type "${fromName}" to "${toName}"`;
501
- this.freeze();
502
- }
503
- toOp() {
504
- return renameType(this.schemaName, this.fromName, this.toName);
505
- }
506
- renderTypeScript() {
507
- return `renameType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.fromName)}, ${jsonToTsSource(this.toName)})`;
508
- }
509
- };
510
- /**
511
- * Laundered pre-built operation.
512
- *
513
- * Wraps an already-materialized `SqlMigrationPlanOperation` — typically one
514
- * produced by a SQL-family method or a codec control hook — so the planner
515
- * can carry it alongside IR nodes without reverse-engineering it into a
516
- * structured call class. Doubles as the user-facing escape hatch for raw
517
- * migrations: authors can pass a full op shape to `rawSql({...})`.
518
- *
519
- * `toOp()` returns the stored op unchanged. `renderTypeScript()` emits
520
- * `rawSql({...})` with the op serialized as a JSON literal — round-tripping
521
- * requires every field on the op to be JSON-serializable (no closures).
522
- */
523
- var RawSqlCall = class extends PostgresOpFactoryCallNode {
524
- factoryName = "rawSql";
525
- operationClass;
526
- label;
527
- op;
528
- constructor(op) {
529
- super();
530
- this.op = op;
531
- this.label = op.label;
532
- this.operationClass = op.operationClass;
533
- this.freeze();
534
- }
535
- toOp() {
536
- return this.op;
537
- }
538
- renderTypeScript() {
539
- return `rawSql(${jsonToTsSource(this.op)})`;
540
- }
541
- };
542
- var CreateExtensionCall = class extends PostgresOpFactoryCallNode {
543
- factoryName = "createExtension";
544
- operationClass = "additive";
545
- extensionName;
546
- label;
547
- constructor(extensionName) {
548
- super();
549
- this.extensionName = extensionName;
550
- this.label = `Create extension "${extensionName}"`;
551
- this.freeze();
552
- }
553
- toOp() {
554
- return createExtension(this.extensionName);
555
- }
556
- renderTypeScript() {
557
- return `createExtension(${jsonToTsSource(this.extensionName)})`;
558
- }
559
- };
560
- var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
561
- factoryName = "createSchema";
562
- operationClass = "additive";
563
- schemaName;
564
- label;
565
- constructor(schemaName) {
566
- super();
567
- this.schemaName = schemaName;
568
- this.label = `Create schema "${schemaName}"`;
569
- this.freeze();
570
- }
571
- toOp() {
572
- return createSchema(this.schemaName);
573
- }
574
- renderTypeScript() {
575
- return `createSchema(${jsonToTsSource(this.schemaName)})`;
576
- }
577
- };
578
- /**
579
- * A planner-generated data-transform stub. `checkSlot` and `runSlot` name
580
- * the unfilled authoring slots that the rendered `migration.ts` will expose
581
- * to the user via `placeholder("…")` calls. `toOp()` always throws
582
- * `PN-MIG-2001`: the planner cannot lower a stubbed transform to a runtime
583
- * op — the user must fill the rendered `migration.ts` and re-emit.
584
- */
585
- var DataTransformCall = class extends PostgresOpFactoryCallNode {
586
- factoryName = "dataTransform";
587
- operationClass;
588
- label;
589
- checkSlot;
590
- runSlot;
591
- constructor(label, checkSlot, runSlot, operationClass = "data") {
592
- super();
593
- this.label = label;
594
- this.checkSlot = checkSlot;
595
- this.runSlot = runSlot;
596
- this.operationClass = operationClass;
597
- this.freeze();
598
- }
599
- toOp() {
600
- throw errorUnfilledPlaceholder(this.label);
601
- }
602
- renderTypeScript() {
603
- return [
604
- `this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,
605
- ` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,
606
- ` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,
607
- "})"
608
- ].join("\n");
609
- }
610
- importRequirements() {
611
- return [{
612
- moduleSpecifier: TARGET_MIGRATION_MODULE,
613
- symbol: "placeholder"
614
- }, {
615
- moduleSpecifier: "./end-contract.json",
616
- symbol: "endContract",
617
- kind: "default",
618
- attributes: { type: "json" }
619
- }];
620
- }
621
- };
622
- //#endregion
623
- export { SetNotNullCall as C, SetDefaultCall as S, DropIndexCall as _, AddUniqueCall as a, RawSqlCall as b, CreateExtensionCall as c, CreateTableCall as d, DataTransformCall as f, DropEnumTypeCall as g, DropDefaultCall as h, AddPrimaryKeyCall as i, CreateIndexCall as l, DropConstraintCall as m, AddEnumValuesCall as n, AlterColumnTypeCall as o, DropColumnCall as p, AddForeignKeyCall as r, CreateEnumTypeCall as s, AddColumnCall as t, CreateSchemaCall as u, DropNotNullCall as v, RenameTypeCall as x, DropTableCall as y };
624
-
625
- //# sourceMappingURL=op-factory-call-B0WNg30h.mjs.map