@prisma-next/target-postgres 0.14.0-dev.6 → 0.14.0-dev.60
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-WkqG_MkU.mjs +419 -0
- package/dist/authoring-WkqG_MkU.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-CkVQrZ4G.mjs +913 -0
- package/dist/codecs-CkVQrZ4G.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 +4 -4
- package/dist/control-policy-Co_13Hxa.mjs +1128 -0
- package/dist/control-policy-Co_13Hxa.mjs.map +1 -0
- package/dist/control.d.mts +2 -2
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +900 -35
- 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-B-krEXY1.mjs} +77 -6
- package/dist/ddl-B-krEXY1.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-BOcKPaLE.mjs +22 -0
- package/dist/descriptor-meta-BOcKPaLE.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-BOsDnH64.mjs +266 -0
- package/dist/diff-database-schema-BOsDnH64.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-B815pj_X.mjs +162 -0
- package/dist/nodes-B815pj_X.mjs.map +1 -0
- package/dist/nodes-BtQyZha6.d.mts +146 -0
- package/dist/nodes-BtQyZha6.d.mts.map +1 -0
- package/dist/{op-factory-call-DmQEc3XV.d.mts → op-factory-call-D6_7-7Vc.d.mts} +68 -15
- package/dist/op-factory-call-D6_7-7Vc.d.mts.map +1 -0
- package/dist/{op-factory-call-D_p5vxwt.mjs → op-factory-call-DxNNKUeZ.mjs} +300 -31
- package/dist/op-factory-call-DxNNKUeZ.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 +144 -3
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-CNrc1Odu.mjs +422 -0
- package/dist/planner-CNrc1Odu.mjs.map +1 -0
- package/dist/{planner-ddl-builders-B2wOwLqI.mjs → planner-ddl-builders-B8Nn6nHN.mjs} +12 -27
- package/dist/planner-ddl-builders-B8Nn6nHN.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-NI-oGKcw.mjs} +3 -3
- package/dist/{planner-produced-postgres-migration-Cji5vxUf.mjs.map → planner-produced-postgres-migration-NI-oGKcw.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts → planner-produced-postgres-migration-a-tjfKsA.d.mts} +4 -4
- package/dist/{planner-produced-postgres-migration-QqHa2C2l.d.mts.map → planner-produced-postgres-migration-a-tjfKsA.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-AXoxB1Jl.mjs} +2 -2
- package/dist/{planner-sql-checks-jqUUGyQR.mjs.map → planner-sql-checks-AXoxB1Jl.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-view-C9j5cqP0.d.mts +34 -0
- package/dist/postgres-contract-view-C9j5cqP0.d.mts.map +1 -0
- package/dist/{postgres-contract-serializer-k3TAcPMY.mjs → postgres-contract-view-Dg-N7KA7.mjs} +45 -41
- package/dist/postgres-contract-view-Dg-N7KA7.mjs.map +1 -0
- package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts +218 -0
- package/dist/postgres-database-schema-node-CfdTY-Qs.d.mts.map +1 -0
- package/dist/{postgres-migration-Y4YBJqkS.d.mts → postgres-migration-Bzzi0Asr.d.mts} +28 -9
- package/dist/postgres-migration-Bzzi0Asr.d.mts.map +1 -0
- package/dist/{postgres-migration-B5jKrXv3.mjs → postgres-migration-ChyRsWvE.mjs} +53 -45
- package/dist/postgres-migration-ChyRsWvE.mjs.map +1 -0
- package/dist/postgres-native-enum-xdiqmBf_.mjs +41 -0
- package/dist/postgres-native-enum-xdiqmBf_.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-BiSTCTNg.mjs +195 -0
- package/dist/postgres-role-schema-node-BiSTCTNg.mjs.map +1 -0
- package/dist/postgres-schema-CU4gF6QZ.d.mts +257 -0
- package/dist/postgres-schema-CU4gF6QZ.d.mts.map +1 -0
- package/dist/{postgres-schema-COGZ1ark.mjs → postgres-schema-DTLA_aRi.mjs} +171 -10
- package/dist/postgres-schema-DTLA_aRi.mjs.map +1 -0
- package/dist/postgres-table-schema-node-9FCtCUz2.mjs +153 -0
- package/dist/postgres-table-schema-node-9FCtCUz2.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-Ca88Tg6W.mjs +22 -0
- package/dist/resolve-ddl-schema-Ca88Tg6W.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/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/ddl.ts +71 -1
- package/src/core/authoring.ts +356 -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 +141 -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 +160 -0
- package/src/core/migrations/control-policy.ts +99 -46
- package/src/core/migrations/diff-database-schema.ts +217 -0
- package/src/core/migrations/issue-planner.ts +692 -652
- package/src/core/migrations/op-factory-call.ts +189 -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/rls.ts +187 -0
- package/src/core/migrations/operations/shared.ts +0 -30
- package/src/core/migrations/planner-ddl-builders.ts +20 -58
- 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 +381 -59
- package/src/core/migrations/postgres-migration.ts +70 -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 +10 -16
- package/src/core/migrations/verify-postgres-namespaces.ts +47 -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 +51 -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 +37 -0
- package/src/core/postgres-schema-verifier.ts +10 -7
- package/src/core/postgres-schema.ts +64 -15
- package/src/core/postgres-validators.ts +33 -0
- package/src/core/psl-infer/infer-psl-contract.ts +1325 -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/postgres-database-schema-node.ts +60 -0
- package/src/core/schema-ir/postgres-namespace-schema-node.ts +79 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +90 -0
- package/src/core/schema-ir/postgres-role-schema-node.ts +63 -0
- package/src/core/schema-ir/postgres-table-schema-node.ts +140 -0
- package/src/core/schema-ir/schema-node-kinds.ts +106 -0
- 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 +6 -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 +1 -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/types.ts +34 -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 { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86.mjs";
|
|
1
2
|
import { i as quoteIdentifier, n as escapeLiteral } from "./sql-utils-DcfMz4MQ.mjs";
|
|
2
|
-
import { a as
|
|
3
|
-
import { n as qualifyTableName } from "./planner-sql-checks-
|
|
4
|
-
import {
|
|
3
|
+
import { _ as noNullValuesAst, a as createSchema, b as tableExistsAst, c as dropDefaultAction, d as columnExistsAst, f as columnNullabilityAst, g as indexExistsAst, h as extensionExistsAst, i as createPolicy, l as dropPolicy, m as constraintExistsAst, n as alterPolicyRename, o as createTable, p as columnTypeAst, r as alterTable, s as disableRowLevelSecurity$1, t as addColumnAction, u as columnDefaultAst, v as rlsEnabledAst, x as tableIsEmptyAst, y as rlsPolicyExistsAst } from "./ddl-B-krEXY1.mjs";
|
|
4
|
+
import { n as qualifyTableName } from "./planner-sql-checks-AXoxB1Jl.mjs";
|
|
5
|
+
import { n as buildColumnTypeSql } from "./planner-ddl-builders-B8Nn6nHN.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,130 @@ async function dropIndex(schemaName, tableName, indexName, lowerer) {
|
|
|
463
485
|
};
|
|
464
486
|
}
|
|
465
487
|
//#endregion
|
|
488
|
+
//#region src/core/migrations/operations/rls.ts
|
|
489
|
+
const PLAIN_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_$]*$/;
|
|
490
|
+
function validateRoleName(role) {
|
|
491
|
+
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_$]*$`);
|
|
492
|
+
return role;
|
|
493
|
+
}
|
|
494
|
+
async function createRlsPolicy(schemaName, tableName, policy, lowerer) {
|
|
495
|
+
const validatedRoles = policy.roles.map(validateRoleName);
|
|
496
|
+
const ddlNode = createPolicy({
|
|
497
|
+
schema: schemaName,
|
|
498
|
+
table: tableName,
|
|
499
|
+
name: policy.name,
|
|
500
|
+
permissive: policy.permissive,
|
|
501
|
+
operation: policy.operation,
|
|
502
|
+
roles: validatedRoles,
|
|
503
|
+
...ifDefined("using", policy.using),
|
|
504
|
+
...ifDefined("withCheck", policy.withCheck)
|
|
505
|
+
});
|
|
506
|
+
const checks = rlsPolicyExistsAst({
|
|
507
|
+
schema: schemaName,
|
|
508
|
+
table: tableName,
|
|
509
|
+
policyName: policy.name
|
|
510
|
+
});
|
|
511
|
+
const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());
|
|
512
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
513
|
+
const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());
|
|
514
|
+
return {
|
|
515
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${policy.name}`,
|
|
516
|
+
label: `Create RLS policy "${policy.name}" on "${tableName}"`,
|
|
517
|
+
operationClass: "additive",
|
|
518
|
+
target: targetDetails("rlsPolicy", policy.name, schemaName, tableName),
|
|
519
|
+
precheck: [step(`ensure RLS policy "${policy.name}" does not exist`, absent.sql, absent.params)],
|
|
520
|
+
execute: [step(`create RLS policy "${policy.name}"`, execute.sql, execute.params)],
|
|
521
|
+
postcheck: [step(`verify RLS policy "${policy.name}" exists`, present.sql, present.params)]
|
|
522
|
+
};
|
|
523
|
+
}
|
|
524
|
+
async function dropRlsPolicy(schemaName, tableName, policyName, lowerer) {
|
|
525
|
+
const ddlNode = dropPolicy({
|
|
526
|
+
schema: schemaName,
|
|
527
|
+
table: tableName,
|
|
528
|
+
name: policyName
|
|
529
|
+
});
|
|
530
|
+
const checks = rlsPolicyExistsAst({
|
|
531
|
+
schema: schemaName,
|
|
532
|
+
table: tableName,
|
|
533
|
+
policyName
|
|
534
|
+
});
|
|
535
|
+
const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());
|
|
536
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
537
|
+
const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());
|
|
538
|
+
return {
|
|
539
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${policyName}.drop`,
|
|
540
|
+
label: `Drop RLS policy "${policyName}" on "${tableName}"`,
|
|
541
|
+
operationClass: "destructive",
|
|
542
|
+
target: targetDetails("rlsPolicy", policyName, schemaName, tableName),
|
|
543
|
+
precheck: [step(`ensure RLS policy "${policyName}" exists`, present.sql, present.params)],
|
|
544
|
+
execute: [step(`drop RLS policy "${policyName}"`, execute.sql, execute.params)],
|
|
545
|
+
postcheck: [step(`verify RLS policy "${policyName}" is absent`, absent.sql, absent.params)]
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
async function enableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
549
|
+
const checks = rlsEnabledAst(schemaName, tableName);
|
|
550
|
+
const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());
|
|
551
|
+
const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());
|
|
552
|
+
return {
|
|
553
|
+
id: `rowLevelSecurity.${schemaName}.${tableName}`,
|
|
554
|
+
label: `Enable row-level security on "${tableName}"`,
|
|
555
|
+
operationClass: "additive",
|
|
556
|
+
target: targetDetails("rowLevelSecurity", tableName, schemaName),
|
|
557
|
+
precheck: [step(`check RLS is not already enabled on "${tableName}"`, disabled.sql, disabled.params)],
|
|
558
|
+
execute: [step(`enable row-level security on "${tableName}"`, `ALTER TABLE ${qualifyTableName(schemaName, tableName)} ENABLE ROW LEVEL SECURITY`)],
|
|
559
|
+
postcheck: [step(`verify row-level security is enabled on "${tableName}"`, enabled.sql, enabled.params)]
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
async function disableRowLevelSecurity(schemaName, tableName, lowerer) {
|
|
563
|
+
const ddlNode = disableRowLevelSecurity$1({
|
|
564
|
+
schema: schemaName,
|
|
565
|
+
table: tableName
|
|
566
|
+
});
|
|
567
|
+
const checks = rlsEnabledAst(schemaName, tableName);
|
|
568
|
+
const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());
|
|
569
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
570
|
+
const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());
|
|
571
|
+
return {
|
|
572
|
+
id: `rowLevelSecurity.${schemaName}.${tableName}.disable`,
|
|
573
|
+
label: `Disable row-level security on "${tableName}"`,
|
|
574
|
+
operationClass: "destructive",
|
|
575
|
+
target: targetDetails("rowLevelSecurity", tableName, schemaName),
|
|
576
|
+
precheck: [step(`check RLS is currently enabled on "${tableName}"`, enabled.sql, enabled.params)],
|
|
577
|
+
execute: [step(`disable row-level security on "${tableName}"`, execute.sql, execute.params)],
|
|
578
|
+
postcheck: [step(`verify row-level security is disabled on "${tableName}"`, disabled.sql, disabled.params)]
|
|
579
|
+
};
|
|
580
|
+
}
|
|
581
|
+
async function renameRlsPolicy(schemaName, tableName, oldPolicyName, newPolicyName, lowerer) {
|
|
582
|
+
const ddlNode = alterPolicyRename({
|
|
583
|
+
schema: schemaName,
|
|
584
|
+
table: tableName,
|
|
585
|
+
name: oldPolicyName,
|
|
586
|
+
newName: newPolicyName
|
|
587
|
+
});
|
|
588
|
+
const oldChecks = rlsPolicyExistsAst({
|
|
589
|
+
schema: schemaName,
|
|
590
|
+
table: tableName,
|
|
591
|
+
policyName: oldPolicyName
|
|
592
|
+
});
|
|
593
|
+
const newChecks = rlsPolicyExistsAst({
|
|
594
|
+
schema: schemaName,
|
|
595
|
+
table: tableName,
|
|
596
|
+
policyName: newPolicyName
|
|
597
|
+
});
|
|
598
|
+
const oldPresent = await lowerer.lowerToExecuteRequest(oldChecks.policyPresent());
|
|
599
|
+
const execute = await lowerer.lowerToExecuteRequest(ddlNode);
|
|
600
|
+
const newPresent = await lowerer.lowerToExecuteRequest(newChecks.policyPresent());
|
|
601
|
+
return {
|
|
602
|
+
id: `rlsPolicy.${schemaName}.${tableName}.${oldPolicyName}.rename`,
|
|
603
|
+
label: `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`,
|
|
604
|
+
operationClass: "widening",
|
|
605
|
+
target: targetDetails("rlsPolicy", newPolicyName, schemaName, tableName),
|
|
606
|
+
precheck: [step(`ensure RLS policy "${oldPolicyName}" exists`, oldPresent.sql, oldPresent.params)],
|
|
607
|
+
execute: [step(`rename RLS policy "${oldPolicyName}" to "${newPolicyName}"`, execute.sql, execute.params)],
|
|
608
|
+
postcheck: [step(`verify RLS policy "${newPolicyName}" exists`, newPresent.sql, newPresent.params)]
|
|
609
|
+
};
|
|
610
|
+
}
|
|
611
|
+
//#endregion
|
|
466
612
|
//#region src/core/migrations/operations/tables.ts
|
|
467
613
|
async function dropTable(schemaName, tableName, lowerer) {
|
|
468
614
|
const qualified = qualifyTableName(schemaName, tableName);
|
|
@@ -504,7 +650,20 @@ function buildAddColumnOperationIdentity(schema, tableName, columnName) {
|
|
|
504
650
|
}
|
|
505
651
|
async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
506
652
|
const { schema, tableName, columnName, column, codecHooks, storageTypes, temporaryDefault, lowerer } = options;
|
|
507
|
-
const
|
|
653
|
+
const ddlColumn = col(columnName, buildColumnTypeSql(column, codecHooks, storageTypes), {
|
|
654
|
+
notNull: true,
|
|
655
|
+
default: new FunctionColumnDefault(temporaryDefault)
|
|
656
|
+
});
|
|
657
|
+
const addColumn = await lowerer.lowerToExecuteRequest(alterTable({
|
|
658
|
+
...ifDefined("schema", boundSchema(schema)),
|
|
659
|
+
table: tableName,
|
|
660
|
+
actions: [addColumnAction(ddlColumn)]
|
|
661
|
+
}));
|
|
662
|
+
const dropTempDefault = await lowerer.lowerToExecuteRequest(alterTable({
|
|
663
|
+
...ifDefined("schema", boundSchema(schema)),
|
|
664
|
+
table: tableName,
|
|
665
|
+
actions: [dropDefaultAction(columnName)]
|
|
666
|
+
}));
|
|
508
667
|
const absent = await lowerer.lowerToExecuteRequest(columnExistsAst({
|
|
509
668
|
schema,
|
|
510
669
|
table: tableName,
|
|
@@ -532,10 +691,10 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
532
691
|
precheck: [step(`ensure column "${columnName}" is missing`, absent.sql, absent.params)],
|
|
533
692
|
execute: [{
|
|
534
693
|
description: `add column "${columnName}"`,
|
|
535
|
-
sql:
|
|
694
|
+
sql: addColumn.sql
|
|
536
695
|
}, {
|
|
537
696
|
description: `drop temporary default from column "${columnName}"`,
|
|
538
|
-
sql:
|
|
697
|
+
sql: dropTempDefault.sql
|
|
539
698
|
}],
|
|
540
699
|
postcheck: [
|
|
541
700
|
step(`verify column "${columnName}" exists`, present.sql, present.params),
|
|
@@ -568,9 +727,6 @@ async function buildAddNotNullColumnWithTemporaryDefaultOperation(options) {
|
|
|
568
727
|
* `PostgresOpFactoryCall` union.
|
|
569
728
|
*/
|
|
570
729
|
const POSTGRES_MIGRATION_FACADE = "@prisma-next/postgres/migration";
|
|
571
|
-
function boundSchema(schemaName) {
|
|
572
|
-
return schemaName === UNBOUND_NAMESPACE_ID ? void 0 : schemaName;
|
|
573
|
-
}
|
|
574
730
|
var PostgresOpFactoryCallNode = class extends TsExpression {
|
|
575
731
|
importRequirements() {
|
|
576
732
|
return [{
|
|
@@ -625,6 +781,7 @@ function renderDdlConstraintAsTsCall(constraint) {
|
|
|
625
781
|
const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
|
|
626
782
|
return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
|
|
627
783
|
}
|
|
784
|
+
case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${jsonToTsSource(constraint.expression)})`;
|
|
628
785
|
}
|
|
629
786
|
}
|
|
630
787
|
function needsColOrConstraintImport(columns) {
|
|
@@ -636,6 +793,7 @@ function constraintImportSymbols(constraints) {
|
|
|
636
793
|
for (const c of constraints) if (c.kind === "primary-key") symbols.add("primaryKey");
|
|
637
794
|
else if (c.kind === "foreign-key") symbols.add("foreignKey");
|
|
638
795
|
else if (c.kind === "unique") symbols.add("unique");
|
|
796
|
+
else if (c.kind === "check-expression") symbols.add("checkExpression");
|
|
639
797
|
return [...symbols];
|
|
640
798
|
}
|
|
641
799
|
function defaultImportSymbols(columns) {
|
|
@@ -998,10 +1156,8 @@ var DropDefaultCall = class extends PostgresOpFactoryCallNode {
|
|
|
998
1156
|
};
|
|
999
1157
|
/**
|
|
1000
1158
|
* 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.
|
|
1159
|
+
* a table that must be empty at migration time. Carries the typed `DdlColumn`
|
|
1160
|
+
* and lowers it to an ADD COLUMN execute step via the adapter at `toOp` time.
|
|
1005
1161
|
*
|
|
1006
1162
|
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1007
1163
|
* planner, never hand-written by migration authors.
|
|
@@ -1012,20 +1168,20 @@ var AddNotNullColumnDirectCall = class extends PostgresOpFactoryCallNode {
|
|
|
1012
1168
|
schemaName;
|
|
1013
1169
|
tableName;
|
|
1014
1170
|
columnName;
|
|
1015
|
-
|
|
1171
|
+
column;
|
|
1016
1172
|
label;
|
|
1017
|
-
constructor(schemaName, tableName, columnName,
|
|
1173
|
+
constructor(schemaName, tableName, columnName, column) {
|
|
1018
1174
|
super();
|
|
1019
1175
|
this.schemaName = schemaName;
|
|
1020
1176
|
this.tableName = tableName;
|
|
1021
1177
|
this.columnName = columnName;
|
|
1022
|
-
this.
|
|
1178
|
+
this.column = column;
|
|
1023
1179
|
this.label = `Add column ${columnName} to ${tableName}`;
|
|
1024
1180
|
this.freeze();
|
|
1025
1181
|
}
|
|
1026
1182
|
async toOp(lowerer) {
|
|
1027
1183
|
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.
|
|
1184
|
+
return addNotNullColumnDirect(this.schemaName, this.tableName, this.column, lowerer);
|
|
1029
1185
|
}
|
|
1030
1186
|
renderTypeScript() {
|
|
1031
1187
|
return `rawSql(${jsonToTsSource({
|
|
@@ -1041,9 +1197,9 @@ var AddNotNullColumnDirectCall = class extends PostgresOpFactoryCallNode {
|
|
|
1041
1197
|
/**
|
|
1042
1198
|
* Planner-internal call for adding a NOT NULL column (no contract default)
|
|
1043
1199
|
* using a temporary default value for non-empty tables. Carries all parameters
|
|
1044
|
-
* needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; the
|
|
1045
|
-
* pre/postchecks are lowered
|
|
1046
|
-
*
|
|
1200
|
+
* needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; both the
|
|
1201
|
+
* typed ADD COLUMN execute step and the pre/postchecks are lowered via the
|
|
1202
|
+
* adapter at `toOp` time.
|
|
1047
1203
|
*
|
|
1048
1204
|
* No authored `PostgresMigration` method: this call is only emitted by the
|
|
1049
1205
|
* planner, never hand-written by migration authors.
|
|
@@ -1484,7 +1640,120 @@ var DataTransformCall = class extends PostgresOpFactoryCallNode {
|
|
|
1484
1640
|
}];
|
|
1485
1641
|
}
|
|
1486
1642
|
};
|
|
1643
|
+
var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1644
|
+
factoryName = "createRlsPolicy";
|
|
1645
|
+
operationClass = "additive";
|
|
1646
|
+
schemaName;
|
|
1647
|
+
tableName;
|
|
1648
|
+
policy;
|
|
1649
|
+
label;
|
|
1650
|
+
constructor(schemaName, tableName, policy) {
|
|
1651
|
+
super();
|
|
1652
|
+
this.schemaName = schemaName;
|
|
1653
|
+
this.tableName = tableName;
|
|
1654
|
+
this.policy = policy;
|
|
1655
|
+
this.label = `Create RLS policy "${policy.name}" on "${tableName}"`;
|
|
1656
|
+
this.freeze();
|
|
1657
|
+
}
|
|
1658
|
+
async toOp(lowerer) {
|
|
1659
|
+
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.`);
|
|
1660
|
+
return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
|
|
1661
|
+
}
|
|
1662
|
+
renderTypeScript() {
|
|
1663
|
+
return `createRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policy)})`;
|
|
1664
|
+
}
|
|
1665
|
+
};
|
|
1666
|
+
var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1667
|
+
factoryName = "dropRlsPolicy";
|
|
1668
|
+
operationClass = "destructive";
|
|
1669
|
+
schemaName;
|
|
1670
|
+
tableName;
|
|
1671
|
+
policyName;
|
|
1672
|
+
label;
|
|
1673
|
+
constructor(schemaName, tableName, policyName) {
|
|
1674
|
+
super();
|
|
1675
|
+
this.schemaName = schemaName;
|
|
1676
|
+
this.tableName = tableName;
|
|
1677
|
+
this.policyName = policyName;
|
|
1678
|
+
this.label = `Drop RLS policy "${policyName}" on "${tableName}"`;
|
|
1679
|
+
this.freeze();
|
|
1680
|
+
}
|
|
1681
|
+
async toOp(lowerer) {
|
|
1682
|
+
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.`);
|
|
1683
|
+
return dropRlsPolicy(this.schemaName, this.tableName, this.policyName, lowerer);
|
|
1684
|
+
}
|
|
1685
|
+
renderTypeScript() {
|
|
1686
|
+
return `dropRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policyName)})`;
|
|
1687
|
+
}
|
|
1688
|
+
};
|
|
1689
|
+
var EnableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
1690
|
+
factoryName = "enableRowLevelSecurity";
|
|
1691
|
+
operationClass = "additive";
|
|
1692
|
+
schemaName;
|
|
1693
|
+
tableName;
|
|
1694
|
+
label;
|
|
1695
|
+
constructor(schemaName, tableName) {
|
|
1696
|
+
super();
|
|
1697
|
+
this.schemaName = schemaName;
|
|
1698
|
+
this.tableName = tableName;
|
|
1699
|
+
this.label = `Enable row-level security on "${tableName}"`;
|
|
1700
|
+
this.freeze();
|
|
1701
|
+
}
|
|
1702
|
+
async toOp(lowerer) {
|
|
1703
|
+
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.`);
|
|
1704
|
+
return enableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1705
|
+
}
|
|
1706
|
+
renderTypeScript() {
|
|
1707
|
+
return `enableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1708
|
+
}
|
|
1709
|
+
};
|
|
1710
|
+
var DisableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
1711
|
+
factoryName = "disableRowLevelSecurity";
|
|
1712
|
+
operationClass = "destructive";
|
|
1713
|
+
schemaName;
|
|
1714
|
+
tableName;
|
|
1715
|
+
label;
|
|
1716
|
+
constructor(schemaName, tableName) {
|
|
1717
|
+
super();
|
|
1718
|
+
this.schemaName = schemaName;
|
|
1719
|
+
this.tableName = tableName;
|
|
1720
|
+
this.label = `Disable row-level security on "${tableName}"`;
|
|
1721
|
+
this.freeze();
|
|
1722
|
+
}
|
|
1723
|
+
async toOp(lowerer) {
|
|
1724
|
+
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.`);
|
|
1725
|
+
return disableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1726
|
+
}
|
|
1727
|
+
renderTypeScript() {
|
|
1728
|
+
return `disableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1729
|
+
}
|
|
1730
|
+
};
|
|
1731
|
+
var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
1732
|
+
factoryName = "renameRlsPolicy";
|
|
1733
|
+
operationClass = "widening";
|
|
1734
|
+
schemaName;
|
|
1735
|
+
tableName;
|
|
1736
|
+
oldPolicyName;
|
|
1737
|
+
newPolicyName;
|
|
1738
|
+
label;
|
|
1739
|
+
constructor(schemaName, tableName, oldPolicyName, newPolicyName) {
|
|
1740
|
+
super();
|
|
1741
|
+
this.schemaName = schemaName;
|
|
1742
|
+
this.tableName = tableName;
|
|
1743
|
+
this.oldPolicyName = oldPolicyName;
|
|
1744
|
+
this.newPolicyName = newPolicyName;
|
|
1745
|
+
this.label = `Rename RLS policy "${oldPolicyName}" to "${newPolicyName}" on "${tableName}"`;
|
|
1746
|
+
this.freeze();
|
|
1747
|
+
}
|
|
1748
|
+
async toOp(lowerer) {
|
|
1749
|
+
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.`);
|
|
1750
|
+
return renameRlsPolicy(this.schemaName, this.tableName, this.oldPolicyName, this.newPolicyName, lowerer);
|
|
1751
|
+
}
|
|
1752
|
+
renderTypeScript() {
|
|
1753
|
+
return `renameRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.oldPolicyName)}, ${jsonToTsSource(this.newPolicyName)})`;
|
|
1754
|
+
}
|
|
1755
|
+
};
|
|
1487
1756
|
//#endregion
|
|
1488
|
-
export {
|
|
1757
|
+
export { buildTargetDetails as A, DropTableCall as C, SetDefaultCall as D, RenamePostgresRlsPolicyCall as E, installExtension as M, SetNotNullCall as O, DropPostgresRlsPolicyCall as S, RawSqlCall as T, DropColumnCall as _, AddNotNullColumnWithTempDefaultCall as a, DropIndexCall as b, AlterColumnTypeCall as c, CreatePostgresRlsPolicyCall as d, CreateSchemaCall as f, DropCheckConstraintCall as g, DisableRowLevelSecurityCall as h, AddNotNullColumnDirectCall as i, createExtension as j, postgresDefaultToDdlColumnDefault as k, CreateExtensionCall as l, DataTransformCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateTableCall as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, CreateIndexCall as u, DropConstraintCall as v, EnableRowLevelSecurityCall as w, DropNotNullCall as x, DropDefaultCall as y };
|
|
1489
1758
|
|
|
1490
|
-
//# sourceMappingURL=op-factory-call-
|
|
1759
|
+
//# sourceMappingURL=op-factory-call-DxNNKUeZ.mjs.map
|