@prisma-next/target-postgres 0.16.0-dev.3 → 0.16.0-dev.31
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/README.md +1 -1
- package/dist/{authoring-34L18kA1.mjs → authoring-DnO1B0N9.mjs} +29 -18
- package/dist/authoring-DnO1B0N9.mjs.map +1 -0
- package/dist/canonicalize-C7zKHw8m.mjs +59 -0
- package/dist/canonicalize-C7zKHw8m.mjs.map +1 -0
- package/dist/{canonicalize-D1F4vUnP.d.mts → canonicalize-CQlxSR4D.d.mts} +3 -18
- package/dist/canonicalize-CQlxSR4D.d.mts.map +1 -0
- package/dist/{codec-types-CQ07nOz-.d.mts → codec-types-DdoPc2dy.d.mts} +3 -2
- package/dist/codec-types-DdoPc2dy.d.mts.map +1 -0
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-G4DTY0F_.d.mts → codecs-CGE5dh94.d.mts} +7 -2
- package/dist/codecs-CGE5dh94.d.mts.map +1 -0
- package/dist/{codecs-TCsGgW-Y.mjs → codecs-Deand7sy.mjs} +84 -26
- package/dist/codecs-Deand7sy.mjs.map +1 -0
- package/dist/codecs.d.mts +2 -2
- package/dist/codecs.mjs +2 -2
- package/dist/contract-free.d.mts +1 -1
- package/dist/contract-free.d.mts.map +1 -1
- package/dist/contract-free.mjs +2 -2
- package/dist/{control-policy-CZKdMztu.mjs → control-policy-DEwdS3oK.mjs} +29 -29
- package/dist/control-policy-DEwdS3oK.mjs.map +1 -0
- package/dist/control.mjs +91 -239
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-BOWpliq8.mjs.map +1 -1
- package/dist/{ddl-DHXKzQ99.mjs → ddl-BQC6u-L9.mjs} +28 -4
- package/dist/{ddl-DHXKzQ99.mjs.map → ddl-BQC6u-L9.mjs.map} +1 -1
- package/dist/ddl.d.mts +3 -3
- package/dist/ddl.mjs +2 -2
- package/dist/{descriptor-meta-qubYaxQA.mjs → descriptor-meta-DGlJurgA.mjs} +4 -4
- package/dist/{descriptor-meta-qubYaxQA.mjs.map → descriptor-meta-DGlJurgA.mjs.map} +1 -1
- package/dist/{diff-database-schema-C-hnJ5mr.mjs → diff-database-schema-qRPwuYBH.mjs} +37 -15
- package/dist/diff-database-schema-qRPwuYBH.mjs.map +1 -0
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/{errors-ByDS0xJL.mjs → errors-DBSNx7EJ.mjs} +6 -2
- package/dist/errors-DBSNx7EJ.mjs.map +1 -0
- package/dist/errors.d.mts +4 -1
- package/dist/errors.d.mts.map +1 -1
- package/dist/errors.mjs +2 -2
- package/dist/issue-planner.d.mts +2 -2
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/{nodes-DJC5B8Id.mjs → nodes-04EILM-z.mjs} +65 -2
- package/dist/nodes-04EILM-z.mjs.map +1 -0
- package/dist/{nodes-CQzM2hR0.d.mts → nodes-DjCsN-uv.d.mts} +69 -4
- package/dist/nodes-DjCsN-uv.d.mts.map +1 -0
- package/dist/{op-factory-call-DT7kdjVP.d.mts → op-factory-call-0TB5XNij.d.mts} +46 -8
- package/dist/op-factory-call-0TB5XNij.d.mts.map +1 -0
- package/dist/{op-factory-call-DuRj7WXX.mjs → op-factory-call-CIaPDDUc.mjs} +147 -64
- package/dist/op-factory-call-CIaPDDUc.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 +2 -2
- package/dist/pack.d.mts.map +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/{planner-DPGxFcXo.mjs → planner-BhnkIJX-.mjs} +121 -13
- package/dist/planner-BhnkIJX-.mjs.map +1 -0
- package/dist/{planner-ddl-builders-BKlmGDJl.mjs → planner-ddl-builders-CVo3L7Nd.mjs} +12 -7
- package/dist/planner-ddl-builders-CVo3L7Nd.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts.map +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-CFDpqWWE.mjs → planner-produced-postgres-migration-BE3EJIRK.mjs} +9 -6
- package/dist/planner-produced-postgres-migration-BE3EJIRK.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-C-dwGdb2.d.mts → planner-produced-postgres-migration-CRAHl6ak.d.mts} +3 -3
- package/dist/planner-produced-postgres-migration-CRAHl6ak.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/{planner-schema-lookup-CiVaAQP-.mjs → planner-schema-lookup-D3Y_OL-C.mjs} +3 -3
- package/dist/planner-schema-lookup-D3Y_OL-C.mjs.map +1 -0
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-BuB877wH.mjs → planner-sql-checks-CmiQ6Nei.mjs} +3 -3
- package/dist/{planner-sql-checks-BuB877wH.mjs.map → planner-sql-checks-CmiQ6Nei.mjs.map} +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/planner.d.mts +27 -1
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-contract-view-DebHMqGR.mjs → postgres-contract-view-BeIEyZfD.mjs} +3 -3
- package/dist/{postgres-contract-view-DebHMqGR.mjs.map → postgres-contract-view-BeIEyZfD.mjs.map} +1 -1
- package/dist/{postgres-migration-C_OPFhIF.mjs → postgres-migration--BzvpA92.mjs} +9 -6
- package/dist/postgres-migration--BzvpA92.mjs.map +1 -0
- package/dist/{postgres-migration-DLIvzHjX.d.mts → postgres-migration-BXelnqHO.d.mts} +15 -10
- package/dist/postgres-migration-BXelnqHO.d.mts.map +1 -0
- package/dist/{postgres-schema-CewLYHB7.mjs → postgres-schema-CTplQZDK.mjs} +2 -2
- package/dist/{postgres-schema-CewLYHB7.mjs.map → postgres-schema-CTplQZDK.mjs.map} +1 -1
- package/dist/{render-ops-BREh1kHe.mjs → render-ops-TcY9XEkz.mjs} +7 -2
- package/dist/render-ops-TcY9XEkz.mjs.map +1 -0
- package/dist/render-ops.d.mts.map +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-7yqILcwr.mjs → render-typescript-Ta7_6CGf.mjs} +20 -8
- package/dist/render-typescript-Ta7_6CGf.mjs.map +1 -0
- package/dist/render-typescript.d.mts +2 -0
- package/dist/render-typescript.d.mts.map +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/{resolve-ddl-schema-D0wi_P9Q.mjs → resolve-ddl-schema-BAsJEKW8.mjs} +2 -2
- package/dist/{resolve-ddl-schema-D0wi_P9Q.mjs.map → resolve-ddl-schema-BAsJEKW8.mjs.map} +1 -1
- package/dist/rls-canonicalize.d.mts +2 -26
- package/dist/rls-canonicalize.mjs +2 -2
- package/dist/runtime.mjs +1 -1
- package/dist/schema-ir-annotations.mjs +1 -1
- package/dist/{sql-utils-SU4FDvIV.mjs → sql-utils-B2lzkKfP.mjs} +22 -19
- package/dist/sql-utils-B2lzkKfP.mjs.map +1 -0
- package/dist/sql-utils.d.mts +4 -9
- package/dist/sql-utils.d.mts.map +1 -1
- package/dist/sql-utils.mjs +2 -2
- package/dist/types.mjs +1 -1
- package/package.json +20 -20
- package/src/contract-free/ddl.ts +47 -0
- package/src/core/authoring.ts +35 -26
- package/src/core/codec-helpers.ts +69 -16
- package/src/core/codec-type-map.ts +2 -0
- package/src/core/codecs.ts +29 -14
- package/src/core/ddl/nodes.ts +104 -0
- package/src/core/errors.ts +30 -0
- package/src/core/migrations/column-ddl-rendering.ts +2 -1
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +38 -14
- package/src/core/migrations/issue-planner.ts +40 -13
- package/src/core/migrations/op-factory-call.ts +189 -44
- package/src/core/migrations/operations/constraints.ts +3 -2
- package/src/core/migrations/operations/data-transform.ts +1 -1
- package/src/core/migrations/operations/indexes.ts +80 -32
- package/src/core/migrations/operations/rls.ts +4 -1
- package/src/core/migrations/planner-ddl-builders.ts +16 -6
- package/src/core/migrations/planner-produced-postgres-migration.ts +8 -1
- package/src/core/migrations/planner-schema-lookup.ts +2 -2
- package/src/core/migrations/planner.ts +163 -5
- package/src/core/migrations/postgres-migration.ts +26 -8
- package/src/core/migrations/render-ops.ts +4 -1
- package/src/core/migrations/render-typescript.ts +20 -8
- package/src/core/migrations/runner.ts +7 -3
- package/src/core/psl-infer/infer-psl-contract.ts +36 -185
- package/src/core/psl-infer/postgres-type-map.ts +43 -65
- package/src/core/rls/canonicalize.ts +4 -21
- package/src/core/sql-utils.ts +16 -27
- package/src/exports/codecs.ts +2 -0
- package/src/exports/ddl.ts +4 -0
- package/src/exports/errors.ts +1 -1
- package/src/exports/op-factory-call.ts +1 -0
- package/src/exports/rls-canonicalize.ts +0 -6
- package/src/exports/sql-utils.ts +0 -1
- package/dist/authoring-34L18kA1.mjs.map +0 -1
- package/dist/canonicalize-D1F4vUnP.d.mts.map +0 -1
- package/dist/codec-types-CQ07nOz-.d.mts.map +0 -1
- package/dist/codecs-G4DTY0F_.d.mts.map +0 -1
- package/dist/codecs-TCsGgW-Y.mjs.map +0 -1
- package/dist/control-policy-CZKdMztu.mjs.map +0 -1
- package/dist/diff-database-schema-C-hnJ5mr.mjs.map +0 -1
- package/dist/errors-ByDS0xJL.mjs.map +0 -1
- package/dist/nodes-CQzM2hR0.d.mts.map +0 -1
- package/dist/nodes-DJC5B8Id.mjs.map +0 -1
- package/dist/op-factory-call-DT7kdjVP.d.mts.map +0 -1
- package/dist/op-factory-call-DuRj7WXX.mjs.map +0 -1
- package/dist/planner-DPGxFcXo.mjs.map +0 -1
- package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +0 -1
- package/dist/planner-produced-postgres-migration-C-dwGdb2.d.mts.map +0 -1
- package/dist/planner-produced-postgres-migration-CFDpqWWE.mjs.map +0 -1
- package/dist/planner-schema-lookup-CiVaAQP-.mjs.map +0 -1
- package/dist/postgres-migration-C_OPFhIF.mjs.map +0 -1
- package/dist/postgres-migration-DLIvzHjX.d.mts.map +0 -1
- package/dist/render-ops-BREh1kHe.mjs.map +0 -1
- package/dist/render-typescript-7yqILcwr.mjs.map +0 -1
- package/dist/rls-canonicalize.d.mts.map +0 -1
- package/dist/sql-utils-SU4FDvIV.mjs.map +0 -1
- package/dist/wire-name-DbQ9-2RC.mjs +0 -104
- package/dist/wire-name-DbQ9-2RC.mjs.map +0 -1
- package/src/core/rls/wire-name.ts +0 -33
|
@@ -38,6 +38,7 @@ import { FunctionColumnDefault, LiteralColumnDefault } from '@prisma-next/sql-re
|
|
|
38
38
|
import { type ImportRequirement, jsonToTsSource, TsExpression } from '@prisma-next/ts-render';
|
|
39
39
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
40
40
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
41
|
+
import { assertNever } from '@prisma-next/utils/internal-error';
|
|
41
42
|
import {
|
|
42
43
|
columnExistsAst,
|
|
43
44
|
nativeEnumTypeExistsAst,
|
|
@@ -45,6 +46,7 @@ import {
|
|
|
45
46
|
tableExistsAst,
|
|
46
47
|
} from '../../contract-free/checks';
|
|
47
48
|
import * as contractFreeDdl from '../../contract-free/ddl';
|
|
49
|
+
import { postgresError } from '../errors';
|
|
48
50
|
import type { PostgresRlsPolicy, PostgresRlsPolicyInput } from '../postgres-rls-policy';
|
|
49
51
|
import {
|
|
50
52
|
escapeLiteral,
|
|
@@ -72,7 +74,13 @@ import {
|
|
|
72
74
|
dropConstraint,
|
|
73
75
|
} from './operations/constraints';
|
|
74
76
|
import { createExtension } from './operations/dependencies';
|
|
75
|
-
import {
|
|
77
|
+
import {
|
|
78
|
+
type CreateIndexElements,
|
|
79
|
+
type CreateIndexExtras,
|
|
80
|
+
createIndex,
|
|
81
|
+
dropIndex,
|
|
82
|
+
renameIndex,
|
|
83
|
+
} from './operations/indexes';
|
|
76
84
|
import { createNativeEnumType, dropNativeEnumType } from './operations/native-enum-types';
|
|
77
85
|
import {
|
|
78
86
|
createRlsPolicy,
|
|
@@ -138,7 +146,8 @@ export function postgresDefaultToDdlColumnDefault(
|
|
|
138
146
|
);
|
|
139
147
|
default: {
|
|
140
148
|
const exhaustive: never = columnDefault;
|
|
141
|
-
|
|
149
|
+
return assertNever(
|
|
150
|
+
exhaustive,
|
|
142
151
|
`postgresDefaultToDdlColumnDefault: unhandled kind "${blindCast<{ kind: string }, 'exhaustiveness: surface the unhandled default kind'>(exhaustive).kind}"`,
|
|
143
152
|
);
|
|
144
153
|
}
|
|
@@ -241,8 +250,10 @@ export class CreateTableCall extends PostgresOpFactoryCallNode {
|
|
|
241
250
|
|
|
242
251
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
243
252
|
if (lowerer === undefined) {
|
|
244
|
-
throw
|
|
253
|
+
throw postgresError(
|
|
254
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
245
255
|
`CreateTableCall.toOp: a DDL lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
256
|
+
{ meta: { factory: 'CreateTableCall' } },
|
|
246
257
|
);
|
|
247
258
|
}
|
|
248
259
|
const ddlNode = contractFreeDdl.createTable({
|
|
@@ -324,8 +335,10 @@ export class DropTableCall extends PostgresOpFactoryCallNode {
|
|
|
324
335
|
|
|
325
336
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
326
337
|
if (lowerer === undefined) {
|
|
327
|
-
throw
|
|
338
|
+
throw postgresError(
|
|
339
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
328
340
|
`DropTableCall.toOp: a lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
341
|
+
{ meta: { factory: 'DropTableCall' } },
|
|
329
342
|
);
|
|
330
343
|
}
|
|
331
344
|
return dropTable(this.schemaName, this.tableName, lowerer);
|
|
@@ -368,8 +381,10 @@ export class AddColumnCall extends PostgresOpFactoryCallNode {
|
|
|
368
381
|
|
|
369
382
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
370
383
|
if (lowerer === undefined) {
|
|
371
|
-
throw
|
|
384
|
+
throw postgresError(
|
|
385
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
372
386
|
`AddColumnCall.toOp: a DDL lowerer is required on the Postgres planner path (column "${this.column.name}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
387
|
+
{ meta: { factory: 'AddColumnCall' } },
|
|
373
388
|
);
|
|
374
389
|
}
|
|
375
390
|
const ddlNode = contractFreeDdl.alterTable({
|
|
@@ -435,8 +450,10 @@ export class DropColumnCall extends PostgresOpFactoryCallNode {
|
|
|
435
450
|
|
|
436
451
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
437
452
|
if (lowerer === undefined) {
|
|
438
|
-
throw
|
|
453
|
+
throw postgresError(
|
|
454
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
439
455
|
`DropColumnCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
456
|
+
{ meta: { factory: 'DropColumnCall' } },
|
|
440
457
|
);
|
|
441
458
|
}
|
|
442
459
|
return dropColumn(this.schemaName, this.tableName, this.columnName, lowerer);
|
|
@@ -490,8 +507,10 @@ export class AlterColumnTypeCall extends PostgresOpFactoryCallNode {
|
|
|
490
507
|
|
|
491
508
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
492
509
|
if (lowerer === undefined) {
|
|
493
|
-
throw
|
|
510
|
+
throw postgresError(
|
|
511
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
494
512
|
`AlterColumnTypeCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
513
|
+
{ meta: { factory: 'AlterColumnTypeCall' } },
|
|
495
514
|
);
|
|
496
515
|
}
|
|
497
516
|
return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options, lowerer);
|
|
@@ -532,8 +551,10 @@ export class SetNotNullCall extends PostgresOpFactoryCallNode {
|
|
|
532
551
|
|
|
533
552
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
534
553
|
if (lowerer === undefined) {
|
|
535
|
-
throw
|
|
554
|
+
throw postgresError(
|
|
555
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
536
556
|
`SetNotNullCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
557
|
+
{ meta: { factory: 'SetNotNullCall' } },
|
|
537
558
|
);
|
|
538
559
|
}
|
|
539
560
|
return setNotNull(this.schemaName, this.tableName, this.columnName, lowerer);
|
|
@@ -573,8 +594,10 @@ export class DropNotNullCall extends PostgresOpFactoryCallNode {
|
|
|
573
594
|
|
|
574
595
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
575
596
|
if (lowerer === undefined) {
|
|
576
|
-
throw
|
|
597
|
+
throw postgresError(
|
|
598
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
577
599
|
`DropNotNullCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
600
|
+
{ meta: { factory: 'DropNotNullCall' } },
|
|
578
601
|
);
|
|
579
602
|
}
|
|
580
603
|
return dropNotNull(this.schemaName, this.tableName, this.columnName, lowerer);
|
|
@@ -623,8 +646,10 @@ export class SetDefaultCall extends PostgresOpFactoryCallNode {
|
|
|
623
646
|
|
|
624
647
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
625
648
|
if (lowerer === undefined) {
|
|
626
|
-
throw
|
|
649
|
+
throw postgresError(
|
|
650
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
627
651
|
`SetDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
652
|
+
{ meta: { factory: 'SetDefaultCall' } },
|
|
628
653
|
);
|
|
629
654
|
}
|
|
630
655
|
return setDefault(
|
|
@@ -675,8 +700,10 @@ export class DropDefaultCall extends PostgresOpFactoryCallNode {
|
|
|
675
700
|
|
|
676
701
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
677
702
|
if (lowerer === undefined) {
|
|
678
|
-
throw
|
|
703
|
+
throw postgresError(
|
|
704
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
679
705
|
`DropDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
706
|
+
{ meta: { factory: 'DropDefaultCall' } },
|
|
680
707
|
);
|
|
681
708
|
}
|
|
682
709
|
return dropDefault(this.schemaName, this.tableName, this.columnName, lowerer);
|
|
@@ -730,8 +757,10 @@ export class AddNotNullColumnDirectCall extends PostgresOpFactoryCallNode {
|
|
|
730
757
|
|
|
731
758
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
732
759
|
if (lowerer === undefined) {
|
|
733
|
-
throw
|
|
760
|
+
throw postgresError(
|
|
761
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
734
762
|
`AddNotNullColumnDirectCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
763
|
+
{ meta: { factory: 'AddNotNullColumnDirectCall' } },
|
|
735
764
|
);
|
|
736
765
|
}
|
|
737
766
|
return addNotNullColumnDirect(this.schemaName, this.tableName, this.column, lowerer);
|
|
@@ -787,8 +816,10 @@ export class AddNotNullColumnWithTempDefaultCall extends PostgresOpFactoryCallNo
|
|
|
787
816
|
|
|
788
817
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
789
818
|
if (lowerer === undefined) {
|
|
790
|
-
throw
|
|
819
|
+
throw postgresError(
|
|
820
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
791
821
|
`AddNotNullColumnWithTempDefaultCall.toOp: a lowerer is required on the Postgres planner path (column "${this.columnName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
822
|
+
{ meta: { factory: 'AddNotNullColumnWithTempDefaultCall' } },
|
|
792
823
|
);
|
|
793
824
|
}
|
|
794
825
|
return buildAddNotNullColumnWithTemporaryDefaultOperation({
|
|
@@ -852,8 +883,10 @@ export class AddPrimaryKeyCall extends PostgresOpFactoryCallNode {
|
|
|
852
883
|
|
|
853
884
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
854
885
|
if (lowerer === undefined) {
|
|
855
|
-
throw
|
|
886
|
+
throw postgresError(
|
|
887
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
856
888
|
`AddPrimaryKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.constraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
889
|
+
{ meta: { factory: 'AddPrimaryKeyCall' } },
|
|
857
890
|
);
|
|
858
891
|
}
|
|
859
892
|
return addPrimaryKey(
|
|
@@ -900,8 +933,10 @@ export class AddUniqueCall extends PostgresOpFactoryCallNode {
|
|
|
900
933
|
|
|
901
934
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
902
935
|
if (lowerer === undefined) {
|
|
903
|
-
throw
|
|
936
|
+
throw postgresError(
|
|
937
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
904
938
|
`AddUniqueCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.constraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
939
|
+
{ meta: { factory: 'AddUniqueCall' } },
|
|
905
940
|
);
|
|
906
941
|
}
|
|
907
942
|
return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns, lowerer);
|
|
@@ -935,8 +970,10 @@ export class AddForeignKeyCall extends PostgresOpFactoryCallNode {
|
|
|
935
970
|
|
|
936
971
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
937
972
|
if (lowerer === undefined) {
|
|
938
|
-
throw
|
|
973
|
+
throw postgresError(
|
|
974
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
939
975
|
`AddForeignKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.fk.name}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
976
|
+
{ meta: { factory: 'AddForeignKeyCall' } },
|
|
940
977
|
);
|
|
941
978
|
}
|
|
942
979
|
return addForeignKey(this.schemaName, this.tableName, this.fk, lowerer);
|
|
@@ -983,8 +1020,10 @@ export class DropConstraintCall extends PostgresOpFactoryCallNode {
|
|
|
983
1020
|
|
|
984
1021
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
985
1022
|
if (lowerer === undefined) {
|
|
986
|
-
throw
|
|
1023
|
+
throw postgresError(
|
|
1024
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
987
1025
|
`DropConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.constraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1026
|
+
{ meta: { factory: 'DropConstraintCall' } },
|
|
988
1027
|
);
|
|
989
1028
|
}
|
|
990
1029
|
return dropConstraint(this.schemaName, this.tableName, this.constraintName, lowerer, this.kind);
|
|
@@ -1032,8 +1071,10 @@ export class AddCheckConstraintCall extends PostgresOpFactoryCallNode {
|
|
|
1032
1071
|
|
|
1033
1072
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1034
1073
|
if (lowerer === undefined) {
|
|
1035
|
-
throw
|
|
1074
|
+
throw postgresError(
|
|
1075
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1036
1076
|
`AddCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.constraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1077
|
+
{ meta: { factory: 'AddCheckConstraintCall' } },
|
|
1037
1078
|
);
|
|
1038
1079
|
}
|
|
1039
1080
|
return addCheckConstraint(
|
|
@@ -1074,8 +1115,10 @@ export class DropCheckConstraintCall extends PostgresOpFactoryCallNode {
|
|
|
1074
1115
|
|
|
1075
1116
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1076
1117
|
if (lowerer === undefined) {
|
|
1077
|
-
throw
|
|
1118
|
+
throw postgresError(
|
|
1119
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1078
1120
|
`DropCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.constraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1121
|
+
{ meta: { factory: 'DropCheckConstraintCall' } },
|
|
1079
1122
|
);
|
|
1080
1123
|
}
|
|
1081
1124
|
return dropCheckConstraint(this.schemaName, this.tableName, this.constraintName, lowerer);
|
|
@@ -1100,45 +1143,64 @@ export class CreateIndexCall extends PostgresOpFactoryCallNode {
|
|
|
1100
1143
|
readonly schemaName: string;
|
|
1101
1144
|
readonly tableName: string;
|
|
1102
1145
|
readonly indexName: string;
|
|
1103
|
-
|
|
1146
|
+
/** Column tuple when the index is column-based; absent for expression indexes. */
|
|
1147
|
+
readonly columns: readonly string[] | undefined;
|
|
1148
|
+
/** Opaque whole element list when the index is expression-based. */
|
|
1149
|
+
readonly expression: string | undefined;
|
|
1104
1150
|
// Named indexType (not typeName): `locationForCall` in issue-planner.ts reads
|
|
1105
1151
|
// a call's `typeName` as a CREATE TYPE target location, which an index is not.
|
|
1106
1152
|
readonly indexType: string | undefined;
|
|
1107
1153
|
readonly options: Record<string, unknown> | undefined;
|
|
1154
|
+
readonly where: string | undefined;
|
|
1155
|
+
readonly unique: boolean;
|
|
1108
1156
|
readonly label: string;
|
|
1109
1157
|
|
|
1110
1158
|
constructor(
|
|
1111
1159
|
schemaName: string,
|
|
1112
1160
|
tableName: string,
|
|
1113
1161
|
indexName: string,
|
|
1114
|
-
|
|
1115
|
-
extras?:
|
|
1162
|
+
elements: CreateIndexElements,
|
|
1163
|
+
extras?: CreateIndexExtras,
|
|
1116
1164
|
) {
|
|
1117
1165
|
super();
|
|
1118
1166
|
this.schemaName = schemaName;
|
|
1119
1167
|
this.tableName = tableName;
|
|
1120
1168
|
this.indexName = indexName;
|
|
1121
|
-
this.columns = columns;
|
|
1169
|
+
this.columns = 'columns' in elements ? elements.columns : undefined;
|
|
1170
|
+
this.expression = 'expression' in elements ? elements.expression : undefined;
|
|
1122
1171
|
this.indexType = extras?.type;
|
|
1123
1172
|
this.options = extras?.options;
|
|
1173
|
+
this.where = extras?.where;
|
|
1174
|
+
this.unique = extras?.unique === true;
|
|
1124
1175
|
this.label = `Create index "${indexName}" on "${tableName}"`;
|
|
1125
1176
|
this.freeze();
|
|
1126
1177
|
}
|
|
1127
1178
|
|
|
1128
1179
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1129
1180
|
if (lowerer === undefined) {
|
|
1130
|
-
throw
|
|
1181
|
+
throw postgresError(
|
|
1182
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1131
1183
|
`CreateIndexCall.toOp: a lowerer is required on the Postgres planner path (index "${this.indexName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1184
|
+
{ meta: { factory: 'CreateIndexCall' } },
|
|
1132
1185
|
);
|
|
1133
1186
|
}
|
|
1134
|
-
const extras: {
|
|
1187
|
+
const extras: {
|
|
1188
|
+
type?: string;
|
|
1189
|
+
options?: Record<string, unknown>;
|
|
1190
|
+
where?: string;
|
|
1191
|
+
unique?: boolean;
|
|
1192
|
+
} = {};
|
|
1135
1193
|
if (this.indexType !== undefined) extras.type = this.indexType;
|
|
1136
1194
|
if (this.options !== undefined) extras.options = this.options;
|
|
1195
|
+
if (this.where !== undefined) extras.where = this.where;
|
|
1196
|
+
if (this.unique) extras.unique = true;
|
|
1137
1197
|
return createIndex(
|
|
1138
1198
|
this.schemaName,
|
|
1139
1199
|
this.tableName,
|
|
1140
1200
|
this.indexName,
|
|
1141
|
-
this.columns
|
|
1201
|
+
this.columns !== undefined
|
|
1202
|
+
? { columns: this.columns }
|
|
1203
|
+
: { expression: this.expression ?? '' },
|
|
1142
1204
|
lowerer,
|
|
1143
1205
|
extras,
|
|
1144
1206
|
);
|
|
@@ -1151,11 +1213,22 @@ export class CreateIndexCall extends PostgresOpFactoryCallNode {
|
|
|
1151
1213
|
}
|
|
1152
1214
|
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1153
1215
|
opts.push(`index: ${jsonToTsSource(this.indexName)}`);
|
|
1154
|
-
|
|
1155
|
-
|
|
1216
|
+
if (this.columns !== undefined) {
|
|
1217
|
+
opts.push(`columns: ${jsonToTsSource(this.columns)}`);
|
|
1218
|
+
} else {
|
|
1219
|
+
opts.push(`expression: ${jsonToTsSource(this.expression ?? '')}`);
|
|
1220
|
+
}
|
|
1221
|
+
if (
|
|
1222
|
+
this.indexType !== undefined ||
|
|
1223
|
+
this.options !== undefined ||
|
|
1224
|
+
this.where !== undefined ||
|
|
1225
|
+
this.unique
|
|
1226
|
+
) {
|
|
1156
1227
|
const extrasParts: string[] = [];
|
|
1157
1228
|
if (this.indexType !== undefined) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);
|
|
1158
1229
|
if (this.options !== undefined) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);
|
|
1230
|
+
if (this.where !== undefined) extrasParts.push(`where: ${jsonToTsSource(this.where)}`);
|
|
1231
|
+
if (this.unique) extrasParts.push('unique: true');
|
|
1159
1232
|
opts.push(`extras: { ${extrasParts.join(', ')} }`);
|
|
1160
1233
|
}
|
|
1161
1234
|
return `this.createIndex({ ${opts.join(', ')} })`;
|
|
@@ -1166,6 +1239,62 @@ export class CreateIndexCall extends PostgresOpFactoryCallNode {
|
|
|
1166
1239
|
}
|
|
1167
1240
|
}
|
|
1168
1241
|
|
|
1242
|
+
export class RenameIndexCall extends PostgresOpFactoryCallNode {
|
|
1243
|
+
readonly factoryName = 'renameIndex' as const;
|
|
1244
|
+
// `widening` is chosen so the rename plans under every allowance set except
|
|
1245
|
+
// additive-only init — a rename is neither additive-creation nor
|
|
1246
|
+
// destructive, and the class vocabulary has no neutral middle class. It is
|
|
1247
|
+
// NOT that a rename widens anything; this is the accepted typology tradeoff.
|
|
1248
|
+
readonly operationClass = 'widening' as const;
|
|
1249
|
+
readonly schemaName: string;
|
|
1250
|
+
readonly tableName: string;
|
|
1251
|
+
readonly oldIndexName: string;
|
|
1252
|
+
readonly newIndexName: string;
|
|
1253
|
+
readonly label: string;
|
|
1254
|
+
|
|
1255
|
+
constructor(schemaName: string, tableName: string, oldIndexName: string, newIndexName: string) {
|
|
1256
|
+
super();
|
|
1257
|
+
this.schemaName = schemaName;
|
|
1258
|
+
this.tableName = tableName;
|
|
1259
|
+
this.oldIndexName = oldIndexName;
|
|
1260
|
+
this.newIndexName = newIndexName;
|
|
1261
|
+
this.label = `Rename index "${oldIndexName}" to "${newIndexName}" on "${tableName}"`;
|
|
1262
|
+
this.freeze();
|
|
1263
|
+
}
|
|
1264
|
+
|
|
1265
|
+
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1266
|
+
if (lowerer === undefined) {
|
|
1267
|
+
throw postgresError(
|
|
1268
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1269
|
+
`RenameIndexCall.toOp: a lowerer is required on the Postgres planner path (index "${this.oldIndexName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1270
|
+
{ meta: { factory: 'RenameIndexCall' } },
|
|
1271
|
+
);
|
|
1272
|
+
}
|
|
1273
|
+
return renameIndex(
|
|
1274
|
+
this.schemaName,
|
|
1275
|
+
this.tableName,
|
|
1276
|
+
this.oldIndexName,
|
|
1277
|
+
this.newIndexName,
|
|
1278
|
+
lowerer,
|
|
1279
|
+
);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
renderTypeScript(): string {
|
|
1283
|
+
const opts: string[] = [];
|
|
1284
|
+
if (this.schemaName !== UNBOUND_NAMESPACE_ID) {
|
|
1285
|
+
opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
|
|
1286
|
+
}
|
|
1287
|
+
opts.push(`table: ${jsonToTsSource(this.tableName)}`);
|
|
1288
|
+
opts.push(`from: ${jsonToTsSource(this.oldIndexName)}`);
|
|
1289
|
+
opts.push(`to: ${jsonToTsSource(this.newIndexName)}`);
|
|
1290
|
+
return `this.renameIndex({ ${opts.join(', ')} })`;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1293
|
+
override importRequirements(): readonly ImportRequirement[] {
|
|
1294
|
+
return [];
|
|
1295
|
+
}
|
|
1296
|
+
}
|
|
1297
|
+
|
|
1169
1298
|
export class DropIndexCall extends PostgresOpFactoryCallNode {
|
|
1170
1299
|
readonly factoryName = 'dropIndex' as const;
|
|
1171
1300
|
readonly operationClass = 'destructive' as const;
|
|
@@ -1185,8 +1314,10 @@ export class DropIndexCall extends PostgresOpFactoryCallNode {
|
|
|
1185
1314
|
|
|
1186
1315
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1187
1316
|
if (lowerer === undefined) {
|
|
1188
|
-
throw
|
|
1317
|
+
throw postgresError(
|
|
1318
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1189
1319
|
`DropIndexCall.toOp: a lowerer is required on the Postgres planner path (index "${this.indexName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1320
|
+
{ meta: { factory: 'DropIndexCall' } },
|
|
1190
1321
|
);
|
|
1191
1322
|
}
|
|
1192
1323
|
return dropIndex(this.schemaName, this.tableName, this.indexName, lowerer);
|
|
@@ -1288,8 +1419,10 @@ export class CreateSchemaCall extends PostgresOpFactoryCallNode {
|
|
|
1288
1419
|
|
|
1289
1420
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1290
1421
|
if (lowerer === undefined) {
|
|
1291
|
-
throw
|
|
1422
|
+
throw postgresError(
|
|
1423
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1292
1424
|
`CreateSchemaCall.toOp: a DDL lowerer is required on the Postgres planner path (schema "${this.schemaName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1425
|
+
{ meta: { factory: 'CreateSchemaCall' } },
|
|
1293
1426
|
);
|
|
1294
1427
|
}
|
|
1295
1428
|
const ddlNode = contractFreeDdl.createSchema({ schema: this.schemaName, ifNotExists: true });
|
|
@@ -1344,8 +1477,10 @@ export class CreateNativeEnumTypeCall extends PostgresOpFactoryCallNode {
|
|
|
1344
1477
|
|
|
1345
1478
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1346
1479
|
if (lowerer === undefined) {
|
|
1347
|
-
throw
|
|
1480
|
+
throw postgresError(
|
|
1481
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1348
1482
|
`CreateNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type "${this.typeName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1483
|
+
{ meta: { factory: 'CreateNativeEnumTypeCall' } },
|
|
1349
1484
|
);
|
|
1350
1485
|
}
|
|
1351
1486
|
return createNativeEnumType(this.schemaName, this.typeName, this.members, lowerer);
|
|
@@ -1382,8 +1517,10 @@ export class DropNativeEnumTypeCall extends PostgresOpFactoryCallNode {
|
|
|
1382
1517
|
|
|
1383
1518
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1384
1519
|
if (lowerer === undefined) {
|
|
1385
|
-
throw
|
|
1520
|
+
throw postgresError(
|
|
1521
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1386
1522
|
`DropNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type "${this.typeName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1523
|
+
{ meta: { factory: 'DropNativeEnumTypeCall' } },
|
|
1387
1524
|
);
|
|
1388
1525
|
}
|
|
1389
1526
|
return dropNativeEnumType(this.schemaName, this.typeName, lowerer);
|
|
@@ -1444,8 +1581,10 @@ export class AddNativeEnumValueCall extends PostgresOpFactoryCallNode {
|
|
|
1444
1581
|
|
|
1445
1582
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1446
1583
|
if (lowerer === undefined) {
|
|
1447
|
-
throw
|
|
1584
|
+
throw postgresError(
|
|
1585
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1448
1586
|
`AddNativeEnumValueCall.toOp: a lowerer is required on the Postgres planner path (type "${this.typeName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1587
|
+
{ meta: { factory: 'AddNativeEnumValueCall' } },
|
|
1449
1588
|
);
|
|
1450
1589
|
}
|
|
1451
1590
|
const { schemaName, typeName, value } = this;
|
|
@@ -1547,12 +1686,7 @@ export class DataTransformCall extends PostgresOpFactoryCallNode {
|
|
|
1547
1686
|
override importRequirements(): readonly ImportRequirement[] {
|
|
1548
1687
|
return [
|
|
1549
1688
|
{ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'placeholder' },
|
|
1550
|
-
|
|
1551
|
-
moduleSpecifier: './end-contract.json',
|
|
1552
|
-
symbol: 'endContract',
|
|
1553
|
-
kind: 'default',
|
|
1554
|
-
attributes: { type: 'json' },
|
|
1555
|
-
},
|
|
1689
|
+
// endContract is imported by the migration scaffold's contractImports; an op never renders outside it.
|
|
1556
1690
|
];
|
|
1557
1691
|
}
|
|
1558
1692
|
}
|
|
@@ -1576,8 +1710,10 @@ export class CreatePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
1576
1710
|
|
|
1577
1711
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1578
1712
|
if (lowerer === undefined) {
|
|
1579
|
-
throw
|
|
1713
|
+
throw postgresError(
|
|
1714
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1580
1715
|
`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.`,
|
|
1716
|
+
{ meta: { factory: 'CreatePostgresRlsPolicyCall' } },
|
|
1581
1717
|
);
|
|
1582
1718
|
}
|
|
1583
1719
|
return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
|
|
@@ -1623,8 +1759,10 @@ export class DropPostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
1623
1759
|
|
|
1624
1760
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1625
1761
|
if (lowerer === undefined) {
|
|
1626
|
-
throw
|
|
1762
|
+
throw postgresError(
|
|
1763
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1627
1764
|
`DropPostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy "${this.policyName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1765
|
+
{ meta: { factory: 'DropPostgresRlsPolicyCall' } },
|
|
1628
1766
|
);
|
|
1629
1767
|
}
|
|
1630
1768
|
return dropRlsPolicy(this.schemaName, this.tableName, this.policyName, lowerer);
|
|
@@ -1656,8 +1794,10 @@ export class EnableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
|
1656
1794
|
|
|
1657
1795
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1658
1796
|
if (lowerer === undefined) {
|
|
1659
|
-
throw
|
|
1797
|
+
throw postgresError(
|
|
1798
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1660
1799
|
`EnableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1800
|
+
{ meta: { factory: 'EnableRowLevelSecurityCall' } },
|
|
1661
1801
|
);
|
|
1662
1802
|
}
|
|
1663
1803
|
return enableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
@@ -1689,8 +1829,10 @@ export class DisableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
|
1689
1829
|
|
|
1690
1830
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1691
1831
|
if (lowerer === undefined) {
|
|
1692
|
-
throw
|
|
1832
|
+
throw postgresError(
|
|
1833
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1693
1834
|
`DisableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1835
|
+
{ meta: { factory: 'DisableRowLevelSecurityCall' } },
|
|
1694
1836
|
);
|
|
1695
1837
|
}
|
|
1696
1838
|
return disableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
@@ -1730,8 +1872,10 @@ export class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
1730
1872
|
|
|
1731
1873
|
async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {
|
|
1732
1874
|
if (lowerer === undefined) {
|
|
1733
|
-
throw
|
|
1875
|
+
throw postgresError(
|
|
1876
|
+
'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',
|
|
1734
1877
|
`RenamePostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy "${this.oldPolicyName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`,
|
|
1878
|
+
{ meta: { factory: 'RenamePostgresRlsPolicyCall' } },
|
|
1735
1879
|
);
|
|
1736
1880
|
}
|
|
1737
1881
|
return renameRlsPolicy(
|
|
@@ -1770,6 +1914,7 @@ export type PostgresOpFactoryCall =
|
|
|
1770
1914
|
| AddCheckConstraintCall
|
|
1771
1915
|
| DropCheckConstraintCall
|
|
1772
1916
|
| CreateIndexCall
|
|
1917
|
+
| RenameIndexCall
|
|
1773
1918
|
| DropIndexCall
|
|
1774
1919
|
| DropConstraintCall
|
|
1775
1920
|
| RawSqlCall
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';
|
|
2
2
|
import { REFERENTIAL_ACTION_SQL } from '@prisma-next/sql-contract/referential-action-sql';
|
|
3
|
+
import { InternalError } from '@prisma-next/utils/internal-error';
|
|
3
4
|
import { constraintExistsAst } from '../../../contract-free/checks';
|
|
4
5
|
import { escapeLiteral, quoteIdentifier } from '../../sql-utils';
|
|
5
6
|
import { qualifyTableName } from '../planner-sql-checks';
|
|
@@ -29,14 +30,14 @@ REFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.
|
|
|
29
30
|
if (fk.onDelete !== undefined) {
|
|
30
31
|
const action = REFERENTIAL_ACTION_SQL[fk.onDelete];
|
|
31
32
|
if (!action) {
|
|
32
|
-
throw new
|
|
33
|
+
throw new InternalError(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);
|
|
33
34
|
}
|
|
34
35
|
sql += `\nON DELETE ${action}`;
|
|
35
36
|
}
|
|
36
37
|
if (fk.onUpdate !== undefined) {
|
|
37
38
|
const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];
|
|
38
39
|
if (!action) {
|
|
39
|
-
throw new
|
|
40
|
+
throw new InternalError(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);
|
|
40
41
|
}
|
|
41
42
|
sql += `\nON UPDATE ${action}`;
|
|
42
43
|
}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* supplies the control adapter from the migration's injected stack:
|
|
6
6
|
*
|
|
7
7
|
* ```ts
|
|
8
|
-
* import endContract from '
|
|
8
|
+
* import endContract from '../../snapshots/93f07d1b…c9e1e5a2/contract.json' with { type: 'json' };
|
|
9
9
|
*
|
|
10
10
|
* class M extends Migration {
|
|
11
11
|
* override get operations() {
|