@prisma-next/target-postgres 0.14.0-dev.7 → 0.14.0-dev.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/authoring-Bi9aa8zG.mjs +574 -0
- package/dist/authoring-Bi9aa8zG.mjs.map +1 -0
- package/dist/canonicalize-CAbXtVtB.d.mts +37 -0
- package/dist/canonicalize-CAbXtVtB.d.mts.map +1 -0
- package/dist/{codec-ids-CnXu9Qy3.d.mts → codec-ids-BzrFF-I4.d.mts} +3 -2
- package/dist/codec-ids-BzrFF-I4.d.mts.map +1 -0
- package/dist/{codec-ids-BvytN2P8.mjs → codec-ids-C_-Hj6bL.mjs} +3 -2
- package/dist/codec-ids-C_-Hj6bL.mjs.map +1 -0
- package/dist/codec-ids.d.mts +2 -2
- package/dist/codec-ids.mjs +2 -2
- package/dist/{codec-types-DHCkwPKE.d.mts → codec-types-BiIWziRO.d.mts} +3 -2
- package/dist/codec-types-BiIWziRO.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/codecs-Cl_hQHg-.mjs +913 -0
- package/dist/codecs-Cl_hQHg-.mjs.map +1 -0
- package/dist/{codecs--0A5_4Bq.d.mts → codecs-Cm-nS4mQ.d.mts} +111 -4
- package/dist/codecs-Cm-nS4mQ.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +3 -757
- package/dist/codecs.mjs.map +1 -1
- package/dist/contract-free.d.mts +33 -3
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +23 -7
- package/dist/contract-free.mjs.map +1 -1
- package/dist/control-policy-5_5odTg9.mjs +1258 -0
- package/dist/control-policy-5_5odTg9.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +866 -36
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{data-transform-DDgWdB5o.d.mts → data-transform-DPzwBMhW.d.mts} +3 -3
- package/dist/{data-transform-DDgWdB5o.d.mts.map → data-transform-DPzwBMhW.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/{ddl-QDyOSeLc.mjs → ddl-Dqgs-bDc.mjs} +93 -6
- package/dist/ddl-Dqgs-bDc.mjs.map +1 -0
- package/dist/ddl.d.mts +3 -2
- package/dist/ddl.mjs +2 -2
- package/dist/default-normalizer.d.mts +1 -1
- package/dist/default-normalizer.d.mts.map +1 -1
- package/dist/default-normalizer.mjs +247 -1
- package/dist/default-normalizer.mjs.map +1 -0
- package/dist/descriptor-meta-UugzVM-U.mjs +22 -0
- package/dist/descriptor-meta-UugzVM-U.mjs.map +1 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs +12 -0
- package/dist/descriptor-meta-runtime-UwYdV8fD.mjs.map +1 -0
- package/dist/diff-database-schema-Dis8SMoT.mjs +305 -0
- package/dist/diff-database-schema-Dis8SMoT.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +46 -0
- package/dist/diff-database-schema.d.mts.map +1 -0
- package/dist/diff-database-schema.mjs +2 -0
- package/dist/errors-DO-w0EUS.mjs +35 -0
- package/dist/errors-DO-w0EUS.mjs.map +1 -0
- package/dist/errors.d.mts +11 -9
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/issue-planner.d.mts +35 -11
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +2 -2
- package/dist/migration.d.mts +5 -5
- package/dist/migration.d.mts.map +1 -1
- package/dist/migration.mjs +4 -4
- package/dist/namespace-ids-xtp_ZY86.mjs +7 -0
- package/dist/namespace-ids-xtp_ZY86.mjs.map +1 -0
- package/dist/native-type-normalizer.mjs +37 -1
- package/dist/native-type-normalizer.mjs.map +1 -0
- package/dist/nodes-Bc2N3tMy.d.mts +170 -0
- package/dist/nodes-Bc2N3tMy.d.mts.map +1 -0
- package/dist/nodes-DJC5B8Id.mjs +192 -0
- package/dist/nodes-DJC5B8Id.mjs.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-CSIg5XDu.d.mts} +91 -15
- package/dist/op-factory-call-CSIg5XDu.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-WFZUHrbI.mjs} +400 -32
- package/dist/op-factory-call-WFZUHrbI.mjs.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 +300 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-BXlWpNsT.mjs +390 -0
- package/dist/planner-BXlWpNsT.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-BKlmGDJl.mjs} +17 -28
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +4 -6
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +2 -2
- package/dist/planner-identity-values-CJPha2Sz.mjs.map +1 -1
- package/dist/planner-identity-values.d.mts +8 -2
- package/dist/planner-identity-values.d.mts.map +1 -1
- package/dist/planner-identity-values.mjs +2 -2
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs → planner-produced-postgres-migration-C8vSaHku.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-C8vSaHku.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-CXue-6M9.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-CXue-6M9.d.mts.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-sql-checks-jqUUGyQR.mjs → planner-sql-checks-CxJ8W66T.mjs} +3 -3
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-CxJ8W66T.mjs.map} +1 -1
- package/dist/planner-sql-checks.d.mts +2 -2
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-CIY6tLeo.d.mts → planner-target-details-HkP4RrRO.d.mts} +2 -2
- package/dist/planner-target-details-HkP4RrRO.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +72 -17
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +3 -2
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-C3LPCLP_.mjs} +45 -41
- package/dist/postgres-contract-view-C3LPCLP_.mjs.map +1 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts +262 -0
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-B3u0erMT.mjs} +69 -45
- package/dist/postgres-migration-B3u0erMT.mjs.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-DkmgGNcv.d.mts} +47 -9
- package/dist/postgres-migration-DkmgGNcv.d.mts.map +1 -0
- package/dist/postgres-native-enum-BwVNf0Ku.mjs +45 -0
- package/dist/postgres-native-enum-BwVNf0Ku.mjs.map +1 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts +52 -0
- package/dist/postgres-rls-policy--CSddvMR.d.mts.map +1 -0
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs +190 -0
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts +269 -0
- package/dist/postgres-schema-DKq6s1P3.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DYATroNx.mjs} +200 -11
- package/dist/postgres-schema-DYATroNx.mjs.map +1 -0
- package/dist/postgres-table-schema-node-D6LvInCe.mjs +216 -0
- package/dist/postgres-table-schema-node-D6LvInCe.mjs.map +1 -0
- package/dist/render-ops.d.mts +1 -1
- package/dist/{render-typescript-KMgosran.mjs → render-typescript-7yqILcwr.mjs} +45 -16
- package/dist/render-typescript-7yqILcwr.mjs.map +1 -0
- package/dist/render-typescript.mjs +1 -1
- package/dist/resolve-ddl-schema-DpGte50u.mjs +22 -0
- package/dist/resolve-ddl-schema-DpGte50u.mjs.map +1 -0
- package/dist/rls-canonicalize.d.mts +20 -0
- package/dist/rls-canonicalize.d.mts.map +1 -0
- package/dist/rls-canonicalize.mjs +2 -0
- package/dist/runtime.d.mts +6 -8
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +3 -3
- package/dist/runtime.mjs.map +1 -1
- package/dist/schema-ir-annotations.d.mts +15 -0
- package/dist/schema-ir-annotations.d.mts.map +1 -0
- package/dist/schema-ir-annotations.mjs +2 -0
- package/dist/{sql-utils-DcfMz4MQ.mjs → sql-utils-SU4FDvIV.mjs} +12 -3
- package/dist/{sql-utils-DcfMz4MQ.mjs.map → sql-utils-SU4FDvIV.mjs.map} +1 -1
- package/dist/sql-utils.d.mts +8 -1
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -2
- package/dist/types.d.mts +4 -140
- package/dist/types.mjs +5 -2
- package/dist/wire-name-rHHtr1h0.mjs +75 -0
- package/dist/wire-name-rHHtr1h0.mjs.map +1 -0
- package/package.json +23 -17
- package/src/contract-free/checks.ts +73 -0
- package/src/contract-free/control-bootstrap.ts +20 -3
- package/src/contract-free/ddl.ts +98 -1
- package/src/core/authoring.ts +509 -2
- package/src/core/codec-ids.ts +1 -0
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +180 -1
- package/src/core/ddl/nodes.ts +185 -2
- package/src/core/default-normalizer.ts +122 -2
- package/src/core/descriptor-meta.ts +10 -1
- package/src/core/entity-kinds.ts +41 -0
- package/src/core/errors.ts +14 -12
- package/src/core/migrations/bound-schema.ts +10 -0
- package/src/core/migrations/column-ddl-rendering.ts +117 -0
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +189 -0
- package/src/core/migrations/control-policy.ts +217 -65
- package/src/core/migrations/diff-database-schema.ts +252 -0
- package/src/core/migrations/issue-planner.ts +769 -656
- package/src/core/migrations/op-factory-call.ts +273 -21
- package/src/core/migrations/operations/columns.ts +24 -12
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/operations/data-transform.ts +6 -0
- package/src/core/migrations/operations/dependencies.ts +2 -1
- package/src/core/migrations/operations/native-enum-types.ts +62 -0
- package/src/core/migrations/operations/rls.ts +187 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +31 -59
- package/src/core/migrations/planner-identity-values.ts +1 -1
- package/src/core/migrations/planner-recipes.ts +31 -13
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +248 -216
- package/src/core/migrations/planner-target-details.ts +3 -1
- package/src/core/migrations/planner.ts +357 -67
- package/src/core/migrations/postgres-migration.ts +101 -86
- package/src/core/migrations/render-typescript.ts +42 -15
- package/src/core/migrations/resolve-ddl-schema.ts +26 -0
- package/src/core/migrations/runner.ts +11 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +46 -31
- package/src/core/namespace-ids.ts +3 -0
- package/src/core/postgres-contract-serializer.ts +46 -71
- package/src/core/postgres-contract-view.ts +48 -0
- package/src/core/postgres-native-enum.ts +61 -0
- package/src/core/postgres-rls-enablement.ts +34 -0
- package/src/core/postgres-rls-policy.ts +64 -0
- package/src/core/postgres-role.ts +59 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +85 -15
- package/src/core/postgres-validators.ts +34 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1273 -0
- package/src/core/psl-infer/postgres-default-mapping.ts +16 -0
- package/src/core/psl-infer/postgres-type-map.ts +128 -0
- package/src/core/rls/canonicalize.ts +48 -0
- package/src/core/rls/wire-name.ts +33 -0
- package/src/core/schema-ir/node-storage-coordinate.ts +26 -0
- package/src/core/schema-ir/postgres-database-schema-node.ts +61 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +70 -0
- package/src/core/schema-ir/postgres-native-enum-schema-node.ts +83 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +65 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
- package/src/core/schema-ir/schema-node-kinds.ts +122 -0
- package/src/core/sql-utils.ts +15 -2
- package/src/exports/codecs.ts +3 -0
- package/src/exports/contract-free.ts +11 -1
- package/src/exports/control.ts +27 -33
- package/src/exports/ddl.ts +8 -0
- package/src/exports/diff-database-schema.ts +7 -0
- package/src/exports/issue-planner.ts +1 -1
- package/src/exports/migration.ts +1 -0
- package/src/exports/op-factory-call.ts +3 -0
- package/src/exports/planner-ddl-builders.ts +0 -2
- package/src/exports/planner-identity-values.ts +4 -1
- package/src/exports/planner.ts +1 -0
- package/src/exports/rls-canonicalize.ts +7 -0
- package/src/exports/runtime.ts +1 -0
- package/src/exports/schema-ir-annotations.ts +1 -0
- package/src/exports/sql-utils.ts +1 -0
- package/src/exports/types.ts +37 -0
- package/dist/codec-ids-BvytN2P8.mjs.map +0 -1
- package/dist/codec-ids-CnXu9Qy3.d.mts.map +0 -1
- package/dist/codec-types-DHCkwPKE.d.mts.map +0 -1
- package/dist/codecs--0A5_4Bq.d.mts.map +0 -1
- package/dist/ddl-QDyOSeLc.mjs.map +0 -1
- package/dist/default-normalizer-DyyCHQWs.mjs +0 -131
- package/dist/default-normalizer-DyyCHQWs.mjs.map +0 -1
- package/dist/descriptor-meta-CpGygXpI.mjs +0 -140
- package/dist/descriptor-meta-CpGygXpI.mjs.map +0 -1
- package/dist/errors-CUk87ByX.mjs +0 -33
- package/dist/errors-CUk87ByX.mjs.map +0 -1
- package/dist/issue-planner-DL6g3CmE.mjs +0 -824
- package/dist/issue-planner-DL6g3CmE.mjs.map +0 -1
- package/dist/native-type-normalizer-Bc9XJzWC.mjs +0 -38
- package/dist/native-type-normalizer-Bc9XJzWC.mjs.map +0 -1
- package/dist/nodes-Bbhs2rwj.mjs +0 -76
- package/dist/nodes-Bbhs2rwj.mjs.map +0 -1
- package/dist/nodes-pLeLgdis.d.mts +0 -67
- package/dist/nodes-pLeLgdis.d.mts.map +0 -1
- package/dist/op-factory-call-D_p5vxwt.mjs.map +0 -1
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +0 -1
- package/dist/planner-Bs_baQax.mjs +0 -324
- package/dist/planner-Bs_baQax.mjs.map +0 -1
- package/dist/planner-ddl-builders-B2wOwLqI.mjs.map +0 -1
- package/dist/planner-target-details-CIY6tLeo.d.mts.map +0 -1
- package/dist/postgres-contract-serializer-k3TAcPMY.mjs.map +0 -1
- package/dist/postgres-migration-B5jKrXv3.mjs.map +0 -1
- package/dist/postgres-migration-Y4YBJqkS.d.mts.map +0 -1
- package/dist/postgres-schema-COGZ1ark.mjs.map +0 -1
- package/dist/render-typescript-KMgosran.mjs.map +0 -1
- package/dist/types.d.mts.map +0 -1
- package/src/core/postgres-enum-type-schema.ts +0 -17
|
@@ -1,14 +1,26 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { n as
|
|
4
|
-
import {
|
|
1
|
+
import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86.mjs";
|
|
2
|
+
import { i as quoteIdentifier, n as escapeLiteral, o as validateEnumValueLength } from "./sql-utils-SU4FDvIV.mjs";
|
|
3
|
+
import { C as tableIsEmptyAst, S as tableExistsAst, _ as extensionExistsAst, a as createSchema, b as rlsEnabledAst, c as disableRowLevelSecurity$1, d as dropType, f as columnDefaultAst, g as constraintExistsAst, h as columnTypeAst, i as createPolicy, l as dropDefaultAction, m as columnNullabilityAst, n as alterPolicyRename, o as createTable, p as columnExistsAst, r as alterTable, s as createType, t as addColumnAction, u as dropPolicy, v as indexExistsAst, x as rlsPolicyExistsAst, y as noNullValuesAst } from "./ddl-Dqgs-bDc.mjs";
|
|
4
|
+
import { n as qualifyTableName } from "./planner-sql-checks-CxJ8W66T.mjs";
|
|
5
|
+
import { n as buildColumnTypeSql } from "./planner-ddl-builders-BKlmGDJl.mjs";
|
|
5
6
|
import { FunctionColumnDefault, LiteralColumnDefault } from "@prisma-next/sql-relational-core/ast";
|
|
7
|
+
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
6
8
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
7
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
8
|
-
import {
|
|
10
|
+
import { col } from "@prisma-next/sql-relational-core/contract-free";
|
|
9
11
|
import { errorUnfilledPlaceholder } from "@prisma-next/errors/migration";
|
|
10
12
|
import { TsExpression, jsonToTsSource } from "@prisma-next/ts-render";
|
|
11
13
|
import { REFERENTIAL_ACTION_SQL } from "@prisma-next/sql-contract/referential-action-sql";
|
|
14
|
+
//#region src/core/migrations/bound-schema.ts
|
|
15
|
+
/**
|
|
16
|
+
* Maps a planner schema name to the contract-free DDL builder's optional
|
|
17
|
+
* `schema` field: the unbound sentinel becomes `undefined` (the builder omits
|
|
18
|
+
* the schema qualifier), every other name passes through.
|
|
19
|
+
*/
|
|
20
|
+
function boundSchema(schemaName) {
|
|
21
|
+
return schemaName === UNBOUND_NAMESPACE_ID ? void 0 : schemaName;
|
|
22
|
+
}
|
|
23
|
+
//#endregion
|
|
12
24
|
//#region src/core/migrations/operations/shared.ts
|
|
13
25
|
function step(description, sql, params) {
|
|
14
26
|
return {
|
|
@@ -171,12 +183,16 @@ async function setDefault(schemaName, tableName, columnName, defaultSql, lowerer
|
|
|
171
183
|
};
|
|
172
184
|
}
|
|
173
185
|
async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
174
|
-
const qualified = qualifyTableName(schemaName, tableName);
|
|
175
186
|
const { present } = await columnExistsSteps(lowerer, {
|
|
176
187
|
schema: schemaName,
|
|
177
188
|
table: tableName,
|
|
178
189
|
column: columnName
|
|
179
190
|
});
|
|
191
|
+
const dropDefaultExec = await lowerer.lowerToExecuteRequest(alterTable({
|
|
192
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
193
|
+
table: tableName,
|
|
194
|
+
actions: [dropDefaultAction(columnName)]
|
|
195
|
+
}));
|
|
180
196
|
const noDefault = await lowerer.lowerToExecuteRequest(columnDefaultAst({
|
|
181
197
|
schema: schemaName,
|
|
182
198
|
table: tableName,
|
|
@@ -188,17 +204,23 @@ async function dropDefault(schemaName, tableName, columnName, lowerer) {
|
|
|
188
204
|
operationClass: "destructive",
|
|
189
205
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
190
206
|
precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
|
|
191
|
-
execute: [step(`drop default on "${columnName}"`,
|
|
207
|
+
execute: [step(`drop default on "${columnName}"`, dropDefaultExec.sql)],
|
|
192
208
|
postcheck: [step(`verify column "${columnName}" has no default`, noDefault.sql, noDefault.params)]
|
|
193
209
|
};
|
|
194
210
|
}
|
|
195
211
|
/**
|
|
196
212
|
* Builds the op for adding a NOT NULL column (no contract default) to a
|
|
197
213
|
* non-empty table. Prechecks assert the column is absent and the table is
|
|
198
|
-
* empty; the execute step
|
|
199
|
-
*
|
|
214
|
+
* empty; the execute step lowers the typed `AddColumn` DDL node through the
|
|
215
|
+
* adapter; postchecks assert the column exists and is NOT NULL.
|
|
200
216
|
*/
|
|
201
|
-
async function addNotNullColumnDirect(schemaName, tableName,
|
|
217
|
+
async function addNotNullColumnDirect(schemaName, tableName, column, lowerer) {
|
|
218
|
+
const columnName = column.name;
|
|
219
|
+
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
220
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
221
|
+
table: tableName,
|
|
222
|
+
actions: [addColumnAction(column)]
|
|
223
|
+
}));
|
|
202
224
|
const absent = await lowerer.lowerToExecuteRequest(columnExistsAst({
|
|
203
225
|
schema: schemaName,
|
|
204
226
|
table: tableName,
|
|
@@ -223,7 +245,7 @@ async function addNotNullColumnDirect(schemaName, tableName, columnName, execute
|
|
|
223
245
|
operationClass: "additive",
|
|
224
246
|
target: targetDetails("column", columnName, schemaName, tableName),
|
|
225
247
|
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params), step(`ensure table "${tableName}" is empty before adding NOT NULL column without default`, tableEmpty.sql, tableEmpty.params)],
|
|
226
|
-
execute: [step(`add column "${columnName}"`,
|
|
248
|
+
execute: [step(`add column "${columnName}"`, addColumn.sql)],
|
|
227
249
|
postcheck: [step(`verify column "${columnName}" exists`, present.sql, present.params), step(`verify column "${columnName}" is NOT NULL`, notNullable.sql, notNullable.params)]
|
|
228
250
|
};
|
|
229
251
|
}
|
|
@@ -344,7 +366,7 @@ async function dropCheckConstraint(schemaName, tableName, constraintName, lowere
|
|
|
344
366
|
* `kind` feeds the operation's `target.details.objectType`. Descriptor-flow
|
|
345
367
|
* does not carry kind information in its drop-constraint descriptor, so the
|
|
346
368
|
* default is `'unique'`. The reconciliation planner passes the correct kind
|
|
347
|
-
* (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the
|
|
369
|
+
* (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the diff issue
|
|
348
370
|
* that produced the drop.
|
|
349
371
|
*/
|
|
350
372
|
async function dropConstraint(schemaName, tableName, constraintName, lowerer, kind = "unique") {
|
|
@@ -405,7 +427,7 @@ async function installExtension(options, lowerer) {
|
|
|
405
427
|
target: {
|
|
406
428
|
id: "postgres",
|
|
407
429
|
details: {
|
|
408
|
-
schema:
|
|
430
|
+
schema: DEFAULT_NAMESPACE_ID,
|
|
409
431
|
objectType: "dependency",
|
|
410
432
|
name: extensionName
|
|
411
433
|
}
|
|
@@ -463,6 +485,175 @@ async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
|
463
485
|
};
|
|
464
486
|
}
|
|
465
487
|
//#endregion
|
|
488
|
+
//#region src/core/migrations/operations/native-enum-types.ts
|
|
489
|
+
/**
|
|
490
|
+
* `CREATE TYPE <qualified> AS ENUM (…)` for a managed native enum, built as a
|
|
491
|
+
* typed DDL node and lowered by the control adapter (the type name is quoted,
|
|
492
|
+
* member values render as escaped string literals in declaration order —
|
|
493
|
+
* Postgres enum sort order is semantic). `boundSchema` maps the unbound sentinel
|
|
494
|
+
* to an absent schema so the type name renders unqualified and the connection's
|
|
495
|
+
* `search_path` resolves the schema at runtime.
|
|
496
|
+
*/
|
|
497
|
+
async function createNativeEnumType(schemaName, typeName, members, lowerer) {
|
|
498
|
+
for (const member of members) validateEnumValueLength(member, typeName);
|
|
499
|
+
const ddlNode = createType({
|
|
500
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
501
|
+
name: typeName,
|
|
502
|
+
values: members
|
|
503
|
+
});
|
|
504
|
+
const statement = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
505
|
+
return {
|
|
506
|
+
id: `createNativeEnumType.${typeName}`,
|
|
507
|
+
label: `Create enum type "${typeName}"`,
|
|
508
|
+
operationClass: "additive",
|
|
509
|
+
target: targetDetails("type", typeName, schemaName),
|
|
510
|
+
precheck: [],
|
|
511
|
+
execute: [step(`create enum type "${typeName}"`, statement.sql, statement.params)],
|
|
512
|
+
postcheck: []
|
|
513
|
+
};
|
|
514
|
+
}
|
|
515
|
+
/** `DROP TYPE <qualified>` for an unclaimed managed native enum, via typed DDL. */
|
|
516
|
+
async function dropNativeEnumType(schemaName, typeName, lowerer) {
|
|
517
|
+
const ddlNode = dropType({
|
|
518
|
+
...ifDefined("schema", boundSchema(schemaName)),
|
|
519
|
+
name: typeName
|
|
520
|
+
});
|
|
521
|
+
const statement = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
522
|
+
return {
|
|
523
|
+
id: `dropNativeEnumType.${typeName}`,
|
|
524
|
+
label: `Drop enum type "${typeName}"`,
|
|
525
|
+
operationClass: "destructive",
|
|
526
|
+
target: targetDetails("type", typeName, schemaName),
|
|
527
|
+
precheck: [],
|
|
528
|
+
execute: [step(`drop enum type "${typeName}"`, statement.sql, statement.params)],
|
|
529
|
+
postcheck: []
|
|
530
|
+
};
|
|
531
|
+
}
|
|
532
|
+
//#endregion
|
|
533
|
+
//#region src/core/migrations/operations/rls.ts
|
|
534
|
+
const PLAIN_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_$]*$/;
|
|
535
|
+
function validateRoleName(role) {
|
|
536
|
+
if (!PLAIN_IDENTIFIER.test(role)) throw new Error(`Invalid role name ${JSON.stringify(role)}: role names must be plain SQL identifiers matching ^[A-Za-z_][A-Za-z0-9_$]*$`);
|
|
537
|
+
return role;
|
|
538
|
+
}
|
|
539
|
+
async function createRlsPolicy(schemaName, tableName, policy, lowerer) {
|
|
540
|
+
const validatedRoles = policy.roles.map(validateRoleName);
|
|
541
|
+
const ddlNode = createPolicy({
|
|
542
|
+
schema: schemaName,
|
|
543
|
+
table: tableName,
|
|
544
|
+
name: policy.name,
|
|
545
|
+
permissive: policy.permissive,
|
|
546
|
+
operation: policy.operation,
|
|
547
|
+
roles: validatedRoles,
|
|
548
|
+
...ifDefined("using", policy.using),
|
|
549
|
+
...ifDefined("withCheck", policy.withCheck)
|
|
550
|
+
});
|
|
551
|
+
const checks = rlsPolicyExistsAst({
|
|
552
|
+
schema: schemaName,
|
|
553
|
+
table: tableName,
|
|
554
|
+
policyName: policy.name
|
|
555
|
+
});
|
|
556
|
+
const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());
|
|
557
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
558
|
+
const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());
|
|
559
|
+
return {
|
|
560
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${policy.name}`,
|
|
561
|
+
label: `Create RLS policy "${policy.name}" on "${tableName}"`,
|
|
562
|
+
operationClass: "additive",
|
|
563
|
+
target: targetDetails("rlsPolicy", policy.name, schemaName, tableName),
|
|
564
|
+
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params)],
|
|
565
|
+
execute: [step(`create RLS policy "${policy.name}"`, execute.sql, execute.params)],
|
|
566
|
+
postcheck: [step(`verify RLS policy "${policy.name}" exists`, present.sql, present.params)]
|
|
567
|
+
};
|
|
568
|
+
}
|
|
569
|
+
async function dropRlsPolicy(schemaName, tableName, policyName, lowerer) {
|
|
570
|
+
const ddlNode = dropPolicy({
|
|
571
|
+
schema: schemaName,
|
|
572
|
+
table: tableName,
|
|
573
|
+
name: policyName
|
|
574
|
+
});
|
|
575
|
+
const checks = rlsPolicyExistsAst({
|
|
576
|
+
schema: schemaName,
|
|
577
|
+
table: tableName,
|
|
578
|
+
policyName
|
|
579
|
+
});
|
|
580
|
+
const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());
|
|
581
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
582
|
+
const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());
|
|
583
|
+
return {
|
|
584
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${policyName}.drop`,
|
|
585
|
+
label: `Drop RLS policy "${policyName}" on "${tableName}"`,
|
|
586
|
+
operationClass: "destructive",
|
|
587
|
+
target: targetDetails("rlsPolicy", policyName, schemaName, tableName),
|
|
588
|
+
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params)],
|
|
589
|
+
execute: [step(`drop RLS policy "${policyName}"`, execute.sql, execute.params)],
|
|
590
|
+
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params)]
|
|
591
|
+
};
|
|
592
|
+
}
|
|
593
|
+
async function enableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
594
|
+
const checks = rlsEnabledAst(schemaName, tableName);
|
|
595
|
+
const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());
|
|
596
|
+
const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());
|
|
597
|
+
return {
|
|
598
|
+
id: `rowLevelSecurity.${schemaName}.${tableName}`,
|
|
599
|
+
label: `Enable row-level security on "${tableName}"`,
|
|
600
|
+
operationClass: "additive",
|
|
601
|
+
target: targetDetails("rowLevelSecurity", tableName, schemaName),
|
|
602
|
+
precheck: [step(`check RLS is not already enabled on "${tableName}"`, disabled.sql, disabled.params)],
|
|
603
|
+
execute: [step(`enable row-level security on "${tableName}"`, `ALTER TABLE ${qualifyTableName(schemaName, tableName)} ENABLE ROW LEVEL SECURITY`)],
|
|
604
|
+
postcheck: [step(`verify row-level security is enabled on "${tableName}"`, enabled.sql, enabled.params)]
|
|
605
|
+
};
|
|
606
|
+
}
|
|
607
|
+
async function disableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
608
|
+
const ddlNode = disableRowLevelSecurity$1({
|
|
609
|
+
schema: schemaName,
|
|
610
|
+
table: tableName
|
|
611
|
+
});
|
|
612
|
+
const checks = rlsEnabledAst(schemaName, tableName);
|
|
613
|
+
const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());
|
|
614
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
615
|
+
const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());
|
|
616
|
+
return {
|
|
617
|
+
id: `rowLevelSecurity.${schemaName}.${tableName}.disable`,
|
|
618
|
+
label: `Disable row-level security on "${tableName}"`,
|
|
619
|
+
operationClass: "destructive",
|
|
620
|
+
target: targetDetails("rowLevelSecurity", tableName, schemaName),
|
|
621
|
+
precheck: [step(`check RLS is currently enabled on "${tableName}"`, enabled.sql, enabled.params)],
|
|
622
|
+
execute: [step(`disable row-level security on "${tableName}"`, execute.sql, execute.params)],
|
|
623
|
+
postcheck: [step(`verify row-level security is disabled on "${tableName}"`, disabled.sql, disabled.params)]
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
async function renameRlsPolicy(schemaName, tableName, oldPolicyName, newPolicyName, lowerer) {
|
|
627
|
+
const ddlNode = alterPolicyRename({
|
|
628
|
+
schema: schemaName,
|
|
629
|
+
table: tableName,
|
|
630
|
+
name: oldPolicyName,
|
|
631
|
+
newName: newPolicyName
|
|
632
|
+
});
|
|
633
|
+
const oldChecks = rlsPolicyExistsAst({
|
|
634
|
+
schema: schemaName,
|
|
635
|
+
table: tableName,
|
|
636
|
+
policyName: oldPolicyName
|
|
637
|
+
});
|
|
638
|
+
const newChecks = rlsPolicyExistsAst({
|
|
639
|
+
schema: schemaName,
|
|
640
|
+
table: tableName,
|
|
641
|
+
policyName: newPolicyName
|
|
642
|
+
});
|
|
643
|
+
const oldPresent = await lowerer.lowerToExecuteRequest(oldChecks.policyPresent());
|
|
644
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
645
|
+
const newPresent = await lowerer.lowerToExecuteRequest(newChecks.policyPresent());
|
|
646
|
+
return {
|
|
647
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${oldPolicyName}.rename`,
|
|
648
|
+
label: `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`,
|
|
649
|
+
operationClass: "widening",
|
|
650
|
+
target: targetDetails("rlsPolicy", newPolicyName, schemaName, tableName),
|
|
651
|
+
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params)],
|
|
652
|
+
execute: [step(`rename RLS policy "${oldPolicyName}" to "${newPolicyName}"`, execute.sql, execute.params)],
|
|
653
|
+
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params)]
|
|
654
|
+
};
|
|
655
|
+
}
|
|
656
|
+
//#endregion
|
|
466
657
|
//#region src/core/migrations/operations/tables.ts
|
|
467
658
|
async function dropTable(schemaName, tableName, lowerer) {
|
|
468
659
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
@@ -504,7 +695,20 @@ function buildAddColumnOperationIdentity(schema, tableName, columnName) {
|
|
|
504
695
|
}
|
|
505
696
|
async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
506
697
|
const { schema, tableName, columnName, column, codecHooks, storageTypes, temporaryDefault, lowerer } = options;
|
|
507
|
-
const
|
|
698
|
+
const ddlColumn = col(columnName, buildColumnTypeSql(column, codecHooks, storageTypes), {
|
|
699
|
+
notNull: true,
|
|
700
|
+
default: new FunctionColumnDefault(temporaryDefault)
|
|
701
|
+
});
|
|
702
|
+
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
703
|
+
...ifDefined("schema", boundSchema(schema)),
|
|
704
|
+
table: tableName,
|
|
705
|
+
actions: [addColumnAction(ddlColumn)]
|
|
706
|
+
}));
|
|
707
|
+
const dropTempDefault = await lowerer.lowerToExecuteRequest(alterTable({
|
|
708
|
+
...ifDefined("schema", boundSchema(schema)),
|
|
709
|
+
table: tableName,
|
|
710
|
+
actions: [dropDefaultAction(columnName)]
|
|
711
|
+
}));
|
|
508
712
|
const absent = await lowerer.lowerToExecuteRequest(columnExistsAst({
|
|
509
713
|
schema,
|
|
510
714
|
table: tableName,
|
|
@@ -532,10 +736,10 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
532
736
|
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
533
737
|
execute: [{
|
|
534
738
|
description: `add column "${columnName}"`,
|
|
535
|
-
sql:
|
|
739
|
+
sql: addColumn.sql
|
|
536
740
|
}, {
|
|
537
741
|
description: `drop temporary default from column "${columnName}"`,
|
|
538
|
-
sql:
|
|
742
|
+
sql: dropTempDefault.sql
|
|
539
743
|
}],
|
|
540
744
|
postcheck: [
|
|
541
745
|
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
@@ -568,9 +772,6 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
568
772
|
* `PostgresOpFactoryCall` union.
|
|
569
773
|
*/
|
|
570
774
|
const POSTGRES_MIGRATION_FACADE = "@prisma-next/postgres/migration";
|
|
571
|
-
function boundSchema(schemaName) {
|
|
572
|
-
return schemaName === UNBOUND_NAMESPACE_ID ? void 0 : schemaName;
|
|
573
|
-
}
|
|
574
775
|
var PostgresOpFactoryCallNode = class extends TsExpression {
|
|
575
776
|
importRequirements() {
|
|
576
777
|
return [{
|
|
@@ -625,6 +826,7 @@ function renderDdlConstraintAsTsCall(constraint) {
|
|
|
625
826
|
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
626
827
|
return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
627
828
|
}
|
|
829
|
+
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${jsonToTsSource(constraint.expression)})`;
|
|
628
830
|
}
|
|
629
831
|
}
|
|
630
832
|
function needsColOrConstraintImport(columns) {
|
|
@@ -636,6 +838,7 @@ function constraintImportSymbols(constraints) {
|
|
|
636
838
|
for (const c of constraints) if (c.kind === "primary-key") symbols.add("primaryKey");
|
|
637
839
|
else if (c.kind === "foreign-key") symbols.add("foreignKey");
|
|
638
840
|
else if (c.kind === "unique") symbols.add("unique");
|
|
841
|
+
else if (c.kind === "check-expression") symbols.add("checkExpression");
|
|
639
842
|
return [...symbols];
|
|
640
843
|
}
|
|
641
844
|
function defaultImportSymbols(columns) {
|
|
@@ -998,10 +1201,8 @@ var DropDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
|
998
1201
|
};
|
|
999
1202
|
/**
|
|
1000
1203
|
* Planner-internal call for adding a NOT NULL column (no contract default) to
|
|
1001
|
-
* a table that must be empty at migration time. Carries the
|
|
1002
|
-
*
|
|
1003
|
-
* DDL) plus the parameters needed to lower the typed pre/postchecks at render
|
|
1004
|
-
* time.
|
|
1204
|
+
* a table that must be empty at migration time. Carries the typed `DdlColumn`
|
|
1205
|
+
* and lowers it to an ADD COLUMN execute step via the adapter at `toOp` time.
|
|
1005
1206
|
*
|
|
1006
1207
|
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1007
1208
|
* planner, never hand-written by migration authors.
|
|
@@ -1012,20 +1213,20 @@ var AddNotNullColumnDirectCall = class extends PostgresOpFactoryCallNode {
|
|
|
1012
1213
|
schemaName;
|
|
1013
1214
|
tableName;
|
|
1014
1215
|
columnName;
|
|
1015
|
-
|
|
1216
|
+
column;
|
|
1016
1217
|
label;
|
|
1017
|
-
constructor(schemaName, tableName, columnName,
|
|
1218
|
+
constructor(schemaName, tableName, columnName, column) {
|
|
1018
1219
|
super();
|
|
1019
1220
|
this.schemaName = schemaName;
|
|
1020
1221
|
this.tableName = tableName;
|
|
1021
1222
|
this.columnName = columnName;
|
|
1022
|
-
this.
|
|
1223
|
+
this.column = column;
|
|
1023
1224
|
this.label = `Add column ${columnName} to ${tableName}`;
|
|
1024
1225
|
this.freeze();
|
|
1025
1226
|
}
|
|
1026
1227
|
async toOp(lowerer) {
|
|
1027
1228
|
if (lowerer === void 0) throw new Error(`AddNotNullColumnDirectCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1028
|
-
return addNotNullColumnDirect(this.schemaName, this.tableName, this.
|
|
1229
|
+
return addNotNullColumnDirect(this.schemaName, this.tableName, this.column, lowerer);
|
|
1029
1230
|
}
|
|
1030
1231
|
renderTypeScript() {
|
|
1031
1232
|
return `rawSql(${jsonToTsSource({
|
|
@@ -1041,9 +1242,9 @@ var AddNotNullColumnDirectCall = class extends PostgresOpFactoryCallNode {
|
|
|
1041
1242
|
/**
|
|
1042
1243
|
* Planner-internal call for adding a NOT NULL column (no contract default)
|
|
1043
1244
|
* using a temporary default value for non-empty tables. Carries all parameters
|
|
1044
|
-
* needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; the
|
|
1045
|
-
* pre/postchecks are lowered
|
|
1046
|
-
*
|
|
1245
|
+
* needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; both the
|
|
1246
|
+
* typed ADD COLUMN execute step and the pre/postchecks are lowered via the
|
|
1247
|
+
* adapter at `toOp` time.
|
|
1047
1248
|
*
|
|
1048
1249
|
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1049
1250
|
* planner, never hand-written by migration authors.
|
|
@@ -1440,6 +1641,60 @@ var CreateSchemaCall = class extends PostgresOpFactoryCallNode {
|
|
|
1440
1641
|
return [];
|
|
1441
1642
|
}
|
|
1442
1643
|
};
|
|
1644
|
+
var CreateNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1645
|
+
factoryName = "createNativeEnumType";
|
|
1646
|
+
operationClass = "additive";
|
|
1647
|
+
schemaName;
|
|
1648
|
+
typeName;
|
|
1649
|
+
members;
|
|
1650
|
+
label;
|
|
1651
|
+
constructor(schemaName, typeName, members) {
|
|
1652
|
+
super();
|
|
1653
|
+
this.schemaName = schemaName;
|
|
1654
|
+
this.typeName = typeName;
|
|
1655
|
+
this.members = Object.freeze([...members]);
|
|
1656
|
+
this.label = `Create enum type "${typeName}"`;
|
|
1657
|
+
this.freeze();
|
|
1658
|
+
}
|
|
1659
|
+
async toOp(lowerer) {
|
|
1660
|
+
if (lowerer === void 0) throw new Error(`CreateNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type "${this.typeName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1661
|
+
return createNativeEnumType(this.schemaName, this.typeName, this.members, lowerer);
|
|
1662
|
+
}
|
|
1663
|
+
renderTypeScript() {
|
|
1664
|
+
return `this.createNativeEnumType({ ${[
|
|
1665
|
+
`schema: ${jsonToTsSource(this.schemaName)}`,
|
|
1666
|
+
`typeName: ${jsonToTsSource(this.typeName)}`,
|
|
1667
|
+
`members: ${jsonToTsSource(this.members)}`
|
|
1668
|
+
].join(", ")} })`;
|
|
1669
|
+
}
|
|
1670
|
+
importRequirements() {
|
|
1671
|
+
return [];
|
|
1672
|
+
}
|
|
1673
|
+
};
|
|
1674
|
+
var DropNativeEnumTypeCall = class extends PostgresOpFactoryCallNode {
|
|
1675
|
+
factoryName = "dropNativeEnumType";
|
|
1676
|
+
operationClass = "destructive";
|
|
1677
|
+
schemaName;
|
|
1678
|
+
typeName;
|
|
1679
|
+
label;
|
|
1680
|
+
constructor(schemaName, typeName) {
|
|
1681
|
+
super();
|
|
1682
|
+
this.schemaName = schemaName;
|
|
1683
|
+
this.typeName = typeName;
|
|
1684
|
+
this.label = `Drop enum type "${typeName}"`;
|
|
1685
|
+
this.freeze();
|
|
1686
|
+
}
|
|
1687
|
+
async toOp(lowerer) {
|
|
1688
|
+
if (lowerer === void 0) throw new Error(`DropNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type "${this.typeName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1689
|
+
return dropNativeEnumType(this.schemaName, this.typeName, lowerer);
|
|
1690
|
+
}
|
|
1691
|
+
renderTypeScript() {
|
|
1692
|
+
return `this.dropNativeEnumType({ ${[`schema: ${jsonToTsSource(this.schemaName)}`, `typeName: ${jsonToTsSource(this.typeName)}`].join(", ")} })`;
|
|
1693
|
+
}
|
|
1694
|
+
importRequirements() {
|
|
1695
|
+
return [];
|
|
1696
|
+
}
|
|
1697
|
+
};
|
|
1443
1698
|
/**
|
|
1444
1699
|
* A planner-generated data-transform stub. `checkSlot` and `runSlot` name
|
|
1445
1700
|
* the unfilled authoring slots that the rendered `migration.ts` will expose
|
|
@@ -1484,7 +1739,120 @@ var DataTransformCall = class extends PostgresOpFactoryCallNode {
|
|
|
1484
1739
|
}];
|
|
1485
1740
|
}
|
|
1486
1741
|
};
|
|
1742
|
+
var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1743
|
+
factoryName = "createRlsPolicy";
|
|
1744
|
+
operationClass = "additive";
|
|
1745
|
+
schemaName;
|
|
1746
|
+
tableName;
|
|
1747
|
+
policy;
|
|
1748
|
+
label;
|
|
1749
|
+
constructor(schemaName, tableName, policy) {
|
|
1750
|
+
super();
|
|
1751
|
+
this.schemaName = schemaName;
|
|
1752
|
+
this.tableName = tableName;
|
|
1753
|
+
this.policy = policy;
|
|
1754
|
+
this.label = `Create RLS policy "${policy.name}" on "${tableName}"`;
|
|
1755
|
+
this.freeze();
|
|
1756
|
+
}
|
|
1757
|
+
async toOp(lowerer) {
|
|
1758
|
+
if (lowerer === void 0) throw new Error(`CreatePostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy "${this.policy.name}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1759
|
+
return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
|
|
1760
|
+
}
|
|
1761
|
+
renderTypeScript() {
|
|
1762
|
+
return `createRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policy)})`;
|
|
1763
|
+
}
|
|
1764
|
+
};
|
|
1765
|
+
var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1766
|
+
factoryName = "dropRlsPolicy";
|
|
1767
|
+
operationClass = "destructive";
|
|
1768
|
+
schemaName;
|
|
1769
|
+
tableName;
|
|
1770
|
+
policyName;
|
|
1771
|
+
label;
|
|
1772
|
+
constructor(schemaName, tableName, policyName) {
|
|
1773
|
+
super();
|
|
1774
|
+
this.schemaName = schemaName;
|
|
1775
|
+
this.tableName = tableName;
|
|
1776
|
+
this.policyName = policyName;
|
|
1777
|
+
this.label = `Drop RLS policy "${policyName}" on "${tableName}"`;
|
|
1778
|
+
this.freeze();
|
|
1779
|
+
}
|
|
1780
|
+
async toOp(lowerer) {
|
|
1781
|
+
if (lowerer === void 0) throw new Error(`DropPostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy "${this.policyName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1782
|
+
return dropRlsPolicy(this.schemaName, this.tableName, this.policyName, lowerer);
|
|
1783
|
+
}
|
|
1784
|
+
renderTypeScript() {
|
|
1785
|
+
return `dropRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policyName)})`;
|
|
1786
|
+
}
|
|
1787
|
+
};
|
|
1788
|
+
var EnableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
1789
|
+
factoryName = "enableRowLevelSecurity";
|
|
1790
|
+
operationClass = "additive";
|
|
1791
|
+
schemaName;
|
|
1792
|
+
tableName;
|
|
1793
|
+
label;
|
|
1794
|
+
constructor(schemaName, tableName) {
|
|
1795
|
+
super();
|
|
1796
|
+
this.schemaName = schemaName;
|
|
1797
|
+
this.tableName = tableName;
|
|
1798
|
+
this.label = `Enable row-level security on "${tableName}"`;
|
|
1799
|
+
this.freeze();
|
|
1800
|
+
}
|
|
1801
|
+
async toOp(lowerer) {
|
|
1802
|
+
if (lowerer === void 0) throw new Error(`EnableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1803
|
+
return enableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1804
|
+
}
|
|
1805
|
+
renderTypeScript() {
|
|
1806
|
+
return `enableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1807
|
+
}
|
|
1808
|
+
};
|
|
1809
|
+
var DisableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
1810
|
+
factoryName = "disableRowLevelSecurity";
|
|
1811
|
+
operationClass = "destructive";
|
|
1812
|
+
schemaName;
|
|
1813
|
+
tableName;
|
|
1814
|
+
label;
|
|
1815
|
+
constructor(schemaName, tableName) {
|
|
1816
|
+
super();
|
|
1817
|
+
this.schemaName = schemaName;
|
|
1818
|
+
this.tableName = tableName;
|
|
1819
|
+
this.label = `Disable row-level security on "${tableName}"`;
|
|
1820
|
+
this.freeze();
|
|
1821
|
+
}
|
|
1822
|
+
async toOp(lowerer) {
|
|
1823
|
+
if (lowerer === void 0) throw new Error(`DisableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1824
|
+
return disableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1825
|
+
}
|
|
1826
|
+
renderTypeScript() {
|
|
1827
|
+
return `disableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1828
|
+
}
|
|
1829
|
+
};
|
|
1830
|
+
var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1831
|
+
factoryName = "renameRlsPolicy";
|
|
1832
|
+
operationClass = "widening";
|
|
1833
|
+
schemaName;
|
|
1834
|
+
tableName;
|
|
1835
|
+
oldPolicyName;
|
|
1836
|
+
newPolicyName;
|
|
1837
|
+
label;
|
|
1838
|
+
constructor(schemaName, tableName, oldPolicyName, newPolicyName) {
|
|
1839
|
+
super();
|
|
1840
|
+
this.schemaName = schemaName;
|
|
1841
|
+
this.tableName = tableName;
|
|
1842
|
+
this.oldPolicyName = oldPolicyName;
|
|
1843
|
+
this.newPolicyName = newPolicyName;
|
|
1844
|
+
this.label = `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`;
|
|
1845
|
+
this.freeze();
|
|
1846
|
+
}
|
|
1847
|
+
async toOp(lowerer) {
|
|
1848
|
+
if (lowerer === void 0) throw new Error(`RenamePostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy "${this.oldPolicyName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`);
|
|
1849
|
+
return renameRlsPolicy(this.schemaName, this.tableName, this.oldPolicyName, this.newPolicyName, lowerer);
|
|
1850
|
+
}
|
|
1851
|
+
renderTypeScript() {
|
|
1852
|
+
return `renameRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.oldPolicyName)}, ${jsonToTsSource(this.newPolicyName)})`;
|
|
1853
|
+
}
|
|
1854
|
+
};
|
|
1487
1855
|
//#endregion
|
|
1488
|
-
export { SetNotNullCall as C,
|
|
1856
|
+
export { SetNotNullCall as A, DropNotNullCall as C, RawSqlCall as D, EnableRowLevelSecurityCall as E, buildTargetDetails as M, createExtension as N, RenamePostgresRlsPolicyCall as O, installExtension as P, DropNativeEnumTypeCall as S, DropTableCall as T, DropCheckConstraintCall as _, AddNotNullColumnWithTempDefaultCall as a, DropDefaultCall as b, AlterColumnTypeCall as c, CreateNativeEnumTypeCall as d, CreatePostgresRlsPolicyCall as f, DisableRowLevelSecurityCall as g, DataTransformCall as h, AddNotNullColumnDirectCall as i, postgresDefaultToDdlColumnDefault as j, SetDefaultCall as k, CreateExtensionCall as l, CreateTableCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateSchemaCall as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, CreateIndexCall as u, DropColumnCall as v, DropPostgresRlsPolicyCall as w, DropIndexCall as x, DropConstraintCall as y };
|
|
1489
1857
|
|
|
1490
|
-
//# sourceMappingURL=op-factory-call-
|
|
1858
|
+
//# sourceMappingURL=op-factory-call-WFZUHrbI.mjs.map
|