@prisma/orm-target-postgres 8.0.0-rc.19-dev.2 → 8.0.0-rc.19-dev.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{control-policy-CKpFHf2M-DiTgsTUn.mjs → control-policy-NpK0183H-DB8b5bNu.mjs} +3 -3
- package/dist/{control-policy-CKpFHf2M-DiTgsTUn.mjs.map → control-policy-NpK0183H-DB8b5bNu.mjs.map} +1 -1
- package/dist/{diff-database-schema-BIPAJn7W-DhU2uiVA.mjs → diff-database-schema-O45Q-UNo-6YARJ8Qu.mjs} +3 -3
- package/dist/{diff-database-schema-BIPAJn7W-DhU2uiVA.mjs.map → diff-database-schema-O45Q-UNo-6YARJ8Qu.mjs.map} +1 -1
- package/dist/{indexes-CvNRG0Xu-C8OjTa0S.d.mts → indexes-c2U6QZ4P-DgZWG_iu.d.mts} +3 -2
- package/dist/indexes-c2U6QZ4P-DgZWG_iu.d.mts.map +1 -0
- package/dist/{issue-planner-B2iWCR_t.d.mts → issue-planner-BrOqWTg5.d.mts} +2 -2
- package/dist/{issue-planner-B2iWCR_t.d.mts.map → issue-planner-BrOqWTg5.d.mts.map} +1 -1
- package/dist/migration-CbOh59ZJ.mjs.map +1 -1
- package/dist/{migration-CpHZV_Y6.d.mts → migration-cxHhDEGa.d.mts} +3 -3
- package/dist/{migration-CpHZV_Y6.d.mts.map → migration-cxHhDEGa.d.mts.map} +1 -1
- package/dist/{op-factory-call-DghB0ndC-9CDIMLTM.d.mts → op-factory-call-BAmu21qK-DjHPE4DG.d.mts} +3 -3
- package/dist/{op-factory-call-DghB0ndC-9CDIMLTM.d.mts.map → op-factory-call-BAmu21qK-DjHPE4DG.d.mts.map} +1 -1
- package/dist/op-factory-call-CDxHGgzs.d.mts +1 -0
- package/dist/{op-factory-call-B5_tnifS-BGaMVQ8g.mjs → op-factory-call-CtHJKITc-BMwiP_p7.mjs} +52 -50
- package/dist/op-factory-call-CtHJKITc-BMwiP_p7.mjs.map +1 -0
- package/dist/{planner-BEAM0y_U.d.mts → planner-BQQdHpAs.d.mts} +2 -2
- package/dist/{planner-BEAM0y_U.d.mts.map → planner-BQQdHpAs.d.mts.map} +1 -1
- package/dist/{planner-DnjJIgvS-YnoVZc2N.mjs → planner-DD0z05v--ByV38sBF.mjs} +7 -7
- package/dist/{planner-DnjJIgvS-YnoVZc2N.mjs.map → planner-DD0z05v--ByV38sBF.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-BO7M2Q-t-Dhyz9UMt.d.mts → planner-produced-postgres-migration-C60Pid87-CFops3Az.d.mts} +3 -3
- package/dist/planner-produced-postgres-migration-C60Pid87-CFops3Az.d.mts.map +1 -0
- package/dist/{planner-produced-postgres-migration-BRGqjq30-3uFr1J4_.mjs → planner-produced-postgres-migration-CHFWM40q-DEXCOdWT.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-BRGqjq30-3uFr1J4_.mjs.map → planner-produced-postgres-migration-CHFWM40q-DEXCOdWT.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration-Ch-pBAnV.d.mts +1 -0
- package/dist/{postgres-migration-CPUwTt8B-B2vE3E_r.d.mts → postgres-migration-C3HdYUMt-DPWn_-7n.d.mts} +3 -3
- package/dist/{postgres-migration-CPUwTt8B-B2vE3E_r.d.mts.map → postgres-migration-C3HdYUMt-DPWn_-7n.d.mts.map} +1 -1
- package/dist/{postgres-migration-B46jBuCV-ByXR4shS.mjs → postgres-migration-CliSGXur-BQsla3Y9.mjs} +5 -5
- package/dist/{postgres-migration-B46jBuCV-ByXR4shS.mjs.map → postgres-migration-CliSGXur-BQsla3Y9.mjs.map} +1 -1
- package/dist/{render-ops-DzfUHzbE-aSmN95s3.mjs → render-ops-CrYiS0XA-Bkqye2yB.mjs} +3 -3
- package/dist/{render-ops-DzfUHzbE-aSmN95s3.mjs.map → render-ops-CrYiS0XA-Bkqye2yB.mjs.map} +1 -1
- package/dist/target.d.mts +8 -8
- package/dist/target.mjs +7 -7
- package/dist/target__control.mjs +27 -21
- package/dist/target__control.mjs.map +1 -1
- package/dist/target__diff-database-schema.mjs +1 -1
- package/dist/target__issue-planner.d.mts +1 -1
- package/dist/target__issue-planner.mjs +1 -1
- package/dist/target__migration.d.mts +2 -2
- package/dist/target__migration.mjs +2 -2
- package/dist/target__op-factory-call.d.mts +2 -2
- package/dist/target__op-factory-call.mjs +1 -1
- package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
- package/dist/target__planner-produced-postgres-migration.mjs +1 -1
- package/dist/target__planner.d.mts +1 -1
- package/dist/target__planner.mjs +2 -2
- package/dist/target__render-ops.mjs +1 -1
- package/package.json +9 -9
- package/dist/indexes-CvNRG0Xu-C8OjTa0S.d.mts.map +0 -1
- package/dist/op-factory-call-B5_tnifS-BGaMVQ8g.mjs.map +0 -1
- package/dist/op-factory-call-BRHT7R1s.d.mts +0 -1
- package/dist/planner-produced-postgres-migration-BO7M2Q-t-Dhyz9UMt.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-C0Zs5NHu.d.mts +0 -1
package/dist/{op-factory-call-B5_tnifS-BGaMVQ8g.mjs → op-factory-call-CtHJKITc-BMwiP_p7.mjs}
RENAMED
|
@@ -11,6 +11,7 @@ import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql } fro
|
|
|
11
11
|
import { blindCast } from "@prisma/orm-framework/utils/casts";
|
|
12
12
|
import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
|
|
13
13
|
import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
|
|
14
|
+
import { expectAbsent, expectPresent } from "@prisma/orm-framework/components/control";
|
|
14
15
|
import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
|
|
15
16
|
import { ifDefined } from "@prisma/orm-framework/utils/defined";
|
|
16
17
|
import { checkExpression, col } from "@prisma/orm-family-sql/relational-core/contract-free";
|
|
@@ -18,7 +19,7 @@ import { checkSqlDefaultText, checkSqlExpressionText, convertedColumnMeta, creat
|
|
|
18
19
|
import { unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
|
|
19
20
|
import { TsExpression, jsonToTsSource, tsObjectSource } from "@prisma/orm-framework/ts-render";
|
|
20
21
|
import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
|
|
21
|
-
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-
|
|
22
|
+
//#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-CtHJKITc.mjs
|
|
22
23
|
/**
|
|
23
24
|
* Maps a planner schema name to the contract-free DDL builder's optional
|
|
24
25
|
* `schema` field: the unbound sentinel becomes `undefined` (the builder omits
|
|
@@ -33,11 +34,12 @@ function boundSchema(schemaName) {
|
|
|
33
34
|
function defaultSequenceName(tableName, columnName) {
|
|
34
35
|
return postgresObjectName(tableName, columnName, "seq");
|
|
35
36
|
}
|
|
36
|
-
function step(description, sql, params) {
|
|
37
|
+
function step(description, sql, params, expectation) {
|
|
37
38
|
return {
|
|
38
39
|
description,
|
|
39
40
|
sql,
|
|
40
|
-
...ifDefined("params", params)
|
|
41
|
+
...ifDefined("params", params),
|
|
42
|
+
...ifDefined("expectation", expectation)
|
|
41
43
|
};
|
|
42
44
|
}
|
|
43
45
|
function targetDetails(objectType, name, schema, table) {
|
|
@@ -92,9 +94,9 @@ async function dropColumn(schemaName, tableName, columnName, lowerer) {
|
|
|
92
94
|
label: `Drop column "${columnName}" from "${tableName}"`,
|
|
93
95
|
operationClass: "destructive",
|
|
94
96
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
95
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
97
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
96
98
|
execute: [step(`drop column "${columnName}"`, `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`)],
|
|
97
|
-
postcheck: [step(`verify column "${columnName}" does not exist`, absent.sql, absent.params)]
|
|
99
|
+
postcheck: [step(`verify column "${columnName}" does not exist`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))]
|
|
98
100
|
};
|
|
99
101
|
}
|
|
100
102
|
function renameColumnStatement(schemaName, tableName, fromName, toName) {
|
|
@@ -119,9 +121,9 @@ async function renameColumn(schemaName, tableName, fromName, toName, lowerer) {
|
|
|
119
121
|
label: `Rename column "${tableName}"."${fromName}" to "${toName}"`,
|
|
120
122
|
operationClass: "widening",
|
|
121
123
|
target: targetDetails("column", toName, schemaName, tableName),
|
|
122
|
-
precheck: [step(`ensure column "${fromName}" exists`, from.present.sql, from.present.params), step(`ensure column "${toName}" does not exist`, to.absent.sql, to.absent.params)],
|
|
124
|
+
precheck: [step(`ensure column "${fromName}" exists`, from.present.sql, from.present.params, expectPresent(`column "${fromName}" on "${tableName}"`)), step(`ensure column "${toName}" does not exist`, to.absent.sql, to.absent.params, expectAbsent(`column "${toName}" on "${tableName}"`))],
|
|
123
125
|
execute: [step(`rename column "${fromName}" to "${toName}"`, renameColumnStatement(schemaName, tableName, fromName, toName))],
|
|
124
|
-
postcheck: [step(`verify column "${toName}" exists`, to.present.sql, to.present.params), step(`verify column "${fromName}" no longer exists`, from.absent.sql, from.absent.params)]
|
|
126
|
+
postcheck: [step(`verify column "${toName}" exists`, to.present.sql, to.present.params, expectPresent(`column "${toName}" on "${tableName}"`)), step(`verify column "${fromName}" no longer exists`, from.absent.sql, from.absent.params, expectAbsent(`column "${fromName}" on "${tableName}"`))]
|
|
125
127
|
};
|
|
126
128
|
}
|
|
127
129
|
/**
|
|
@@ -163,7 +165,7 @@ async function alterColumnType(schemaName, tableName, columnName, options, lower
|
|
|
163
165
|
label: `Alter type of "${tableName}"."${columnName}" to ${options.type}`,
|
|
164
166
|
operationClass,
|
|
165
167
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
166
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params), ...sequenceSteps.precheck],
|
|
168
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), ...sequenceSteps.precheck],
|
|
167
169
|
execute: [{
|
|
168
170
|
...step(`alter type of "${columnName}" to ${options.type}`, alterType.sql),
|
|
169
171
|
...options.using !== void 0 ? { meta: convertedColumnMeta(tableName, columnName, "conversion") } : operationClass === "destructive" ? { meta: convertedColumnMeta(tableName, columnName, "cast") } : {}
|
|
@@ -231,7 +233,7 @@ async function setNotNull(schemaName, tableName, columnName, lowerer) {
|
|
|
231
233
|
label: `Set NOT NULL on "${tableName}"."${columnName}"`,
|
|
232
234
|
operationClass: "widening",
|
|
233
235
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
234
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params), {
|
|
236
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), {
|
|
235
237
|
...step(`ensure no NULL values in "${columnName}"`, noNulls.sql, noNulls.params),
|
|
236
238
|
meta: requiredColumnMeta(tableName, columnName, "nullValues")
|
|
237
239
|
}],
|
|
@@ -257,7 +259,7 @@ async function dropNotNull(schemaName, tableName, columnName, lowerer) {
|
|
|
257
259
|
label: `Drop NOT NULL on "${tableName}"."${columnName}"`,
|
|
258
260
|
operationClass: "widening",
|
|
259
261
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
260
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
262
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
261
263
|
execute: [step(`drop NOT NULL on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`)],
|
|
262
264
|
postcheck: [step(`verify column "${columnName}" is nullable`, nullable.sql, nullable.params)]
|
|
263
265
|
};
|
|
@@ -291,7 +293,7 @@ async function setDefault(schemaName, tableName, column, lowerer, operationClass
|
|
|
291
293
|
label: `Set default on "${tableName}"."${columnName}"`,
|
|
292
294
|
operationClass,
|
|
293
295
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
294
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
296
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
295
297
|
execute: [step(`set default on "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${clause}`)],
|
|
296
298
|
postcheck: []
|
|
297
299
|
};
|
|
@@ -341,7 +343,7 @@ async function setAutoincrementDefault(schemaName, tableName, column, lowerer, o
|
|
|
341
343
|
label: `Set default on "${tableName}"."${columnName}"`,
|
|
342
344
|
operationClass,
|
|
343
345
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
344
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params), step(`ensure column "${columnName}" owns a sequence or no relation is named ${qualifiedSequence} (rename that relation, or write this migration with migration new)`, nameAvailable.sql, nameAvailable.params)],
|
|
346
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)), step(`ensure column "${columnName}" owns a sequence or no relation is named ${qualifiedSequence} (rename that relation, or write this migration with migration new)`, nameAvailable.sql, nameAvailable.params)],
|
|
345
347
|
execute: [
|
|
346
348
|
step(`create sequence "${sequenceName}" owned by "${columnName}" unless the column owns one`, doBlock(`IF ${ownedSequence} IS NULL THEN CREATE SEQUENCE ${qualifiedSequence} AS ${sequenceType}; ALTER SEQUENCE ${qualifiedSequence} OWNED BY ${qualifiedTable}.${qualifiedColumn}; END IF;`)),
|
|
347
349
|
step(`change the sequence column "${columnName}" owns to ${sequenceType}`, doBlock(alterOwnedSequenceTypeStatement(location, sequenceType))),
|
|
@@ -372,7 +374,7 @@ async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
|
372
374
|
label: `Drop default on "${tableName}"."${columnName}"`,
|
|
373
375
|
operationClass: "widening",
|
|
374
376
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
375
|
-
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
377
|
+
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`))],
|
|
376
378
|
execute: [step(`drop default on "${columnName}"`, dropDefaultExec.sql)],
|
|
377
379
|
postcheck: [step(`verify column "${columnName}" has no default`, noDefault.sql, noDefault.params)]
|
|
378
380
|
};
|
|
@@ -418,13 +420,13 @@ async function addRequiredColumnToEmptyTable(schemaName, tableName, column, chec
|
|
|
418
420
|
summary: `Adds column ${columnName} to table ${tableName}`,
|
|
419
421
|
operationClass: "additive",
|
|
420
422
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
421
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params), {
|
|
423
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`)), {
|
|
422
424
|
...step(`ensure table "${tableName}" is empty before adding NOT NULL column without default`, tableEmpty.sql, tableEmpty.params),
|
|
423
425
|
meta: requiredColumnMeta(tableName, columnName, "newField")
|
|
424
426
|
}],
|
|
425
427
|
execute: [step(`add column "${columnName}"`, addColumn.sql)],
|
|
426
428
|
postcheck: [
|
|
427
|
-
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
429
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
428
430
|
step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params),
|
|
429
431
|
hasType
|
|
430
432
|
]
|
|
@@ -488,7 +490,7 @@ async function addPrimaryKey(schemaName, tableName, constraintName, columns, low
|
|
|
488
490
|
label: `Add primary key on "${tableName}"`,
|
|
489
491
|
operationClass: "additive",
|
|
490
492
|
target: targetDetails("primaryKey", constraintName, schemaName, tableName),
|
|
491
|
-
precheck: [step(`ensure primary key "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
493
|
+
precheck: [step(`ensure primary key "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`primary key "${constraintName}" on "${tableName}"`))],
|
|
492
494
|
execute: [step(`add primary key "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`)],
|
|
493
495
|
postcheck: [defined]
|
|
494
496
|
};
|
|
@@ -513,7 +515,7 @@ async function addUnique(schemaName, tableName, constraintName, columns, lowerer
|
|
|
513
515
|
label: `Add unique constraint on "${tableName}" (${columns.join(", ")})`,
|
|
514
516
|
operationClass: "additive",
|
|
515
517
|
target: targetDetails("unique", constraintName, schemaName, tableName),
|
|
516
|
-
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
518
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
517
519
|
execute: [step(`add unique constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`)],
|
|
518
520
|
postcheck: [defined]
|
|
519
521
|
};
|
|
@@ -543,7 +545,7 @@ async function addForeignKey(schemaName, tableName, fk, lowerer) {
|
|
|
543
545
|
label: `Add foreign key "${fk.name}" on "${tableName}"`,
|
|
544
546
|
operationClass: "additive",
|
|
545
547
|
target: targetDetails("foreignKey", fk.name, schemaName, tableName),
|
|
546
|
-
precheck: [step(`ensure FK "${fk.name}" does not exist`, absent.sql, absent.params)],
|
|
548
|
+
precheck: [step(`ensure FK "${fk.name}" does not exist`, absent.sql, absent.params, expectAbsent(`FK "${fk.name}" on "${tableName}"`))],
|
|
547
549
|
execute: [step(`add FK "${fk.name}"`, renderForeignKeySql(schemaName, tableName, fk))],
|
|
548
550
|
postcheck: [defined]
|
|
549
551
|
};
|
|
@@ -570,7 +572,7 @@ async function addCheckConstraint(schemaName, tableName, constraintName, express
|
|
|
570
572
|
label: `Add check constraint "${constraintName}" on "${tableName}"`,
|
|
571
573
|
operationClass: "additive",
|
|
572
574
|
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
573
|
-
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
|
|
575
|
+
precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
574
576
|
execute: [step(`add check constraint "${constraintName}"`, addCheck.sql)],
|
|
575
577
|
postcheck: [defined]
|
|
576
578
|
};
|
|
@@ -604,9 +606,9 @@ async function renameConstraint(schemaName, tableName, kind, fromName, toName, l
|
|
|
604
606
|
label: renameConstraintLabel(kind, fromName, toName, tableName),
|
|
605
607
|
operationClass: "widening",
|
|
606
608
|
target: targetDetails(kind, toName, schemaName, tableName),
|
|
607
|
-
precheck: [step(`ensure constraint "${fromName}" exists`, from.present.sql, from.present.params), step(`ensure constraint "${toName}" does not exist`, to.absent.sql, to.absent.params)],
|
|
609
|
+
precheck: [step(`ensure constraint "${fromName}" exists`, from.present.sql, from.present.params, expectPresent(`constraint "${fromName}" on "${tableName}"`)), step(`ensure constraint "${toName}" does not exist`, to.absent.sql, to.absent.params, expectAbsent(`constraint "${toName}" on "${tableName}"`))],
|
|
608
610
|
execute: [step(`rename ${CONSTRAINT_KIND_LABEL[kind]} "${fromName}" to "${toName}"`, `ALTER TABLE ${qualified} RENAME CONSTRAINT ${quoteIdentifier(fromName)} TO ${quoteIdentifier(toName)}`)],
|
|
609
|
-
postcheck: [step(`verify constraint "${toName}" exists`, to.present.sql, to.present.params), step(`verify constraint "${fromName}" no longer exists`, from.absent.sql, from.absent.params)]
|
|
611
|
+
postcheck: [step(`verify constraint "${toName}" exists`, to.present.sql, to.present.params, expectPresent(`constraint "${toName}" on "${tableName}"`)), step(`verify constraint "${fromName}" no longer exists`, from.absent.sql, from.absent.params, expectAbsent(`constraint "${fromName}" on "${tableName}"`))]
|
|
610
612
|
};
|
|
611
613
|
}
|
|
612
614
|
async function dropCheckConstraint(schemaName, tableName, constraintName, lowerer) {
|
|
@@ -621,9 +623,9 @@ async function dropCheckConstraint(schemaName, tableName, constraintName, lowere
|
|
|
621
623
|
label: `Drop check constraint "${constraintName}" on "${tableName}"`,
|
|
622
624
|
operationClass: "widening",
|
|
623
625
|
target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
|
|
624
|
-
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params)],
|
|
626
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params, expectPresent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
625
627
|
execute: [step(`drop check constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
626
|
-
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params)]
|
|
628
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))]
|
|
627
629
|
};
|
|
628
630
|
}
|
|
629
631
|
/**
|
|
@@ -645,9 +647,9 @@ async function dropConstraint(schemaName, tableName, constraintName, lowerer, ki
|
|
|
645
647
|
label: `Drop constraint "${constraintName}" on "${tableName}"`,
|
|
646
648
|
operationClass: "widening",
|
|
647
649
|
target: targetDetails(kind, constraintName, schemaName, tableName),
|
|
648
|
-
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params)],
|
|
650
|
+
precheck: [step(`ensure constraint "${constraintName}" exists`, present.sql, present.params, expectPresent(`constraint "${constraintName}" on "${tableName}"`))],
|
|
649
651
|
execute: [step(`drop constraint "${constraintName}"`, `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`)],
|
|
650
|
-
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params)]
|
|
652
|
+
postcheck: [step(`verify constraint "${constraintName}" does not exist`, absent.sql, absent.params, expectAbsent(`constraint "${constraintName}" on "${tableName}"`))]
|
|
651
653
|
};
|
|
652
654
|
}
|
|
653
655
|
function createExtension(extensionName) {
|
|
@@ -694,9 +696,9 @@ async function installExtension(options, lowerer) {
|
|
|
694
696
|
name: extensionName
|
|
695
697
|
}
|
|
696
698
|
},
|
|
697
|
-
precheck: [step(`verify extension "${extensionName}" is not already enabled`, absent.sql, absent.params)],
|
|
699
|
+
precheck: [step(`verify extension "${extensionName}" is not already enabled`, absent.sql, absent.params, expectAbsent(`extension "${extensionName}"`))],
|
|
698
700
|
execute: [step(`create extension "${extensionName}"`, `CREATE EXTENSION IF NOT EXISTS ${extensionName}`)],
|
|
699
|
-
postcheck: [step(`confirm extension "${extensionName}" is enabled`, present.sql, present.params)]
|
|
701
|
+
postcheck: [step(`confirm extension "${extensionName}" is enabled`, present.sql, present.params, expectPresent(`extension "${extensionName}"`))]
|
|
700
702
|
};
|
|
701
703
|
}
|
|
702
704
|
async function indexExistsSteps(lowerer, schemaName, indexName) {
|
|
@@ -737,7 +739,7 @@ async function createIndex(schemaName, tableName, indexName, elements, lowerer,
|
|
|
737
739
|
label: `Create index "${indexName}" on "${tableName}"`,
|
|
738
740
|
operationClass: "additive",
|
|
739
741
|
target: targetDetails("index", indexName, schemaName, tableName),
|
|
740
|
-
precheck: [step(`ensure index "${indexName}" does not exist`, absent.sql, absent.params)],
|
|
742
|
+
precheck: [step(`ensure index "${indexName}" does not exist`, absent.sql, absent.params, expectAbsent(`index "${indexName}"`))],
|
|
741
743
|
execute: [step(`create index "${indexName}"`, execute.sql, execute.params)],
|
|
742
744
|
postcheck: [step(`verify index "${indexName}" exists on "${tableName}" with the planned definition`, defined.sql, defined.params)]
|
|
743
745
|
};
|
|
@@ -764,9 +766,9 @@ async function renameIndex(schemaName, tableName, fromName, toName, lowerer) {
|
|
|
764
766
|
label: `Rename index "${fromName}" to "${toName}" on "${tableName}"`,
|
|
765
767
|
operationClass: "widening",
|
|
766
768
|
target: targetDetails("index", toName, schemaName, tableName),
|
|
767
|
-
precheck: [step(`ensure index "${fromName}" exists`, fromPresent.sql, fromPresent.params), step(`ensure index "${toName}" does not exist`, toAbsent.sql, toAbsent.params)],
|
|
769
|
+
precheck: [step(`ensure index "${fromName}" exists`, fromPresent.sql, fromPresent.params, expectPresent(`index "${fromName}"`)), step(`ensure index "${toName}" does not exist`, toAbsent.sql, toAbsent.params, expectAbsent(`index "${toName}"`))],
|
|
768
770
|
execute: [step(`rename index "${fromName}" to "${toName}"`, execute.sql, execute.params)],
|
|
769
|
-
postcheck: [step(`verify index "${toName}" exists`, toPresent.sql, toPresent.params), step(`verify index "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params)]
|
|
771
|
+
postcheck: [step(`verify index "${toName}" exists`, toPresent.sql, toPresent.params, expectPresent(`index "${toName}"`)), step(`verify index "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params, expectAbsent(`index "${fromName}"`))]
|
|
770
772
|
};
|
|
771
773
|
}
|
|
772
774
|
async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
@@ -781,9 +783,9 @@ async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
|
781
783
|
label: `Drop index "${indexName}"`,
|
|
782
784
|
operationClass: "widening",
|
|
783
785
|
target: targetDetails("index", indexName, schemaName, tableName),
|
|
784
|
-
precheck: [step(`ensure index "${indexName}" exists`, present.sql, present.params)],
|
|
786
|
+
precheck: [step(`ensure index "${indexName}" exists`, present.sql, present.params, expectPresent(`index "${indexName}"`))],
|
|
785
787
|
execute: [step(`drop index "${indexName}"`, execute.sql, execute.params)],
|
|
786
|
-
postcheck: [step(`verify index "${indexName}" does not exist`, absent.sql, absent.params)]
|
|
788
|
+
postcheck: [step(`verify index "${indexName}" does not exist`, absent.sql, absent.params, expectAbsent(`index "${indexName}"`))]
|
|
787
789
|
};
|
|
788
790
|
}
|
|
789
791
|
/**
|
|
@@ -874,7 +876,7 @@ async function createRlsPolicy(schemaName, tableName, policy, lowerer) {
|
|
|
874
876
|
label: `Create RLS policy "${policy.name}" on "${tableName}"`,
|
|
875
877
|
operationClass: "additive",
|
|
876
878
|
target: targetDetails("rlsPolicy", policy.name, schemaName, tableName),
|
|
877
|
-
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params)],
|
|
879
|
+
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params, expectAbsent(`RLS policy "${policy.name}" on "${tableName}"`))],
|
|
878
880
|
execute: [step(`create RLS policy "${policy.name}"`, execute.sql, execute.params)],
|
|
879
881
|
postcheck: [step(`verify RLS policy "${policy.name}" exists with the planned command, roles and permissiveness`, defined.sql, defined.params)]
|
|
880
882
|
};
|
|
@@ -898,9 +900,9 @@ async function dropRlsPolicy(schemaName, tableName, policyName, lowerer) {
|
|
|
898
900
|
label: `Drop RLS policy "${policyName}" on "${tableName}"`,
|
|
899
901
|
operationClass: "widening",
|
|
900
902
|
target: targetDetails("rlsPolicy", policyName, schemaName, tableName),
|
|
901
|
-
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params)],
|
|
903
|
+
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params, expectPresent(`RLS policy "${policyName}" on "${tableName}"`))],
|
|
902
904
|
execute: [step(`drop RLS policy "${policyName}"`, execute.sql, execute.params)],
|
|
903
|
-
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params)]
|
|
905
|
+
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params, expectAbsent(`RLS policy "${policyName}" on "${tableName}"`))]
|
|
904
906
|
};
|
|
905
907
|
}
|
|
906
908
|
async function enableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
@@ -963,9 +965,9 @@ async function renameRlsPolicy(schemaName, tableName, oldPolicyName, newPolicyNa
|
|
|
963
965
|
label: `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`,
|
|
964
966
|
operationClass: "widening",
|
|
965
967
|
target: targetDetails("rlsPolicy", newPolicyName, schemaName, tableName),
|
|
966
|
-
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params), step(`ensure RLS policy "${newPolicyName}" does not exist`, newAbsent.sql, newAbsent.params)],
|
|
968
|
+
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params, expectPresent(`RLS policy "${oldPolicyName}" on "${tableName}"`)), step(`ensure RLS policy "${newPolicyName}" does not exist`, newAbsent.sql, newAbsent.params, expectAbsent(`RLS policy "${newPolicyName}" on "${tableName}"`))],
|
|
967
969
|
execute: [step(`rename RLS policy "${oldPolicyName}" to "${newPolicyName}"`, execute.sql, execute.params)],
|
|
968
|
-
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params), step(`verify RLS policy "${oldPolicyName}" no longer exists`, oldAbsent.sql, oldAbsent.params)]
|
|
970
|
+
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params, expectPresent(`RLS policy "${newPolicyName}" on "${tableName}"`)), step(`verify RLS policy "${oldPolicyName}" no longer exists`, oldAbsent.sql, oldAbsent.params, expectAbsent(`RLS policy "${oldPolicyName}" on "${tableName}"`))]
|
|
969
971
|
};
|
|
970
972
|
}
|
|
971
973
|
async function dropTable(schemaName, tableName, lowerer) {
|
|
@@ -978,9 +980,9 @@ async function dropTable(schemaName, tableName, lowerer) {
|
|
|
978
980
|
label: `Drop table "${tableName}"`,
|
|
979
981
|
operationClass: "destructive",
|
|
980
982
|
target: targetDetails("table", tableName, schemaName),
|
|
981
|
-
precheck: [step(`ensure table "${tableName}" exists`, present.sql, present.params)],
|
|
983
|
+
precheck: [step(`ensure table "${tableName}" exists`, present.sql, present.params, expectPresent(`table "${tableName}"`))],
|
|
982
984
|
execute: [step(`drop table "${tableName}"`, `DROP TABLE ${qualified}`)],
|
|
983
|
-
postcheck: [step(`verify table "${tableName}" does not exist`, absent.sql, absent.params)]
|
|
985
|
+
postcheck: [step(`verify table "${tableName}" does not exist`, absent.sql, absent.params, expectAbsent(`table "${tableName}"`))]
|
|
984
986
|
};
|
|
985
987
|
}
|
|
986
988
|
function renameTableStatement(schemaName, fromName, toName) {
|
|
@@ -1001,9 +1003,9 @@ async function renameTable(schemaName, fromName, toName, lowerer) {
|
|
|
1001
1003
|
label: `Rename table "${fromName}" to "${toName}"`,
|
|
1002
1004
|
operationClass: "widening",
|
|
1003
1005
|
target: targetDetails("table", toName, schemaName),
|
|
1004
|
-
precheck: [step(`ensure table "${fromName}" exists`, fromPresent.sql, fromPresent.params), step(`ensure table "${toName}" does not exist`, toAbsent.sql, toAbsent.params)],
|
|
1006
|
+
precheck: [step(`ensure table "${fromName}" exists`, fromPresent.sql, fromPresent.params, expectPresent(`table "${fromName}"`)), step(`ensure table "${toName}" does not exist`, toAbsent.sql, toAbsent.params, expectAbsent(`table "${toName}"`))],
|
|
1005
1007
|
execute: [step(`rename table "${fromName}" to "${toName}"`, renameTableStatement(schemaName, fromName, toName))],
|
|
1006
|
-
postcheck: [step(`verify table "${toName}" exists`, toPresent.sql, toPresent.params), step(`verify table "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params)]
|
|
1008
|
+
postcheck: [step(`verify table "${toName}" exists`, toPresent.sql, toPresent.params, expectPresent(`table "${toName}"`)), step(`verify table "${fromName}" no longer exists`, fromAbsent.sql, fromAbsent.params, expectAbsent(`table "${fromName}"`))]
|
|
1007
1009
|
};
|
|
1008
1010
|
}
|
|
1009
1011
|
function buildAddColumnOperationIdentity(schema, tableName, columnName) {
|
|
@@ -1062,7 +1064,7 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
1062
1064
|
return {
|
|
1063
1065
|
...buildAddColumnOperationIdentity(schema, tableName, columnName),
|
|
1064
1066
|
operationClass: "additive",
|
|
1065
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
1067
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))],
|
|
1066
1068
|
execute: [{
|
|
1067
1069
|
description: `add column "${columnName}"`,
|
|
1068
1070
|
sql: addColumn.sql
|
|
@@ -1071,7 +1073,7 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
1071
1073
|
sql: dropTempDefault.sql
|
|
1072
1074
|
}],
|
|
1073
1075
|
postcheck: [
|
|
1074
|
-
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
1076
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
1075
1077
|
step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params),
|
|
1076
1078
|
step(`verify column "${columnName}" has no default after temporary default removal`, noDefault.sql, noDefault.params),
|
|
1077
1079
|
hasType
|
|
@@ -1228,13 +1230,13 @@ var CreateTableCall = class extends PostgresOpFactoryCallNode {
|
|
|
1228
1230
|
summary: `Creates table "${tableName}"`,
|
|
1229
1231
|
operationClass: "additive",
|
|
1230
1232
|
target: targetDetails("table", tableName, schemaName),
|
|
1231
|
-
precheck: [step(`ensure table "${tableName}" does not exist`, absent.sql, absent.params)],
|
|
1233
|
+
precheck: [step(`ensure table "${tableName}" does not exist`, absent.sql, absent.params, expectAbsent(`table "${tableName}"`))],
|
|
1232
1234
|
execute: [{
|
|
1233
1235
|
description: `create table "${tableName}"`,
|
|
1234
1236
|
sql: statement.sql,
|
|
1235
1237
|
params: statement.params ?? []
|
|
1236
1238
|
}],
|
|
1237
|
-
postcheck: [step(`verify table "${tableName}" exists`, isTable.sql, isTable.params)]
|
|
1239
|
+
postcheck: [step(`verify table "${tableName}" exists`, isTable.sql, isTable.params, expectPresent(`table "${tableName}"`))]
|
|
1238
1240
|
};
|
|
1239
1241
|
}
|
|
1240
1242
|
renderTypeScript() {
|
|
@@ -1389,10 +1391,10 @@ var AddColumnCall = class extends PostgresOpFactoryCallNode {
|
|
|
1389
1391
|
label: `Add column "${columnName}" to "${tableName}"`,
|
|
1390
1392
|
operationClass: "additive",
|
|
1391
1393
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
1392
|
-
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
1394
|
+
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params, expectAbsent(`column "${columnName}" on "${tableName}"`))],
|
|
1393
1395
|
execute: [step(`add column "${columnName}"`, statement.sql)],
|
|
1394
1396
|
postcheck: [
|
|
1395
|
-
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
1397
|
+
step(`verify column "${columnName}" exists`, present.sql, present.params, expectPresent(`column "${columnName}" on "${tableName}"`)),
|
|
1396
1398
|
hasType,
|
|
1397
1399
|
...notNullable.map((check) => step(`verify column "${columnName}" is NOT NULL`, check.sql, check.params)),
|
|
1398
1400
|
...sequenceDefault.map((check) => step(`verify column "${columnName}" takes its default from an attached sequence`, check.sql, check.params))
|
|
@@ -2389,9 +2391,9 @@ var AddNativeEnumValueCall = class extends PostgresOpFactoryCallNode {
|
|
|
2389
2391
|
summary: this.summary,
|
|
2390
2392
|
operationClass: "additive",
|
|
2391
2393
|
target: targetDetails("type", typeName, schemaName),
|
|
2392
|
-
precheck: [step(`ensure enum type "${typeName}" exists`, typePresent.sql, typePresent.params), step(`ensure value "${value}" is absent from enum type "${typeName}"`, valueAbsent.sql, valueAbsent.params)],
|
|
2394
|
+
precheck: [step(`ensure enum type "${typeName}" exists`, typePresent.sql, typePresent.params, expectPresent(`enum type "${typeName}"`)), step(`ensure value "${value}" is absent from enum type "${typeName}"`, valueAbsent.sql, valueAbsent.params, expectAbsent(`value "${value}" in enum type "${typeName}"`))],
|
|
2393
2395
|
execute: [step(`add value "${value}" to enum type "${typeName}"`, `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`)],
|
|
2394
|
-
postcheck: [step(`verify value "${value}" exists on enum type "${typeName}"`, valuePresent.sql, valuePresent.params)]
|
|
2396
|
+
postcheck: [step(`verify value "${value}" exists on enum type "${typeName}"`, valuePresent.sql, valuePresent.params, expectPresent(`value "${value}" in enum type "${typeName}"`))]
|
|
2395
2397
|
};
|
|
2396
2398
|
}
|
|
2397
2399
|
renderTypeScript() {
|
|
@@ -2612,4 +2614,4 @@ function columnNameOfCall(call) {
|
|
|
2612
2614
|
//#endregion
|
|
2613
2615
|
export { RenameConstraintCall as A, isPostgresOpFactoryCall as B, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, SetNotNullCall as F, renameTableStatement as H, alterColumnTypeCallText as I, columnNameOfCall as L, RenamePostgresRlsPolicyCall as M, RenameTableCall as N, RawSqlCall as O, SetDefaultCall as P, createExtension as R, DropIndexCall as S, DropPostgresRlsPolicyCall as T, postgresDefaultToDdlColumnDefault as V, DisableRowLevelSecurityCall as _, AddNativeEnumValueCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddForeignKeyCall as i, RenameIndexCall as j, RenameColumnCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreatePostgresRlsPolicyCall as p, AddColumnWithTemporaryDefaultCall as r, AddRequiredColumnToEmptyTableCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y, installExtension as z };
|
|
2614
2616
|
|
|
2615
|
-
//# sourceMappingURL=op-factory-call-
|
|
2617
|
+
//# sourceMappingURL=op-factory-call-CtHJKITc-BMwiP_p7.mjs.map
|