@prisma-next/target-postgres 0.12.0 → 0.13.0-dev.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{codec-ids-D9fJ4HP5.d.mts → codec-ids-B1vOchLE.d.mts} +3 -2
- package/dist/codec-ids-B1vOchLE.d.mts.map +1 -0
- package/dist/{codec-ids-C5qzBqus.mjs → codec-ids-CTikp1if.mjs} +3 -2
- package/dist/codec-ids-CTikp1if.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-CRlHq7Cz.d.mts → codec-types-CnFiNML4.d.mts} +8 -9
- package/dist/codec-types-CnFiNML4.d.mts.map +1 -0
- package/dist/codec-types.d.mts +2 -2
- package/dist/{codecs-Dud5KDNk.d.mts → codecs-CBpEv4s5.d.mts} +33 -35
- package/dist/codecs-CBpEv4s5.d.mts.map +1 -0
- package/dist/codecs.d.mts +1 -1
- package/dist/codecs.mjs +37 -2
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +80 -0
- package/dist/contract-free.d.mts.map +1 -0
- package/dist/contract-free.mjs +117 -0
- package/dist/contract-free.mjs.map +1 -0
- package/dist/control.d.mts +1 -1
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +67 -41
- package/dist/control.mjs.map +1 -1
- package/dist/{data-transform-CdtGUWp2.mjs → data-transform-D25tLeYU.mjs} +1 -1
- package/dist/{data-transform-CdtGUWp2.mjs.map → data-transform-D25tLeYU.mjs.map} +1 -1
- package/dist/{data-transform-bmOKkygi.d.mts → data-transform-DGOqcLrf.d.mts} +2 -2
- package/dist/{data-transform-bmOKkygi.d.mts.map → data-transform-DGOqcLrf.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/ddl-77SyXgFt.mjs +30 -0
- package/dist/ddl-77SyXgFt.mjs.map +1 -0
- package/dist/ddl.d.mts +2 -0
- package/dist/ddl.mjs +2 -0
- package/dist/{default-normalizer-CRscvhS5.mjs → default-normalizer-DyyCHQWs.mjs} +1 -1
- package/dist/{default-normalizer-CRscvhS5.mjs.map → default-normalizer-DyyCHQWs.mjs.map} +1 -1
- package/dist/default-normalizer.mjs +1 -1
- package/dist/descriptor-meta-DKmj-IMN.mjs +14 -0
- package/dist/descriptor-meta-DKmj-IMN.mjs.map +1 -0
- package/dist/{descriptor-meta-DLA2xV6B.mjs → descriptor-meta-runtime-My8_s4cs.mjs} +82 -78
- package/dist/descriptor-meta-runtime-My8_s4cs.mjs.map +1 -0
- package/dist/{enum-planning-Dz0Ye3Lb.mjs → enum-planning-DTMrPLkN.mjs} +0 -0
- package/dist/enum-planning-DTMrPLkN.mjs.map +1 -0
- package/dist/enum-planning.d.mts +14 -8
- package/dist/enum-planning.d.mts.map +1 -1
- package/dist/enum-planning.mjs +2 -2
- package/dist/{errors--zafB5_n.mjs → errors-CUk87ByX.mjs} +1 -1
- package/dist/{errors--zafB5_n.mjs.map → errors-CUk87ByX.mjs.map} +1 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-ByQhUzS4.mjs → issue-planner-B0A7RFN2.mjs} +130 -28
- package/dist/issue-planner-B0A7RFN2.mjs.map +1 -0
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +7 -8
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +5 -4
- package/dist/migration.mjs.map +1 -1
- package/dist/{native-type-normalizer-ClNPq__-.mjs → native-type-normalizer-Bc9XJzWC.mjs} +1 -1
- package/dist/{native-type-normalizer-ClNPq__-.mjs.map → native-type-normalizer-Bc9XJzWC.mjs.map} +1 -1
- package/dist/native-type-normalizer.mjs +1 -1
- package/dist/nodes-779hmCfL.d.mts +40 -0
- package/dist/nodes-779hmCfL.d.mts.map +1 -0
- package/dist/nodes-DZk2JZG3.mjs +47 -0
- package/dist/nodes-DZk2JZG3.mjs.map +1 -0
- package/dist/op-factory-call-Clp7Zr1z.mjs +1307 -0
- package/dist/op-factory-call-Clp7Zr1z.mjs.map +1 -0
- package/dist/{op-factory-call-Drccm_JD.d.mts → op-factory-call-DMA86_2D.d.mts} +39 -14
- package/dist/op-factory-call-DMA86_2D.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/pack.d.mts +13 -12
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-DID7RZCQ.mjs +344 -0
- package/dist/planner-DID7RZCQ.mjs.map +1 -0
- package/dist/{planner-ddl-builders-BxRCSn_b.mjs → planner-ddl-builders-Cw2n2llW.mjs} +7 -30
- package/dist/planner-ddl-builders-Cw2n2llW.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +6 -7
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/{planner-identity-values-ojX-6cPV.mjs → planner-identity-values-BIpa5p2I.mjs} +1 -1
- package/dist/{planner-identity-values-ojX-6cPV.mjs.map → planner-identity-values-BIpa5p2I.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-p-VKkCia.d.mts → planner-produced-postgres-migration-B4EDvLdz.d.mts} +5 -4
- package/dist/planner-produced-postgres-migration-B4EDvLdz.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-N1yqYg20.mjs → planner-produced-postgres-migration-B8gZBPOR.mjs} +8 -6
- package/dist/planner-produced-postgres-migration-B8gZBPOR.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-schema-lookup-BGyukuzG.mjs → planner-schema-lookup-CiVaAQP-.mjs} +1 -1
- package/dist/{planner-schema-lookup-BGyukuzG.mjs.map → planner-schema-lookup-CiVaAQP-.mjs.map} +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-D3H-xOO1.mjs → planner-sql-checks-DRD5E8A1.mjs} +41 -30
- package/dist/planner-sql-checks-DRD5E8A1.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIj61DUj.d.mts → planner-target-details-CIY6tLeo.d.mts} +2 -2
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +2 -2
- package/dist/planner-type-resolution-836DExFN.mjs +20 -0
- package/dist/planner-type-resolution-836DExFN.mjs.map +1 -0
- package/dist/planner.d.mts +7 -3
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-contract-serializer-YJvjKrmo.mjs → postgres-contract-serializer-DCg7YaP3.mjs} +40 -24
- package/dist/postgres-contract-serializer-DCg7YaP3.mjs.map +1 -0
- package/dist/{postgres-enum-type-CNhPTDhy.d.mts → postgres-enum-type-BVn63a89.d.mts} +4 -1
- package/dist/postgres-enum-type-BVn63a89.d.mts.map +1 -0
- package/dist/{postgres-enum-type-DS-KLVRH.mjs → postgres-enum-type-DPKqCBem.mjs} +2 -1
- package/dist/postgres-enum-type-DPKqCBem.mjs.map +1 -0
- package/dist/{postgres-migration-uADmx0dW.mjs → postgres-migration-BCQEjFHK.mjs} +23 -3
- package/dist/postgres-migration-BCQEjFHK.mjs.map +1 -0
- package/dist/{postgres-migration-Fd4fQkBw.d.mts → postgres-migration-DZ_gLUOW.d.mts} +25 -3
- package/dist/postgres-migration-DZ_gLUOW.d.mts.map +1 -0
- package/dist/{postgres-schema-Bm7vjlOv.mjs → postgres-schema-BVTA2QH7.mjs} +41 -15
- package/dist/postgres-schema-BVTA2QH7.mjs.map +1 -0
- package/dist/{render-ops-BC2PtCkj.mjs → render-ops-BpjstrKQ.mjs} +4 -3
- package/dist/{render-ops-BC2PtCkj.mjs.map → render-ops-BpjstrKQ.mjs.map} +1 -1
- package/dist/render-ops.d.mts +3 -2
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-CPk7hhWH.mjs → render-typescript-KMgosran.mjs} +5 -2
- package/dist/render-typescript-KMgosran.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/{shared-ByhSooBS.d.mts → shared-DarONYBZ.d.mts} +5 -5
- package/dist/{shared-ByhSooBS.d.mts.map → shared-DarONYBZ.d.mts.map} +1 -1
- package/dist/{sql-utils-B_ruBD-M.mjs → sql-utils-DcfMz4MQ.mjs} +1 -1
- package/dist/{sql-utils-B_ruBD-M.mjs.map → sql-utils-DcfMz4MQ.mjs.map} +1 -1
- package/dist/sql-utils.mjs +1 -1
- package/dist/{types-D-XIpzHA.d.mts → types-BDKkx8MA.d.mts} +1 -1
- package/dist/types-BDKkx8MA.d.mts.map +1 -0
- package/dist/types.d.mts +18 -11
- package/dist/types.d.mts.map +1 -1
- package/dist/types.mjs +2 -2
- package/package.json +21 -20
- package/src/contract-free/columns.ts +49 -0
- package/src/contract-free/control-bootstrap.ts +55 -0
- package/src/contract-free/ddl.ts +37 -0
- package/src/core/ast/table-source.ts +23 -0
- package/src/core/authoring.ts +1 -1
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codecs.ts +44 -0
- package/src/core/ddl/nodes.ts +72 -0
- package/src/core/descriptor-meta-runtime.ts +28 -0
- package/src/core/descriptor-meta.ts +3 -6
- package/src/core/migrations/control-policy.ts +234 -0
- package/src/core/migrations/enum-planning.ts +33 -29
- package/src/core/migrations/issue-planner.ts +81 -13
- package/src/core/migrations/op-factory-call.ts +289 -46
- package/src/core/migrations/operations/constraints.ts +79 -10
- package/src/core/migrations/operations/dependencies.ts +0 -17
- package/src/core/migrations/operations/shared.ts +3 -3
- package/src/core/migrations/operations/tables.ts +1 -39
- package/src/core/migrations/planner-ddl-builders.ts +7 -48
- package/src/core/migrations/planner-produced-postgres-migration.ts +11 -6
- package/src/core/migrations/planner-sql-checks.ts +9 -9
- package/src/core/migrations/planner-strategies.ts +149 -11
- package/src/core/migrations/planner-target-details.ts +2 -1
- package/src/core/migrations/planner.ts +66 -8
- package/src/core/migrations/postgres-migration.ts +41 -0
- package/src/core/migrations/render-ops.ts +7 -2
- package/src/core/migrations/render-typescript.ts +5 -1
- package/src/core/migrations/runner.ts +78 -50
- package/src/core/postgres-contract-serializer.ts +66 -46
- package/src/core/postgres-enum-type.ts +4 -0
- package/src/core/postgres-schema.ts +56 -19
- package/src/exports/contract-free.ts +7 -0
- package/src/exports/control.ts +15 -24
- package/src/exports/ddl.ts +7 -0
- package/src/exports/enum-planning.ts +0 -1
- package/src/exports/migration.ts +11 -2
- package/src/exports/op-factory-call.ts +2 -0
- package/src/exports/planner-ddl-builders.ts +0 -1
- package/src/exports/runtime.ts +2 -2
- package/dist/codec-ids-C5qzBqus.mjs.map +0 -1
- package/dist/codec-ids-D9fJ4HP5.d.mts.map +0 -1
- package/dist/codec-types-CRlHq7Cz.d.mts.map +0 -1
- package/dist/codecs-Dud5KDNk.d.mts.map +0 -1
- package/dist/descriptor-meta-DLA2xV6B.mjs.map +0 -1
- package/dist/enum-planning-Dz0Ye3Lb.mjs.map +0 -1
- package/dist/issue-planner-ByQhUzS4.mjs.map +0 -1
- package/dist/op-factory-call-B0WNg30h.mjs +0 -625
- package/dist/op-factory-call-B0WNg30h.mjs.map +0 -1
- package/dist/op-factory-call-Drccm_JD.d.mts.map +0 -1
- package/dist/planner-ClF0y0YR.mjs +0 -177
- package/dist/planner-ClF0y0YR.mjs.map +0 -1
- package/dist/planner-ddl-builders-BxRCSn_b.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-N1yqYg20.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-p-VKkCia.d.mts.map +0 -1
- package/dist/planner-sql-checks-D3H-xOO1.mjs.map +0 -1
- package/dist/planner-target-details-CIj61DUj.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-YJvjKrmo.mjs.map +0 -1
- package/dist/postgres-enum-type-CNhPTDhy.d.mts.map +0 -1
- package/dist/postgres-enum-type-DS-KLVRH.mjs.map +0 -1
- package/dist/postgres-migration-Fd4fQkBw.d.mts.map +0 -1
- package/dist/postgres-migration-uADmx0dW.mjs.map +0 -1
- package/dist/postgres-schema-Bm7vjlOv.mjs.map +0 -1
- package/dist/render-typescript-CPk7hhWH.mjs.map +0 -1
- package/dist/statement-builders-vImtdfmM.mjs +0 -131
- package/dist/statement-builders-vImtdfmM.mjs.map +0 -1
- package/dist/statement-builders.d.mts +0 -51
- package/dist/statement-builders.d.mts.map +0 -1
- package/dist/statement-builders.mjs +0 -2
- package/dist/tables-Dcb2q9zV.mjs +0 -516
- package/dist/tables-Dcb2q9zV.mjs.map +0 -1
- package/dist/types-D-XIpzHA.d.mts.map +0 -1
- package/src/core/migrations/statement-builders.ts +0 -183
- package/src/exports/statement-builders.ts +0 -8
|
@@ -0,0 +1,1307 @@
|
|
|
1
|
+
import { i as quoteIdentifier, n as escapeLiteral, r as qualifyName } from "./sql-utils-DcfMz4MQ.mjs";
|
|
2
|
+
import { n as createTable, t as createSchema } from "./ddl-77SyXgFt.mjs";
|
|
3
|
+
import { a as columnNullabilityCheck, c as qualifyTableName, d as toRegclassLiteral, n as columnDefaultExistsCheck, o as columnTypeCheck, r as columnExistsCheck, s as constraintExistsCheck } from "./planner-sql-checks-DRD5E8A1.mjs";
|
|
4
|
+
import { FunctionColumnDefault, LiteralColumnDefault } from "@prisma-next/sql-relational-core/ast";
|
|
5
|
+
import { ifDefined } from "@prisma-next/utils/defined";
|
|
6
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
7
|
+
import { blindCast } from "@prisma-next/utils/casts";
|
|
8
|
+
import { errorUnfilledPlaceholder } from "@prisma-next/errors/migration";
|
|
9
|
+
import { TsExpression, jsonToTsSource } from "@prisma-next/ts-render";
|
|
10
|
+
import { REFERENTIAL_ACTION_SQL } from "@prisma-next/sql-contract/referential-action-sql";
|
|
11
|
+
//#region src/core/migrations/operations/shared.ts
|
|
12
|
+
function step(description, sql) {
|
|
13
|
+
return {
|
|
14
|
+
description,
|
|
15
|
+
sql
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
function targetDetails(objectType, name, schema, table) {
|
|
19
|
+
return {
|
|
20
|
+
id: "postgres",
|
|
21
|
+
details: {
|
|
22
|
+
schema,
|
|
23
|
+
objectType,
|
|
24
|
+
name,
|
|
25
|
+
...ifDefined("table", table)
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/core/migrations/operations/columns.ts
|
|
31
|
+
function addColumn(schemaName, tableName, column) {
|
|
32
|
+
const addSql = [
|
|
33
|
+
`ALTER TABLE ${qualifyTableName(schemaName, tableName)}`,
|
|
34
|
+
`ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,
|
|
35
|
+
column.defaultSql,
|
|
36
|
+
column.nullable ? "" : "NOT NULL"
|
|
37
|
+
].filter(Boolean).join(" ");
|
|
38
|
+
return {
|
|
39
|
+
id: `column.${tableName}.${column.name}`,
|
|
40
|
+
label: `Add column "${column.name}" to "${tableName}"`,
|
|
41
|
+
operationClass: "additive",
|
|
42
|
+
target: targetDetails("column", column.name, schemaName, tableName),
|
|
43
|
+
precheck: [step(`ensure column "${column.name}" is missing`, columnExistsCheck({
|
|
44
|
+
schema: schemaName,
|
|
45
|
+
table: tableName,
|
|
46
|
+
column: column.name,
|
|
47
|
+
exists: false
|
|
48
|
+
}))],
|
|
49
|
+
execute: [step(`add column "${column.name}"`, addSql)],
|
|
50
|
+
postcheck: [step(`verify column "${column.name}" exists`, columnExistsCheck({
|
|
51
|
+
schema: schemaName,
|
|
52
|
+
table: tableName,
|
|
53
|
+
column: column.name
|
|
54
|
+
}))]
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
function dropColumn(schemaName, tableName, columnName) {
|
|
58
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
59
|
+
return {
|
|
60
|
+
id: `dropColumn.${tableName}.${columnName}`,
|
|
61
|
+
label: `Drop column "${columnName}" from "${tableName}"`,
|
|
62
|
+
operationClass: "destructive",
|
|
63
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
64
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
65
|
+
schema: schemaName,
|
|
66
|
+
table: tableName,
|
|
67
|
+
column: columnName
|
|
68
|
+
}))],
|
|
69
|
+
execute: [step(`drop column "${columnName}"`, `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`)],
|
|
70
|
+
postcheck: [step(`verify column "${columnName}" does not exist`, columnExistsCheck({
|
|
71
|
+
schema: schemaName,
|
|
72
|
+
table: tableName,
|
|
73
|
+
column: columnName,
|
|
74
|
+
exists: false
|
|
75
|
+
}))]
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* `qualifiedTargetType` is the new column type as it appears in the
|
|
80
|
+
* `ALTER COLUMN TYPE` clause (schema-qualified for user-defined types, raw
|
|
81
|
+
* native name for built-ins). `formatTypeExpected` is the unqualified
|
|
82
|
+
* `format_type` form used in the postcheck. `rawTargetTypeForLabel` is the
|
|
83
|
+
* string appearing in the human-readable label (typically `toType` when
|
|
84
|
+
* explicit, else the column's native type).
|
|
85
|
+
*/
|
|
86
|
+
function alterColumnType(schemaName, tableName, columnName, options) {
|
|
87
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
88
|
+
const usingClause = options.using ? ` USING ${options.using}` : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;
|
|
89
|
+
return {
|
|
90
|
+
id: `alterType.${tableName}.${columnName}`,
|
|
91
|
+
label: `Alter type of "${tableName}"."${columnName}" to ${options.rawTargetTypeForLabel}`,
|
|
92
|
+
operationClass: "destructive",
|
|
93
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
94
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
95
|
+
schema: schemaName,
|
|
96
|
+
table: tableName,
|
|
97
|
+
column: columnName
|
|
98
|
+
}))],
|
|
99
|
+
execute: [step(`alter type of "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} TYPE ${options.qualifiedTargetType}${usingClause}`)],
|
|
100
|
+
postcheck: [step(`verify column "${columnName}" has type "${options.formatTypeExpected}"`, columnTypeCheck({
|
|
101
|
+
schema: schemaName,
|
|
102
|
+
table: tableName,
|
|
103
|
+
column: columnName,
|
|
104
|
+
expectedType: options.formatTypeExpected
|
|
105
|
+
}))],
|
|
106
|
+
meta: { warning: "TABLE_REWRITE" }
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function setNotNull(schemaName, tableName, columnName) {
|
|
110
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
111
|
+
return {
|
|
112
|
+
id: `alterNullability.setNotNull.${tableName}.${columnName}`,
|
|
113
|
+
label: `Set NOT NULL on "${tableName}"."${columnName}"`,
|
|
114
|
+
operationClass: "destructive",
|
|
115
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
116
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
117
|
+
schema: schemaName,
|
|
118
|
+
table: tableName,
|
|
119
|
+
column: columnName
|
|
120
|
+
})), step(`ensure no NULL values in "${columnName}"`, `SELECT NOT EXISTS (SELECT 1 FROM ${qualified} WHERE ${quoteIdentifier(columnName)} IS NULL)`)],
|
|
121
|
+
execute: [step(`set NOT NULL on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET NOT NULL`)],
|
|
122
|
+
postcheck: [step(`verify column "${columnName}" is NOT NULL`, columnNullabilityCheck({
|
|
123
|
+
schema: schemaName,
|
|
124
|
+
table: tableName,
|
|
125
|
+
column: columnName,
|
|
126
|
+
nullable: false
|
|
127
|
+
}))]
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
function dropNotNull(schemaName, tableName, columnName) {
|
|
131
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
132
|
+
return {
|
|
133
|
+
id: `alterNullability.dropNotNull.${tableName}.${columnName}`,
|
|
134
|
+
label: `Drop NOT NULL on "${tableName}"."${columnName}"`,
|
|
135
|
+
operationClass: "widening",
|
|
136
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
137
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
138
|
+
schema: schemaName,
|
|
139
|
+
table: tableName,
|
|
140
|
+
column: columnName
|
|
141
|
+
}))],
|
|
142
|
+
execute: [step(`drop NOT NULL on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`)],
|
|
143
|
+
postcheck: [step(`verify column "${columnName}" is nullable`, columnNullabilityCheck({
|
|
144
|
+
schema: schemaName,
|
|
145
|
+
table: tableName,
|
|
146
|
+
column: columnName,
|
|
147
|
+
nullable: true
|
|
148
|
+
}))]
|
|
149
|
+
};
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* `defaultSql` is the full `DEFAULT …` clause as produced by
|
|
153
|
+
* `buildColumnDefaultSql` — e.g. `"DEFAULT 42"`,
|
|
154
|
+
* `"DEFAULT (CURRENT_TIMESTAMP)"`, or `"DEFAULT nextval('seq'::regclass)"`.
|
|
155
|
+
*
|
|
156
|
+
* `operationClass` defaults to `'additive'` (setting a default on a column
|
|
157
|
+
* that currently has none). The reconciliation planner passes `'widening'`
|
|
158
|
+
* when the column already has a different default — policy enforcement
|
|
159
|
+
* treats that as a widening change rather than an additive one.
|
|
160
|
+
*/
|
|
161
|
+
function setDefault(schemaName, tableName, columnName, defaultSql, operationClass = "additive") {
|
|
162
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
163
|
+
return {
|
|
164
|
+
id: `setDefault.${tableName}.${columnName}`,
|
|
165
|
+
label: `Set default on "${tableName}"."${columnName}"`,
|
|
166
|
+
operationClass,
|
|
167
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
168
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
169
|
+
schema: schemaName,
|
|
170
|
+
table: tableName,
|
|
171
|
+
column: columnName
|
|
172
|
+
}))],
|
|
173
|
+
execute: [step(`set default on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${defaultSql}`)],
|
|
174
|
+
postcheck: [step(`verify column "${columnName}" has a default`, columnDefaultExistsCheck({
|
|
175
|
+
schema: schemaName,
|
|
176
|
+
table: tableName,
|
|
177
|
+
column: columnName,
|
|
178
|
+
exists: true
|
|
179
|
+
}))]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
function dropDefault(schemaName, tableName, columnName) {
|
|
183
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
184
|
+
return {
|
|
185
|
+
id: `dropDefault.${tableName}.${columnName}`,
|
|
186
|
+
label: `Drop default on "${tableName}"."${columnName}"`,
|
|
187
|
+
operationClass: "destructive",
|
|
188
|
+
target: targetDetails("column", columnName, schemaName, tableName),
|
|
189
|
+
precheck: [step(`ensure column "${columnName}" exists`, columnExistsCheck({
|
|
190
|
+
schema: schemaName,
|
|
191
|
+
table: tableName,
|
|
192
|
+
column: columnName
|
|
193
|
+
}))],
|
|
194
|
+
execute: [step(`drop default on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`)],
|
|
195
|
+
postcheck: [step(`verify column "${columnName}" has no default`, columnDefaultExistsCheck({
|
|
196
|
+
schema: schemaName,
|
|
197
|
+
table: tableName,
|
|
198
|
+
column: columnName,
|
|
199
|
+
exists: false
|
|
200
|
+
}))]
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
//#endregion
|
|
204
|
+
//#region src/core/migrations/operations/constraints.ts
|
|
205
|
+
function renderForeignKeySql(schemaName, tableName, fk) {
|
|
206
|
+
let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}
|
|
207
|
+
ADD CONSTRAINT ${quoteIdentifier(fk.name)}
|
|
208
|
+
FOREIGN KEY (${fk.columns.map(quoteIdentifier).join(", ")})
|
|
209
|
+
REFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.references.columns.map(quoteIdentifier).join(", ")})`;
|
|
210
|
+
if (fk.onDelete !== void 0) {
|
|
211
|
+
const action = REFERENTIAL_ACTION_SQL[fk.onDelete];
|
|
212
|
+
if (!action) throw new Error(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);
|
|
213
|
+
sql += `\nON DELETE ${action}`;
|
|
214
|
+
}
|
|
215
|
+
if (fk.onUpdate !== void 0) {
|
|
216
|
+
const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];
|
|
217
|
+
if (!action) throw new Error(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);
|
|
218
|
+
sql += `\nON UPDATE ${action}`;
|
|
219
|
+
}
|
|
220
|
+
return sql;
|
|
221
|
+
}
|
|
222
|
+
function addPrimaryKey(schemaName, tableName, constraintName, columns) {
|
|
223
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
224
|
+
const columnList = columns.map(quoteIdentifier).join(", ");
|
|
225
|
+
return {
|
|
226
|
+
id: `primaryKey.${tableName}.${constraintName}`,
|
|
227
|
+
label: `Add primary key on "${tableName}"`,
|
|
228
|
+
operationClass: "additive",
|
|
229
|
+
target: targetDetails("primaryKey", constraintName, schemaName, tableName),
|
|
230
|
+
precheck: [step(`ensure primary key "${constraintName}" does not exist`, constraintExistsCheck({
|
|
231
|
+
constraintName,
|
|
232
|
+
schema: schemaName,
|
|
233
|
+
table: tableName,
|
|
234
|
+
exists: false
|
|
235
|
+
}))],
|
|
236
|
+
execute: [step(`add primary key "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`)],
|
|
237
|
+
postcheck: [step(`verify primary key "${constraintName}" exists`, constraintExistsCheck({
|
|
238
|
+
constraintName,
|
|
239
|
+
schema: schemaName,
|
|
240
|
+
table: tableName
|
|
241
|
+
}))]
|
|
242
|
+
};
|
|
243
|
+
}
|
|
244
|
+
function addUnique(schemaName, tableName, constraintName, columns) {
|
|
245
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
246
|
+
const columnList = columns.map(quoteIdentifier).join(", ");
|
|
247
|
+
return {
|
|
248
|
+
id: `unique.${tableName}.${constraintName}`,
|
|
249
|
+
label: `Add unique constraint on "${tableName}" (${columns.join(", ")})`,
|
|
250
|
+
operationClass: "additive",
|
|
251
|
+
target: targetDetails("unique", constraintName, schemaName, tableName),
|
|
252
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, constraintExistsCheck({
|
|
253
|
+
constraintName,
|
|
254
|
+
schema: schemaName,
|
|
255
|
+
table: tableName,
|
|
256
|
+
exists: false
|
|
257
|
+
}))],
|
|
258
|
+
execute: [step(`add unique constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`)],
|
|
259
|
+
postcheck: [step(`verify constraint "${constraintName}" exists`, constraintExistsCheck({
|
|
260
|
+
constraintName,
|
|
261
|
+
schema: schemaName,
|
|
262
|
+
table: tableName
|
|
263
|
+
}))]
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
function addForeignKey(schemaName, tableName, fk) {
|
|
267
|
+
return {
|
|
268
|
+
id: `foreignKey.${tableName}.${fk.name}`,
|
|
269
|
+
label: `Add foreign key "${fk.name}" on "${tableName}"`,
|
|
270
|
+
operationClass: "additive",
|
|
271
|
+
target: targetDetails("foreignKey", fk.name, schemaName, tableName),
|
|
272
|
+
precheck: [step(`ensure FK "${fk.name}" does not exist`, constraintExistsCheck({
|
|
273
|
+
constraintName: fk.name,
|
|
274
|
+
schema: schemaName,
|
|
275
|
+
table: tableName,
|
|
276
|
+
exists: false
|
|
277
|
+
}))],
|
|
278
|
+
execute: [step(`add FK "${fk.name}"`, renderForeignKeySql(schemaName, tableName, fk))],
|
|
279
|
+
postcheck: [step(`verify FK "${fk.name}" exists`, constraintExistsCheck({
|
|
280
|
+
constraintName: fk.name,
|
|
281
|
+
schema: schemaName,
|
|
282
|
+
table: tableName
|
|
283
|
+
}))]
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
function addCheckConstraint(schemaName, tableName, constraintName, column, values) {
|
|
287
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
288
|
+
const valueList = values.map((v) => `'${escapeLiteral(v)}'`).join(", ");
|
|
289
|
+
return {
|
|
290
|
+
id: `checkConstraint.${tableName}.${constraintName}`,
|
|
291
|
+
label: `Add check constraint "${constraintName}" on "${tableName}"."${column}"`,
|
|
292
|
+
operationClass: "additive",
|
|
293
|
+
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
294
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, constraintExistsCheck({
|
|
295
|
+
constraintName,
|
|
296
|
+
schema: schemaName,
|
|
297
|
+
table: tableName,
|
|
298
|
+
exists: false
|
|
299
|
+
}))],
|
|
300
|
+
execute: [step(`add check constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${quoteIdentifier(column)} IN (${valueList}))`)],
|
|
301
|
+
postcheck: [step(`verify constraint "${constraintName}" exists`, constraintExistsCheck({
|
|
302
|
+
constraintName,
|
|
303
|
+
schema: schemaName,
|
|
304
|
+
table: tableName
|
|
305
|
+
}))]
|
|
306
|
+
};
|
|
307
|
+
}
|
|
308
|
+
function dropCheckConstraint(schemaName, tableName, constraintName) {
|
|
309
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
310
|
+
return {
|
|
311
|
+
id: `dropCheckConstraint.${tableName}.${constraintName}`,
|
|
312
|
+
label: `Drop check constraint "${constraintName}" on "${tableName}"`,
|
|
313
|
+
operationClass: "destructive",
|
|
314
|
+
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
315
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, constraintExistsCheck({
|
|
316
|
+
constraintName,
|
|
317
|
+
schema: schemaName,
|
|
318
|
+
table: tableName
|
|
319
|
+
}))],
|
|
320
|
+
execute: [step(`drop check constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
321
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, constraintExistsCheck({
|
|
322
|
+
constraintName,
|
|
323
|
+
schema: schemaName,
|
|
324
|
+
table: tableName,
|
|
325
|
+
exists: false
|
|
326
|
+
}))]
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
/**
|
|
330
|
+
* `kind` feeds the operation's `target.details.objectType`. Descriptor-flow
|
|
331
|
+
* does not carry kind information in its drop-constraint descriptor, so the
|
|
332
|
+
* default is `'unique'`. The reconciliation planner passes the correct kind
|
|
333
|
+
* (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the `SchemaIssue`
|
|
334
|
+
* that produced the drop.
|
|
335
|
+
*/
|
|
336
|
+
function dropConstraint(schemaName, tableName, constraintName, kind = "unique") {
|
|
337
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
338
|
+
return {
|
|
339
|
+
id: `dropConstraint.${tableName}.${constraintName}`,
|
|
340
|
+
label: `Drop constraint "${constraintName}" on "${tableName}"`,
|
|
341
|
+
operationClass: "destructive",
|
|
342
|
+
target: targetDetails(kind, constraintName, schemaName, tableName),
|
|
343
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, constraintExistsCheck({
|
|
344
|
+
constraintName,
|
|
345
|
+
schema: schemaName,
|
|
346
|
+
table: tableName
|
|
347
|
+
}))],
|
|
348
|
+
execute: [step(`drop constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
349
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, constraintExistsCheck({
|
|
350
|
+
constraintName,
|
|
351
|
+
schema: schemaName,
|
|
352
|
+
table: tableName,
|
|
353
|
+
exists: false
|
|
354
|
+
}))]
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/core/migrations/operations/dependencies.ts
|
|
359
|
+
function createExtension(extensionName) {
|
|
360
|
+
return {
|
|
361
|
+
id: `extension.${extensionName}`,
|
|
362
|
+
label: `Create extension "${extensionName}"`,
|
|
363
|
+
operationClass: "additive",
|
|
364
|
+
target: { id: "postgres" },
|
|
365
|
+
precheck: [],
|
|
366
|
+
execute: [step(`Create extension "${extensionName}"`, `CREATE EXTENSION IF NOT EXISTS ${quoteIdentifier(extensionName)}`)],
|
|
367
|
+
postcheck: []
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
/**
|
|
371
|
+
* Install a Postgres extension as the baseline op for an extension-pack
|
|
372
|
+
* contract space. Layered on top of {@link createExtension}: stamps an
|
|
373
|
+
* `invariantId` (required so the per-space marker records the install),
|
|
374
|
+
* scopes the op `id` under a caller-chosen namespace (e.g. `pgvector.`),
|
|
375
|
+
* and emits pre- and postcheck SQL probing `pg_extension`. The richer
|
|
376
|
+
* shape lets the runner's idempotency probe skip the install on re-run
|
|
377
|
+
* (postcheck-pre-satisfied) without firing the precheck.
|
|
378
|
+
*
|
|
379
|
+
* Use this for hand-rolled baseline migrations in contract-space
|
|
380
|
+
* extension packages (e.g. `extension-pgvector`, `extension-paradedb`);
|
|
381
|
+
* use the bare {@link createExtension} for planner-emitted ops where the
|
|
382
|
+
* caller already controls idempotency through the surrounding plan.
|
|
383
|
+
*/
|
|
384
|
+
function installExtension(options) {
|
|
385
|
+
const { extensionName, invariantId, id } = options;
|
|
386
|
+
return {
|
|
387
|
+
id,
|
|
388
|
+
label: options.label ?? `Enable extension "${extensionName}"`,
|
|
389
|
+
operationClass: "additive",
|
|
390
|
+
invariantId,
|
|
391
|
+
target: {
|
|
392
|
+
id: "postgres",
|
|
393
|
+
details: {
|
|
394
|
+
schema: "public",
|
|
395
|
+
objectType: "dependency",
|
|
396
|
+
name: extensionName
|
|
397
|
+
}
|
|
398
|
+
},
|
|
399
|
+
precheck: [step(`verify extension "${extensionName}" is not already enabled`, `SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`)],
|
|
400
|
+
execute: [step(`create extension "${extensionName}"`, `CREATE EXTENSION IF NOT EXISTS ${extensionName}`)],
|
|
401
|
+
postcheck: [step(`confirm extension "${extensionName}" is enabled`, `SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`)]
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/core/migrations/operations/enums.ts
|
|
406
|
+
function enumTypeExistsCheck(schemaName, nativeType, exists = true) {
|
|
407
|
+
return `SELECT ${exists ? "EXISTS" : "NOT EXISTS"} (
|
|
408
|
+
SELECT 1
|
|
409
|
+
FROM pg_type t
|
|
410
|
+
JOIN pg_namespace n ON t.typnamespace = n.oid
|
|
411
|
+
WHERE n.nspname = '${escapeLiteral(schemaName)}'
|
|
412
|
+
AND t.typname = '${escapeLiteral(nativeType)}'
|
|
413
|
+
)`;
|
|
414
|
+
}
|
|
415
|
+
function createEnumType(schemaName, typeName, values, nativeType = typeName) {
|
|
416
|
+
const qualifiedType = qualifyName(schemaName, nativeType);
|
|
417
|
+
const literalValues = values.map((v) => `'${escapeLiteral(v)}'`).join(", ");
|
|
418
|
+
return {
|
|
419
|
+
id: `type.${typeName}`,
|
|
420
|
+
label: `Create enum type "${typeName}"`,
|
|
421
|
+
operationClass: "additive",
|
|
422
|
+
target: targetDetails("type", typeName, schemaName),
|
|
423
|
+
precheck: [step(`ensure type "${nativeType}" does not exist`, enumTypeExistsCheck(schemaName, nativeType, false))],
|
|
424
|
+
execute: [step(`create enum type "${typeName}"`, `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`)],
|
|
425
|
+
postcheck: [step(`verify type "${nativeType}" exists`, enumTypeExistsCheck(schemaName, nativeType))]
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
/**
|
|
429
|
+
* `typeName` is the contract-facing type name (used for id/label).
|
|
430
|
+
* `nativeType` is the Postgres type name to mutate (may differ for external types).
|
|
431
|
+
*/
|
|
432
|
+
function addEnumValues(schemaName, typeName, nativeType, values) {
|
|
433
|
+
const qualifiedType = qualifyName(schemaName, nativeType);
|
|
434
|
+
return {
|
|
435
|
+
id: `type.${typeName}.addValues`,
|
|
436
|
+
label: `Add values to enum type "${typeName}": ${values.join(", ")}`,
|
|
437
|
+
operationClass: "additive",
|
|
438
|
+
target: targetDetails("type", typeName, schemaName),
|
|
439
|
+
precheck: [step(`ensure type "${nativeType}" exists`, enumTypeExistsCheck(schemaName, nativeType))],
|
|
440
|
+
execute: values.map((value) => step(`add value '${value}' to enum "${nativeType}"`, `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`)),
|
|
441
|
+
postcheck: [step(`verify type "${nativeType}" exists`, enumTypeExistsCheck(schemaName, nativeType))]
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
function dropEnumType(schemaName, typeName) {
|
|
445
|
+
const qualified = qualifyName(schemaName, typeName);
|
|
446
|
+
return {
|
|
447
|
+
id: `type.${typeName}.drop`,
|
|
448
|
+
label: `Drop enum type "${typeName}"`,
|
|
449
|
+
operationClass: "destructive",
|
|
450
|
+
target: targetDetails("type", typeName, schemaName),
|
|
451
|
+
precheck: [step(`ensure type "${typeName}" exists`, enumTypeExistsCheck(schemaName, typeName))],
|
|
452
|
+
execute: [step(`drop enum type "${typeName}"`, `DROP TYPE ${qualified}`)],
|
|
453
|
+
postcheck: [step(`verify type "${typeName}" removed`, enumTypeExistsCheck(schemaName, typeName, false))]
|
|
454
|
+
};
|
|
455
|
+
}
|
|
456
|
+
function renameType(schemaName, fromName, toName) {
|
|
457
|
+
const qualifiedFrom = qualifyName(schemaName, fromName);
|
|
458
|
+
return {
|
|
459
|
+
id: `type.${fromName}.rename`,
|
|
460
|
+
label: `Rename type "${fromName}" to "${toName}"`,
|
|
461
|
+
operationClass: "destructive",
|
|
462
|
+
target: targetDetails("type", fromName, schemaName),
|
|
463
|
+
precheck: [step(`ensure type "${fromName}" exists`, enumTypeExistsCheck(schemaName, fromName)), step(`ensure type "${toName}" does not already exist`, enumTypeExistsCheck(schemaName, toName, false))],
|
|
464
|
+
execute: [step(`rename type "${fromName}" to "${toName}"`, `ALTER TYPE ${qualifiedFrom} RENAME TO ${quoteIdentifier(toName)}`)],
|
|
465
|
+
postcheck: [step(`verify type "${toName}" exists`, enumTypeExistsCheck(schemaName, toName))]
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
//#endregion
|
|
469
|
+
//#region src/core/migrations/operations/indexes.ts
|
|
470
|
+
function renderIndexOptionValue(key, value) {
|
|
471
|
+
if (typeof value === "string") return `'${escapeLiteral(value)}'`;
|
|
472
|
+
if (typeof value === "number" && Number.isFinite(value)) return String(value);
|
|
473
|
+
if (typeof value === "boolean") return value ? "true" : "false";
|
|
474
|
+
throw new Error(`Index option "${key}" must be a string, finite number, or boolean; got ${typeof value}`);
|
|
475
|
+
}
|
|
476
|
+
function renderIndexOptions(options) {
|
|
477
|
+
return Object.entries(options).map(([key, value]) => `${quoteIdentifier(key)} = ${renderIndexOptionValue(key, value)}`).join(", ");
|
|
478
|
+
}
|
|
479
|
+
function createIndex(schemaName, tableName, indexName, columns, extras) {
|
|
480
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
481
|
+
const columnList = columns.map(quoteIdentifier).join(", ");
|
|
482
|
+
const using = extras?.type ? ` USING ${quoteIdentifier(extras.type)}` : "";
|
|
483
|
+
const options = extras?.options;
|
|
484
|
+
const withClause = options && Object.keys(options).length > 0 ? ` WITH (${renderIndexOptions(options)})` : "";
|
|
485
|
+
return {
|
|
486
|
+
id: `index.${tableName}.${indexName}`,
|
|
487
|
+
label: `Create index "${indexName}" on "${tableName}"`,
|
|
488
|
+
operationClass: "additive",
|
|
489
|
+
target: targetDetails("index", indexName, schemaName, tableName),
|
|
490
|
+
precheck: [step(`ensure index "${indexName}" does not exist`, `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`)],
|
|
491
|
+
execute: [step(`create index "${indexName}"`, `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`)],
|
|
492
|
+
postcheck: [step(`verify index "${indexName}" exists`, `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`)]
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
function dropIndex(schemaName, tableName, indexName) {
|
|
496
|
+
return {
|
|
497
|
+
id: `dropIndex.${tableName}.${indexName}`,
|
|
498
|
+
label: `Drop index "${indexName}"`,
|
|
499
|
+
operationClass: "destructive",
|
|
500
|
+
target: targetDetails("index", indexName, schemaName, tableName),
|
|
501
|
+
precheck: [step(`ensure index "${indexName}" exists`, `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`)],
|
|
502
|
+
execute: [step(`drop index "${indexName}"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`)],
|
|
503
|
+
postcheck: [step(`verify index "${indexName}" does not exist`, `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`)]
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
//#endregion
|
|
507
|
+
//#region src/core/migrations/operations/tables.ts
|
|
508
|
+
function dropTable(schemaName, tableName) {
|
|
509
|
+
const qualified = qualifyTableName(schemaName, tableName);
|
|
510
|
+
return {
|
|
511
|
+
id: `dropTable.${tableName}`,
|
|
512
|
+
label: `Drop table "${tableName}"`,
|
|
513
|
+
operationClass: "destructive",
|
|
514
|
+
target: targetDetails("table", tableName, schemaName),
|
|
515
|
+
precheck: [step(`ensure table "${tableName}" exists`, `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`)],
|
|
516
|
+
execute: [step(`drop table "${tableName}"`, `DROP TABLE ${qualified}`)],
|
|
517
|
+
postcheck: [step(`verify table "${tableName}" does not exist`, `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`)]
|
|
518
|
+
};
|
|
519
|
+
}
|
|
520
|
+
//#endregion
|
|
521
|
+
//#region src/core/migrations/op-factory-call.ts
|
|
522
|
+
/**
|
|
523
|
+
* Postgres migration IR: one concrete `*Call` class per pure factory under
|
|
524
|
+
* `operations/`, plus a shared `PostgresOpFactoryCallNode` abstract base.
|
|
525
|
+
*
|
|
526
|
+
* Every call class carries the literal arguments its backing factory would
|
|
527
|
+
* receive, computes a human-readable `label` in its constructor, and
|
|
528
|
+
* implements two polymorphic hooks:
|
|
529
|
+
*
|
|
530
|
+
* - `toOp()` — converts the IR node to a runtime
|
|
531
|
+
* `SqlMigrationPlanOperation` by delegating to the matching pure factory
|
|
532
|
+
* under `operations/`. `DataTransformCall.toOp()` always throws
|
|
533
|
+
* `PN-MIG-2001` because a planner-generated data transform is an
|
|
534
|
+
* unfilled authoring stub by construction.
|
|
535
|
+
* - `renderTypeScript()` / `importRequirements()` — inherited from
|
|
536
|
+
* `TsExpression`. Used by `renderCallsToTypeScript` to emit the call as
|
|
537
|
+
* a TypeScript expression inside the scaffolded `migration.ts`.
|
|
538
|
+
*
|
|
539
|
+
* The abstract base and all concrete classes are package-private. External
|
|
540
|
+
* consumers see only the framework-level `OpFactoryCall` interface and the
|
|
541
|
+
* `PostgresOpFactoryCall` union.
|
|
542
|
+
*/
|
|
543
|
+
const POSTGRES_MIGRATION_FACADE = "@prisma-next/postgres/migration";
|
|
544
|
+
var PostgresOpFactoryCallNode = class extends TsExpression {
|
|
545
|
+
importRequirements() {
|
|
546
|
+
return [{
|
|
547
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
548
|
+
symbol: this.factoryName
|
|
549
|
+
}];
|
|
550
|
+
}
|
|
551
|
+
freeze() {
|
|
552
|
+
Object.freeze(this);
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
function postgresDefaultToDdlColumnDefault(columnDefault) {
|
|
556
|
+
if (!columnDefault) return void 0;
|
|
557
|
+
switch (columnDefault.kind) {
|
|
558
|
+
case "literal": return new LiteralColumnDefault(columnDefault.value);
|
|
559
|
+
case "function":
|
|
560
|
+
if (columnDefault.expression === "autoincrement()") return void 0;
|
|
561
|
+
return new FunctionColumnDefault(columnDefault.expression);
|
|
562
|
+
case "sequence": return new FunctionColumnDefault(`nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`);
|
|
563
|
+
default: throw new Error(`postgresDefaultToDdlColumnDefault: unhandled kind "${blindCast(columnDefault).kind}"`);
|
|
564
|
+
}
|
|
565
|
+
}
|
|
566
|
+
function renderDdlColumnDefault(def) {
|
|
567
|
+
if (!def) return "";
|
|
568
|
+
if (def.kind === "literal") return `lit(${jsonToTsSource(def.value)})`;
|
|
569
|
+
return `fn(${jsonToTsSource(def.expression)})`;
|
|
570
|
+
}
|
|
571
|
+
function renderDdlColumnAsTsCall(col) {
|
|
572
|
+
const opts = [];
|
|
573
|
+
if (col.notNull) opts.push("notNull: true");
|
|
574
|
+
if (col.primaryKey) opts.push("primaryKey: true");
|
|
575
|
+
if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default)}`);
|
|
576
|
+
const optsStr = opts.length > 0 ? `, { ${opts.join(", ")} }` : "";
|
|
577
|
+
return `col(${jsonToTsSource(col.name)}, ${jsonToTsSource(col.type)}${optsStr})`;
|
|
578
|
+
}
|
|
579
|
+
function renderDdlConstraintAsTsCall(constraint) {
|
|
580
|
+
switch (constraint.kind) {
|
|
581
|
+
case "primary-key": {
|
|
582
|
+
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
583
|
+
return `primaryKey(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
584
|
+
}
|
|
585
|
+
case "foreign-key": {
|
|
586
|
+
const opts = [];
|
|
587
|
+
if (constraint.name) opts.push(`name: ${jsonToTsSource(constraint.name)}`);
|
|
588
|
+
if (constraint.onDelete) opts.push(`onDelete: ${jsonToTsSource(constraint.onDelete)}`);
|
|
589
|
+
if (constraint.onUpdate) opts.push(`onUpdate: ${jsonToTsSource(constraint.onUpdate)}`);
|
|
590
|
+
const optsStr = opts.length > 0 ? `, { ${opts.join(", ")} }` : "";
|
|
591
|
+
return `foreignKey(${jsonToTsSource(constraint.columns)}, ${jsonToTsSource(constraint.refTable)}, ${jsonToTsSource(constraint.refColumns)}${optsStr})`;
|
|
592
|
+
}
|
|
593
|
+
case "unique": {
|
|
594
|
+
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
595
|
+
return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
function needsColOrConstraintImport(columns) {
|
|
600
|
+
return columns.length > 0;
|
|
601
|
+
}
|
|
602
|
+
function constraintImportSymbols(constraints) {
|
|
603
|
+
if (!constraints || constraints.length === 0) return [];
|
|
604
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
605
|
+
for (const c of constraints) if (c.kind === "primary-key") symbols.add("primaryKey");
|
|
606
|
+
else if (c.kind === "foreign-key") symbols.add("foreignKey");
|
|
607
|
+
else if (c.kind === "unique") symbols.add("unique");
|
|
608
|
+
return [...symbols];
|
|
609
|
+
}
|
|
610
|
+
function defaultImportSymbols(columns) {
|
|
611
|
+
const symbols = /* @__PURE__ */ new Set();
|
|
612
|
+
for (const col of columns) if (col.default?.kind === "literal") symbols.add("lit");
|
|
613
|
+
else if (col.default?.kind === "function") symbols.add("fn");
|
|
614
|
+
return [...symbols];
|
|
615
|
+
}
|
|
616
|
+
var CreateTableCall = class extends PostgresOpFactoryCallNode {
|
|
617
|
+
factoryName = "createTable";
|
|
618
|
+
operationClass = "additive";
|
|
619
|
+
schemaName;
|
|
620
|
+
tableName;
|
|
621
|
+
columns;
|
|
622
|
+
constraints;
|
|
623
|
+
label;
|
|
624
|
+
constructor(schemaName, tableName, columns, constraints) {
|
|
625
|
+
super();
|
|
626
|
+
this.schemaName = schemaName;
|
|
627
|
+
this.tableName = tableName;
|
|
628
|
+
this.columns = Object.freeze([...columns]);
|
|
629
|
+
this.constraints = constraints ? Object.freeze([...constraints]) : void 0;
|
|
630
|
+
this.label = `Create table "${tableName}"`;
|
|
631
|
+
this.freeze();
|
|
632
|
+
}
|
|
633
|
+
toOp(lowerer) {
|
|
634
|
+
if (lowerer === void 0) throw new Error(`CreateTableCall.toOp: a DDL lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
635
|
+
const ddlNode = createTable({
|
|
636
|
+
...this.schemaName !== UNBOUND_NAMESPACE_ID ? { schema: this.schemaName } : {},
|
|
637
|
+
table: this.tableName,
|
|
638
|
+
columns: this.columns,
|
|
639
|
+
...this.constraints ? { constraints: this.constraints } : {}
|
|
640
|
+
});
|
|
641
|
+
const { sql } = lowerer.lower(ddlNode, { contract: {} });
|
|
642
|
+
const schemaName = this.schemaName;
|
|
643
|
+
const tableName = this.tableName;
|
|
644
|
+
return {
|
|
645
|
+
id: `table.${tableName}`,
|
|
646
|
+
label: `Create table "${tableName}"`,
|
|
647
|
+
summary: `Creates table "${tableName}"`,
|
|
648
|
+
operationClass: "additive",
|
|
649
|
+
target: targetDetails("table", tableName, schemaName),
|
|
650
|
+
precheck: [step(`ensure table "${tableName}" does not exist`, `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`)],
|
|
651
|
+
execute: [step(`create table "${tableName}"`, sql)],
|
|
652
|
+
postcheck: [step(`verify table "${tableName}" exists`, `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`)]
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
renderTypeScript() {
|
|
656
|
+
const columnsList = this.columns.map(renderDdlColumnAsTsCall).join(", ");
|
|
657
|
+
const constraintsList = this.constraints ? this.constraints.map(renderDdlConstraintAsTsCall).join(", ") : void 0;
|
|
658
|
+
const opts = [];
|
|
659
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
660
|
+
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
661
|
+
opts.push(`columns: [${columnsList}]`);
|
|
662
|
+
if (constraintsList) opts.push(`constraints: [${constraintsList}]`);
|
|
663
|
+
return `this.createTable({ ${opts.join(", ")} })`;
|
|
664
|
+
}
|
|
665
|
+
importRequirements() {
|
|
666
|
+
const req = [];
|
|
667
|
+
if (needsColOrConstraintImport(this.columns)) {
|
|
668
|
+
req.push({
|
|
669
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
670
|
+
symbol: "col"
|
|
671
|
+
});
|
|
672
|
+
for (const sym of defaultImportSymbols(this.columns)) req.push({
|
|
673
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
674
|
+
symbol: sym
|
|
675
|
+
});
|
|
676
|
+
}
|
|
677
|
+
for (const sym of constraintImportSymbols(this.constraints)) req.push({
|
|
678
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
679
|
+
symbol: sym
|
|
680
|
+
});
|
|
681
|
+
return req;
|
|
682
|
+
}
|
|
683
|
+
};
|
|
684
|
+
var DropTableCall = class extends PostgresOpFactoryCallNode {
|
|
685
|
+
factoryName = "dropTable";
|
|
686
|
+
operationClass = "destructive";
|
|
687
|
+
schemaName;
|
|
688
|
+
tableName;
|
|
689
|
+
label;
|
|
690
|
+
constructor(schemaName, tableName) {
|
|
691
|
+
super();
|
|
692
|
+
this.schemaName = schemaName;
|
|
693
|
+
this.tableName = tableName;
|
|
694
|
+
this.label = `Drop table "${tableName}"`;
|
|
695
|
+
this.freeze();
|
|
696
|
+
}
|
|
697
|
+
toOp() {
|
|
698
|
+
return dropTable(this.schemaName, this.tableName);
|
|
699
|
+
}
|
|
700
|
+
renderTypeScript() {
|
|
701
|
+
return `dropTable(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
702
|
+
}
|
|
703
|
+
};
|
|
704
|
+
var AddColumnCall = class extends PostgresOpFactoryCallNode {
|
|
705
|
+
factoryName = "addColumn";
|
|
706
|
+
operationClass = "additive";
|
|
707
|
+
schemaName;
|
|
708
|
+
tableName;
|
|
709
|
+
column;
|
|
710
|
+
label;
|
|
711
|
+
constructor(schemaName, tableName, column) {
|
|
712
|
+
super();
|
|
713
|
+
this.schemaName = schemaName;
|
|
714
|
+
this.tableName = tableName;
|
|
715
|
+
this.column = column;
|
|
716
|
+
this.label = `Add column "${column.name}" to "${tableName}"`;
|
|
717
|
+
this.freeze();
|
|
718
|
+
}
|
|
719
|
+
toOp() {
|
|
720
|
+
return addColumn(this.schemaName, this.tableName, this.column);
|
|
721
|
+
}
|
|
722
|
+
renderTypeScript() {
|
|
723
|
+
return `addColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.column)})`;
|
|
724
|
+
}
|
|
725
|
+
};
|
|
726
|
+
var DropColumnCall = class extends PostgresOpFactoryCallNode {
|
|
727
|
+
factoryName = "dropColumn";
|
|
728
|
+
operationClass = "destructive";
|
|
729
|
+
schemaName;
|
|
730
|
+
tableName;
|
|
731
|
+
columnName;
|
|
732
|
+
label;
|
|
733
|
+
constructor(schemaName, tableName, columnName) {
|
|
734
|
+
super();
|
|
735
|
+
this.schemaName = schemaName;
|
|
736
|
+
this.tableName = tableName;
|
|
737
|
+
this.columnName = columnName;
|
|
738
|
+
this.label = `Drop column "${columnName}" from "${tableName}"`;
|
|
739
|
+
this.freeze();
|
|
740
|
+
}
|
|
741
|
+
toOp() {
|
|
742
|
+
return dropColumn(this.schemaName, this.tableName, this.columnName);
|
|
743
|
+
}
|
|
744
|
+
renderTypeScript() {
|
|
745
|
+
return `dropColumn(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
|
|
746
|
+
}
|
|
747
|
+
};
|
|
748
|
+
var AlterColumnTypeCall = class extends PostgresOpFactoryCallNode {
|
|
749
|
+
factoryName = "alterColumnType";
|
|
750
|
+
operationClass = "destructive";
|
|
751
|
+
schemaName;
|
|
752
|
+
tableName;
|
|
753
|
+
columnName;
|
|
754
|
+
options;
|
|
755
|
+
label;
|
|
756
|
+
constructor(schemaName, tableName, columnName, options) {
|
|
757
|
+
super();
|
|
758
|
+
this.schemaName = schemaName;
|
|
759
|
+
this.tableName = tableName;
|
|
760
|
+
this.columnName = columnName;
|
|
761
|
+
this.options = options;
|
|
762
|
+
this.label = `Alter type of "${tableName}"."${columnName}" to ${options.rawTargetTypeForLabel}`;
|
|
763
|
+
this.freeze();
|
|
764
|
+
}
|
|
765
|
+
toOp() {
|
|
766
|
+
return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options);
|
|
767
|
+
}
|
|
768
|
+
renderTypeScript() {
|
|
769
|
+
return `alterColumnType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)}, ${jsonToTsSource(this.options)})`;
|
|
770
|
+
}
|
|
771
|
+
};
|
|
772
|
+
var SetNotNullCall = class extends PostgresOpFactoryCallNode {
|
|
773
|
+
factoryName = "setNotNull";
|
|
774
|
+
operationClass = "destructive";
|
|
775
|
+
schemaName;
|
|
776
|
+
tableName;
|
|
777
|
+
columnName;
|
|
778
|
+
label;
|
|
779
|
+
constructor(schemaName, tableName, columnName) {
|
|
780
|
+
super();
|
|
781
|
+
this.schemaName = schemaName;
|
|
782
|
+
this.tableName = tableName;
|
|
783
|
+
this.columnName = columnName;
|
|
784
|
+
this.label = `Set NOT NULL on "${tableName}"."${columnName}"`;
|
|
785
|
+
this.freeze();
|
|
786
|
+
}
|
|
787
|
+
toOp() {
|
|
788
|
+
return setNotNull(this.schemaName, this.tableName, this.columnName);
|
|
789
|
+
}
|
|
790
|
+
renderTypeScript() {
|
|
791
|
+
return `setNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
|
|
792
|
+
}
|
|
793
|
+
};
|
|
794
|
+
var DropNotNullCall = class extends PostgresOpFactoryCallNode {
|
|
795
|
+
factoryName = "dropNotNull";
|
|
796
|
+
operationClass = "widening";
|
|
797
|
+
schemaName;
|
|
798
|
+
tableName;
|
|
799
|
+
columnName;
|
|
800
|
+
label;
|
|
801
|
+
constructor(schemaName, tableName, columnName) {
|
|
802
|
+
super();
|
|
803
|
+
this.schemaName = schemaName;
|
|
804
|
+
this.tableName = tableName;
|
|
805
|
+
this.columnName = columnName;
|
|
806
|
+
this.label = `Drop NOT NULL on "${tableName}"."${columnName}"`;
|
|
807
|
+
this.freeze();
|
|
808
|
+
}
|
|
809
|
+
toOp() {
|
|
810
|
+
return dropNotNull(this.schemaName, this.tableName, this.columnName);
|
|
811
|
+
}
|
|
812
|
+
renderTypeScript() {
|
|
813
|
+
return `dropNotNull(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
|
|
814
|
+
}
|
|
815
|
+
};
|
|
816
|
+
var SetDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
817
|
+
factoryName = "setDefault";
|
|
818
|
+
operationClass;
|
|
819
|
+
schemaName;
|
|
820
|
+
tableName;
|
|
821
|
+
columnName;
|
|
822
|
+
defaultSql;
|
|
823
|
+
label;
|
|
824
|
+
constructor(schemaName, tableName, columnName, defaultSql, operationClass = "additive") {
|
|
825
|
+
super();
|
|
826
|
+
this.schemaName = schemaName;
|
|
827
|
+
this.tableName = tableName;
|
|
828
|
+
this.columnName = columnName;
|
|
829
|
+
this.defaultSql = defaultSql;
|
|
830
|
+
this.operationClass = operationClass;
|
|
831
|
+
this.label = `Set default on "${tableName}"."${columnName}"`;
|
|
832
|
+
this.freeze();
|
|
833
|
+
}
|
|
834
|
+
toOp() {
|
|
835
|
+
return setDefault(this.schemaName, this.tableName, this.columnName, this.defaultSql, this.operationClass);
|
|
836
|
+
}
|
|
837
|
+
renderTypeScript() {
|
|
838
|
+
const args = [
|
|
839
|
+
jsonToTsSource(this.schemaName),
|
|
840
|
+
jsonToTsSource(this.tableName),
|
|
841
|
+
jsonToTsSource(this.columnName),
|
|
842
|
+
jsonToTsSource(this.defaultSql)
|
|
843
|
+
];
|
|
844
|
+
if (this.operationClass !== "additive") args.push(jsonToTsSource(this.operationClass));
|
|
845
|
+
return `setDefault(${args.join(", ")})`;
|
|
846
|
+
}
|
|
847
|
+
};
|
|
848
|
+
var DropDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
849
|
+
factoryName = "dropDefault";
|
|
850
|
+
operationClass = "destructive";
|
|
851
|
+
schemaName;
|
|
852
|
+
tableName;
|
|
853
|
+
columnName;
|
|
854
|
+
label;
|
|
855
|
+
constructor(schemaName, tableName, columnName) {
|
|
856
|
+
super();
|
|
857
|
+
this.schemaName = schemaName;
|
|
858
|
+
this.tableName = tableName;
|
|
859
|
+
this.columnName = columnName;
|
|
860
|
+
this.label = `Drop default on "${tableName}"."${columnName}"`;
|
|
861
|
+
this.freeze();
|
|
862
|
+
}
|
|
863
|
+
toOp() {
|
|
864
|
+
return dropDefault(this.schemaName, this.tableName, this.columnName);
|
|
865
|
+
}
|
|
866
|
+
renderTypeScript() {
|
|
867
|
+
return `dropDefault(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.columnName)})`;
|
|
868
|
+
}
|
|
869
|
+
};
|
|
870
|
+
var AddPrimaryKeyCall = class extends PostgresOpFactoryCallNode {
|
|
871
|
+
factoryName = "addPrimaryKey";
|
|
872
|
+
operationClass = "additive";
|
|
873
|
+
schemaName;
|
|
874
|
+
tableName;
|
|
875
|
+
constraintName;
|
|
876
|
+
columns;
|
|
877
|
+
label;
|
|
878
|
+
constructor(schemaName, tableName, constraintName, columns) {
|
|
879
|
+
super();
|
|
880
|
+
this.schemaName = schemaName;
|
|
881
|
+
this.tableName = tableName;
|
|
882
|
+
this.constraintName = constraintName;
|
|
883
|
+
this.columns = columns;
|
|
884
|
+
this.label = `Add primary key on "${tableName}"`;
|
|
885
|
+
this.freeze();
|
|
886
|
+
}
|
|
887
|
+
toOp() {
|
|
888
|
+
return addPrimaryKey(this.schemaName, this.tableName, this.constraintName, this.columns);
|
|
889
|
+
}
|
|
890
|
+
renderTypeScript() {
|
|
891
|
+
return `addPrimaryKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;
|
|
892
|
+
}
|
|
893
|
+
};
|
|
894
|
+
var AddUniqueCall = class extends PostgresOpFactoryCallNode {
|
|
895
|
+
factoryName = "addUnique";
|
|
896
|
+
operationClass = "additive";
|
|
897
|
+
schemaName;
|
|
898
|
+
tableName;
|
|
899
|
+
constraintName;
|
|
900
|
+
columns;
|
|
901
|
+
label;
|
|
902
|
+
constructor(schemaName, tableName, constraintName, columns) {
|
|
903
|
+
super();
|
|
904
|
+
this.schemaName = schemaName;
|
|
905
|
+
this.tableName = tableName;
|
|
906
|
+
this.constraintName = constraintName;
|
|
907
|
+
this.columns = columns;
|
|
908
|
+
this.label = `Add unique constraint on "${tableName}" (${columns.join(", ")})`;
|
|
909
|
+
this.freeze();
|
|
910
|
+
}
|
|
911
|
+
toOp() {
|
|
912
|
+
return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns);
|
|
913
|
+
}
|
|
914
|
+
renderTypeScript() {
|
|
915
|
+
return `addUnique(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.columns)})`;
|
|
916
|
+
}
|
|
917
|
+
};
|
|
918
|
+
var AddForeignKeyCall = class extends PostgresOpFactoryCallNode {
|
|
919
|
+
factoryName = "addForeignKey";
|
|
920
|
+
operationClass = "additive";
|
|
921
|
+
schemaName;
|
|
922
|
+
tableName;
|
|
923
|
+
fk;
|
|
924
|
+
label;
|
|
925
|
+
constructor(schemaName, tableName, fk) {
|
|
926
|
+
super();
|
|
927
|
+
this.schemaName = schemaName;
|
|
928
|
+
this.tableName = tableName;
|
|
929
|
+
this.fk = fk;
|
|
930
|
+
this.label = `Add foreign key "${fk.name}" on "${tableName}"`;
|
|
931
|
+
this.freeze();
|
|
932
|
+
}
|
|
933
|
+
toOp() {
|
|
934
|
+
return addForeignKey(this.schemaName, this.tableName, this.fk);
|
|
935
|
+
}
|
|
936
|
+
renderTypeScript() {
|
|
937
|
+
return `addForeignKey(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.fk)})`;
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
var DropConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
941
|
+
factoryName = "dropConstraint";
|
|
942
|
+
operationClass = "destructive";
|
|
943
|
+
schemaName;
|
|
944
|
+
tableName;
|
|
945
|
+
constraintName;
|
|
946
|
+
kind;
|
|
947
|
+
label;
|
|
948
|
+
constructor(schemaName, tableName, constraintName, kind = "unique") {
|
|
949
|
+
super();
|
|
950
|
+
this.schemaName = schemaName;
|
|
951
|
+
this.tableName = tableName;
|
|
952
|
+
this.constraintName = constraintName;
|
|
953
|
+
this.kind = kind;
|
|
954
|
+
this.label = `Drop constraint "${constraintName}" on "${tableName}"`;
|
|
955
|
+
this.freeze();
|
|
956
|
+
}
|
|
957
|
+
toOp() {
|
|
958
|
+
return dropConstraint(this.schemaName, this.tableName, this.constraintName, this.kind);
|
|
959
|
+
}
|
|
960
|
+
renderTypeScript() {
|
|
961
|
+
const args = [
|
|
962
|
+
jsonToTsSource(this.schemaName),
|
|
963
|
+
jsonToTsSource(this.tableName),
|
|
964
|
+
jsonToTsSource(this.constraintName)
|
|
965
|
+
];
|
|
966
|
+
if (this.kind !== "unique") args.push(jsonToTsSource(this.kind));
|
|
967
|
+
return `dropConstraint(${args.join(", ")})`;
|
|
968
|
+
}
|
|
969
|
+
};
|
|
970
|
+
var AddCheckConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
971
|
+
factoryName = "addCheckConstraint";
|
|
972
|
+
operationClass = "additive";
|
|
973
|
+
schemaName;
|
|
974
|
+
tableName;
|
|
975
|
+
constraintName;
|
|
976
|
+
column;
|
|
977
|
+
values;
|
|
978
|
+
label;
|
|
979
|
+
constructor(schemaName, tableName, constraintName, column, values) {
|
|
980
|
+
super();
|
|
981
|
+
this.schemaName = schemaName;
|
|
982
|
+
this.tableName = tableName;
|
|
983
|
+
this.constraintName = constraintName;
|
|
984
|
+
this.column = column;
|
|
985
|
+
this.values = values;
|
|
986
|
+
this.label = `Add check constraint "${constraintName}" on "${tableName}"."${column}"`;
|
|
987
|
+
this.freeze();
|
|
988
|
+
}
|
|
989
|
+
toOp() {
|
|
990
|
+
return addCheckConstraint(this.schemaName, this.tableName, this.constraintName, this.column, this.values);
|
|
991
|
+
}
|
|
992
|
+
renderTypeScript() {
|
|
993
|
+
return `addCheckConstraint(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)}, ${jsonToTsSource(this.column)}, ${jsonToTsSource(this.values)})`;
|
|
994
|
+
}
|
|
995
|
+
};
|
|
996
|
+
var DropCheckConstraintCall = class extends PostgresOpFactoryCallNode {
|
|
997
|
+
factoryName = "dropCheckConstraint";
|
|
998
|
+
operationClass = "destructive";
|
|
999
|
+
schemaName;
|
|
1000
|
+
tableName;
|
|
1001
|
+
constraintName;
|
|
1002
|
+
label;
|
|
1003
|
+
constructor(schemaName, tableName, constraintName) {
|
|
1004
|
+
super();
|
|
1005
|
+
this.schemaName = schemaName;
|
|
1006
|
+
this.tableName = tableName;
|
|
1007
|
+
this.constraintName = constraintName;
|
|
1008
|
+
this.label = `Drop check constraint "${constraintName}" on "${tableName}"`;
|
|
1009
|
+
this.freeze();
|
|
1010
|
+
}
|
|
1011
|
+
toOp() {
|
|
1012
|
+
return dropCheckConstraint(this.schemaName, this.tableName, this.constraintName);
|
|
1013
|
+
}
|
|
1014
|
+
renderTypeScript() {
|
|
1015
|
+
return `dropCheckConstraint(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.constraintName)})`;
|
|
1016
|
+
}
|
|
1017
|
+
};
|
|
1018
|
+
var CreateIndexCall = class extends PostgresOpFactoryCallNode {
|
|
1019
|
+
factoryName = "createIndex";
|
|
1020
|
+
operationClass = "additive";
|
|
1021
|
+
schemaName;
|
|
1022
|
+
tableName;
|
|
1023
|
+
indexName;
|
|
1024
|
+
columns;
|
|
1025
|
+
indexType;
|
|
1026
|
+
options;
|
|
1027
|
+
label;
|
|
1028
|
+
constructor(schemaName, tableName, indexName, columns, extras) {
|
|
1029
|
+
super();
|
|
1030
|
+
this.schemaName = schemaName;
|
|
1031
|
+
this.tableName = tableName;
|
|
1032
|
+
this.indexName = indexName;
|
|
1033
|
+
this.columns = columns;
|
|
1034
|
+
this.indexType = extras?.type;
|
|
1035
|
+
this.options = extras?.options;
|
|
1036
|
+
this.label = `Create index "${indexName}" on "${tableName}"`;
|
|
1037
|
+
this.freeze();
|
|
1038
|
+
}
|
|
1039
|
+
toOp() {
|
|
1040
|
+
const extras = {};
|
|
1041
|
+
if (this.indexType !== void 0) extras.type = this.indexType;
|
|
1042
|
+
if (this.options !== void 0) extras.options = this.options;
|
|
1043
|
+
return createIndex(this.schemaName, this.tableName, this.indexName, this.columns, extras);
|
|
1044
|
+
}
|
|
1045
|
+
renderTypeScript() {
|
|
1046
|
+
const args = [
|
|
1047
|
+
jsonToTsSource(this.schemaName),
|
|
1048
|
+
jsonToTsSource(this.tableName),
|
|
1049
|
+
jsonToTsSource(this.indexName),
|
|
1050
|
+
jsonToTsSource(this.columns)
|
|
1051
|
+
];
|
|
1052
|
+
if (this.indexType !== void 0 || this.options !== void 0) {
|
|
1053
|
+
const extrasParts = [];
|
|
1054
|
+
if (this.indexType !== void 0) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);
|
|
1055
|
+
if (this.options !== void 0) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);
|
|
1056
|
+
args.push(`{ ${extrasParts.join(", ")} }`);
|
|
1057
|
+
}
|
|
1058
|
+
return `createIndex(${args.join(", ")})`;
|
|
1059
|
+
}
|
|
1060
|
+
};
|
|
1061
|
+
var DropIndexCall = class extends PostgresOpFactoryCallNode {
|
|
1062
|
+
factoryName = "dropIndex";
|
|
1063
|
+
operationClass = "destructive";
|
|
1064
|
+
schemaName;
|
|
1065
|
+
tableName;
|
|
1066
|
+
indexName;
|
|
1067
|
+
label;
|
|
1068
|
+
constructor(schemaName, tableName, indexName) {
|
|
1069
|
+
super();
|
|
1070
|
+
this.schemaName = schemaName;
|
|
1071
|
+
this.tableName = tableName;
|
|
1072
|
+
this.indexName = indexName;
|
|
1073
|
+
this.label = `Drop index "${indexName}"`;
|
|
1074
|
+
this.freeze();
|
|
1075
|
+
}
|
|
1076
|
+
toOp() {
|
|
1077
|
+
return dropIndex(this.schemaName, this.tableName, this.indexName);
|
|
1078
|
+
}
|
|
1079
|
+
renderTypeScript() {
|
|
1080
|
+
return `dropIndex(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.indexName)})`;
|
|
1081
|
+
}
|
|
1082
|
+
};
|
|
1083
|
+
var CreateEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1084
|
+
factoryName = "createEnumType";
|
|
1085
|
+
operationClass = "additive";
|
|
1086
|
+
schemaName;
|
|
1087
|
+
typeName;
|
|
1088
|
+
nativeType;
|
|
1089
|
+
values;
|
|
1090
|
+
label;
|
|
1091
|
+
constructor(schemaName, typeName, values, nativeType = typeName) {
|
|
1092
|
+
super();
|
|
1093
|
+
this.schemaName = schemaName;
|
|
1094
|
+
this.typeName = typeName;
|
|
1095
|
+
this.nativeType = nativeType;
|
|
1096
|
+
this.values = values;
|
|
1097
|
+
this.label = `Create enum type "${typeName}"`;
|
|
1098
|
+
this.freeze();
|
|
1099
|
+
}
|
|
1100
|
+
toOp() {
|
|
1101
|
+
return createEnumType(this.schemaName, this.typeName, this.values, this.nativeType);
|
|
1102
|
+
}
|
|
1103
|
+
renderTypeScript() {
|
|
1104
|
+
const nativeArg = this.nativeType === this.typeName ? "" : `, ${jsonToTsSource(this.nativeType)}`;
|
|
1105
|
+
return `createEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.values)}${nativeArg})`;
|
|
1106
|
+
}
|
|
1107
|
+
};
|
|
1108
|
+
var AddEnumValuesCall = class extends PostgresOpFactoryCallNode {
|
|
1109
|
+
factoryName = "addEnumValues";
|
|
1110
|
+
operationClass = "additive";
|
|
1111
|
+
schemaName;
|
|
1112
|
+
typeName;
|
|
1113
|
+
nativeType;
|
|
1114
|
+
values;
|
|
1115
|
+
label;
|
|
1116
|
+
constructor(schemaName, typeName, nativeType, values) {
|
|
1117
|
+
super();
|
|
1118
|
+
this.schemaName = schemaName;
|
|
1119
|
+
this.typeName = typeName;
|
|
1120
|
+
this.nativeType = nativeType;
|
|
1121
|
+
this.values = values;
|
|
1122
|
+
this.label = `Add values to enum type "${typeName}": ${values.join(", ")}`;
|
|
1123
|
+
this.freeze();
|
|
1124
|
+
}
|
|
1125
|
+
toOp() {
|
|
1126
|
+
return addEnumValues(this.schemaName, this.typeName, this.nativeType, this.values);
|
|
1127
|
+
}
|
|
1128
|
+
renderTypeScript() {
|
|
1129
|
+
return `addEnumValues(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)}, ${jsonToTsSource(this.nativeType)}, ${jsonToTsSource(this.values)})`;
|
|
1130
|
+
}
|
|
1131
|
+
};
|
|
1132
|
+
var DropEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1133
|
+
factoryName = "dropEnumType";
|
|
1134
|
+
operationClass = "destructive";
|
|
1135
|
+
schemaName;
|
|
1136
|
+
typeName;
|
|
1137
|
+
label;
|
|
1138
|
+
constructor(schemaName, typeName) {
|
|
1139
|
+
super();
|
|
1140
|
+
this.schemaName = schemaName;
|
|
1141
|
+
this.typeName = typeName;
|
|
1142
|
+
this.label = `Drop enum type "${typeName}"`;
|
|
1143
|
+
this.freeze();
|
|
1144
|
+
}
|
|
1145
|
+
toOp() {
|
|
1146
|
+
return dropEnumType(this.schemaName, this.typeName);
|
|
1147
|
+
}
|
|
1148
|
+
renderTypeScript() {
|
|
1149
|
+
return `dropEnumType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.typeName)})`;
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
var RenameTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1153
|
+
factoryName = "renameType";
|
|
1154
|
+
operationClass = "destructive";
|
|
1155
|
+
schemaName;
|
|
1156
|
+
fromName;
|
|
1157
|
+
toName;
|
|
1158
|
+
label;
|
|
1159
|
+
constructor(schemaName, fromName, toName) {
|
|
1160
|
+
super();
|
|
1161
|
+
this.schemaName = schemaName;
|
|
1162
|
+
this.fromName = fromName;
|
|
1163
|
+
this.toName = toName;
|
|
1164
|
+
this.label = `Rename type "${fromName}" to "${toName}"`;
|
|
1165
|
+
this.freeze();
|
|
1166
|
+
}
|
|
1167
|
+
toOp() {
|
|
1168
|
+
return renameType(this.schemaName, this.fromName, this.toName);
|
|
1169
|
+
}
|
|
1170
|
+
renderTypeScript() {
|
|
1171
|
+
return `renameType(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.fromName)}, ${jsonToTsSource(this.toName)})`;
|
|
1172
|
+
}
|
|
1173
|
+
};
|
|
1174
|
+
/**
|
|
1175
|
+
* Laundered pre-built operation.
|
|
1176
|
+
*
|
|
1177
|
+
* Wraps an already-materialized `SqlMigrationPlanOperation` — typically one
|
|
1178
|
+
* produced by a SQL-family method or a codec control hook — so the planner
|
|
1179
|
+
* can carry it alongside IR nodes without reverse-engineering it into a
|
|
1180
|
+
* structured call class. Doubles as the user-facing escape hatch for raw
|
|
1181
|
+
* migrations: authors can pass a full op shape to `rawSql({...})`.
|
|
1182
|
+
*
|
|
1183
|
+
* `toOp()` returns the stored op unchanged. `renderTypeScript()` emits
|
|
1184
|
+
* `rawSql({...})` with the op serialized as a JSON literal — round-tripping
|
|
1185
|
+
* requires every field on the op to be JSON-serializable (no closures).
|
|
1186
|
+
*/
|
|
1187
|
+
var RawSqlCall = class extends PostgresOpFactoryCallNode {
|
|
1188
|
+
factoryName = "rawSql";
|
|
1189
|
+
operationClass;
|
|
1190
|
+
label;
|
|
1191
|
+
op;
|
|
1192
|
+
constructor(op) {
|
|
1193
|
+
super();
|
|
1194
|
+
this.op = op;
|
|
1195
|
+
this.label = op.label;
|
|
1196
|
+
this.operationClass = op.operationClass;
|
|
1197
|
+
this.freeze();
|
|
1198
|
+
}
|
|
1199
|
+
toOp() {
|
|
1200
|
+
return this.op;
|
|
1201
|
+
}
|
|
1202
|
+
renderTypeScript() {
|
|
1203
|
+
return `rawSql(${jsonToTsSource(this.op)})`;
|
|
1204
|
+
}
|
|
1205
|
+
};
|
|
1206
|
+
var CreateExtensionCall = class extends PostgresOpFactoryCallNode {
|
|
1207
|
+
factoryName = "createExtension";
|
|
1208
|
+
operationClass = "additive";
|
|
1209
|
+
extensionName;
|
|
1210
|
+
label;
|
|
1211
|
+
constructor(extensionName) {
|
|
1212
|
+
super();
|
|
1213
|
+
this.extensionName = extensionName;
|
|
1214
|
+
this.label = `Create extension "${extensionName}"`;
|
|
1215
|
+
this.freeze();
|
|
1216
|
+
}
|
|
1217
|
+
toOp() {
|
|
1218
|
+
return createExtension(this.extensionName);
|
|
1219
|
+
}
|
|
1220
|
+
renderTypeScript() {
|
|
1221
|
+
return `createExtension(${jsonToTsSource(this.extensionName)})`;
|
|
1222
|
+
}
|
|
1223
|
+
};
|
|
1224
|
+
var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
1225
|
+
factoryName = "createSchema";
|
|
1226
|
+
operationClass = "additive";
|
|
1227
|
+
schemaName;
|
|
1228
|
+
label;
|
|
1229
|
+
constructor(schemaName) {
|
|
1230
|
+
super();
|
|
1231
|
+
this.schemaName = schemaName;
|
|
1232
|
+
this.label = `Create schema "${schemaName}"`;
|
|
1233
|
+
this.freeze();
|
|
1234
|
+
}
|
|
1235
|
+
toOp(lowerer) {
|
|
1236
|
+
if (lowerer === void 0) throw new Error(`CreateSchemaCall.toOp: a DDL lowerer is required on the Postgres planner path (schema "${this.schemaName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1237
|
+
const ddlNode = createSchema({
|
|
1238
|
+
schema: this.schemaName,
|
|
1239
|
+
ifNotExists: true
|
|
1240
|
+
});
|
|
1241
|
+
const { sql } = lowerer.lower(ddlNode, { contract: {} });
|
|
1242
|
+
const schemaName = this.schemaName;
|
|
1243
|
+
return {
|
|
1244
|
+
id: `schema.${schemaName}`,
|
|
1245
|
+
label: `Create schema "${schemaName}"`,
|
|
1246
|
+
operationClass: "additive",
|
|
1247
|
+
target: { id: "postgres" },
|
|
1248
|
+
precheck: [],
|
|
1249
|
+
execute: [step(`Create schema "${schemaName}"`, sql)],
|
|
1250
|
+
postcheck: []
|
|
1251
|
+
};
|
|
1252
|
+
}
|
|
1253
|
+
renderTypeScript() {
|
|
1254
|
+
return `this.createSchema({ schema: ${jsonToTsSource(this.schemaName)} })`;
|
|
1255
|
+
}
|
|
1256
|
+
importRequirements() {
|
|
1257
|
+
return [];
|
|
1258
|
+
}
|
|
1259
|
+
};
|
|
1260
|
+
/**
|
|
1261
|
+
* A planner-generated data-transform stub. `checkSlot` and `runSlot` name
|
|
1262
|
+
* the unfilled authoring slots that the rendered `migration.ts` will expose
|
|
1263
|
+
* to the user via `placeholder("…")` calls. `toOp()` always throws
|
|
1264
|
+
* `PN-MIG-2001`: the planner cannot lower a stubbed transform to a runtime
|
|
1265
|
+
* op — the user must fill the rendered `migration.ts` and re-emit.
|
|
1266
|
+
*/
|
|
1267
|
+
var DataTransformCall = class extends PostgresOpFactoryCallNode {
|
|
1268
|
+
factoryName = "dataTransform";
|
|
1269
|
+
operationClass;
|
|
1270
|
+
label;
|
|
1271
|
+
checkSlot;
|
|
1272
|
+
runSlot;
|
|
1273
|
+
constructor(label, checkSlot, runSlot, operationClass = "data") {
|
|
1274
|
+
super();
|
|
1275
|
+
this.label = label;
|
|
1276
|
+
this.checkSlot = checkSlot;
|
|
1277
|
+
this.runSlot = runSlot;
|
|
1278
|
+
this.operationClass = operationClass;
|
|
1279
|
+
this.freeze();
|
|
1280
|
+
}
|
|
1281
|
+
toOp() {
|
|
1282
|
+
throw errorUnfilledPlaceholder(this.label);
|
|
1283
|
+
}
|
|
1284
|
+
renderTypeScript() {
|
|
1285
|
+
return [
|
|
1286
|
+
`this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,
|
|
1287
|
+
` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,
|
|
1288
|
+
` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,
|
|
1289
|
+
"})"
|
|
1290
|
+
].join("\n");
|
|
1291
|
+
}
|
|
1292
|
+
importRequirements() {
|
|
1293
|
+
return [{
|
|
1294
|
+
moduleSpecifier: POSTGRES_MIGRATION_FACADE,
|
|
1295
|
+
symbol: "placeholder"
|
|
1296
|
+
}, {
|
|
1297
|
+
moduleSpecifier: "./end-contract.json",
|
|
1298
|
+
symbol: "endContract",
|
|
1299
|
+
kind: "default",
|
|
1300
|
+
attributes: { type: "json" }
|
|
1301
|
+
}];
|
|
1302
|
+
}
|
|
1303
|
+
};
|
|
1304
|
+
//#endregion
|
|
1305
|
+
export { addEnumValues as A, dropCheckConstraint as B, RenameTypeCall as C, dropTable as D, postgresDefaultToDdlColumnDefault as E, installExtension as F, dropDefault as G, addColumn as H, addCheckConstraint as I, setNotNull as J, dropNotNull as K, addForeignKey as L, dropEnumType as M, renameType as N, createIndex as O, createExtension as P, addPrimaryKey as R, RawSqlCall as S, SetNotNullCall as T, alterColumnType as U, dropConstraint as V, dropColumn as W, DropDefaultCall as _, AddPrimaryKeyCall as a, DropNotNullCall as b, CreateEnumTypeCall as c, CreateSchemaCall as d, CreateTableCall as f, DropConstraintCall as g, DropColumnCall as h, AddForeignKeyCall as i, createEnumType as j, dropIndex as k, CreateExtensionCall as l, DropCheckConstraintCall as m, AddColumnCall as n, AddUniqueCall as o, DataTransformCall as p, setDefault as q, AddEnumValuesCall as r, AlterColumnTypeCall as s, AddCheckConstraintCall as t, CreateIndexCall as u, DropEnumTypeCall as v, SetDefaultCall as w, DropTableCall as x, DropIndexCall as y, addUnique as z };
|
|
1306
|
+
|
|
1307
|
+
//# sourceMappingURL=op-factory-call-Clp7Zr1z.mjs.map
|