@prisma-next/target-postgres 0.15.0-dev.13 → 0.15.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{control-policy-DaLdbcYE.mjs → control-policy-1Tcf7Tyu.mjs} +72 -41
- package/dist/control-policy-1Tcf7Tyu.mjs.map +1 -0
- package/dist/control.mjs +3 -3
- package/dist/{diff-database-schema-oY3brcLj.mjs → diff-database-schema-Bfgshz4v.mjs} +22 -85
- package/dist/diff-database-schema-Bfgshz4v.mjs.map +1 -0
- package/dist/diff-database-schema.d.mts +12 -3
- package/dist/diff-database-schema.d.mts.map +1 -1
- package/dist/diff-database-schema.mjs +1 -1
- package/dist/issue-planner.d.mts +1 -1
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +2 -2
- package/dist/migration.mjs +2 -2
- package/dist/{op-factory-call-CvH0JeBW.d.mts → op-factory-call-Bn9zDx4_.d.mts} +4 -7
- package/dist/op-factory-call-Bn9zDx4_.d.mts.map +1 -0
- package/dist/{op-factory-call-tBcLo_B8.mjs → op-factory-call-C38NzvQD.mjs} +12 -33
- package/dist/op-factory-call-C38NzvQD.mjs.map +1 -0
- package/dist/op-factory-call.d.mts +2 -2
- package/dist/op-factory-call.mjs +2 -2
- package/dist/{planner-ootbxGty.mjs → planner-BvUu6b9C.mjs} +11 -11
- package/dist/planner-BvUu6b9C.mjs.map +1 -0
- package/dist/{planner-produced-postgres-migration-k33bb9Sm.d.mts → planner-produced-postgres-migration-BEY1T0Xm.d.mts} +2 -2
- package/dist/{planner-produced-postgres-migration-k33bb9Sm.d.mts.map → planner-produced-postgres-migration-BEY1T0Xm.d.mts.map} +1 -1
- package/dist/{planner-produced-postgres-migration-DVsaobdV.mjs → planner-produced-postgres-migration-D7y-PEHK.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-DVsaobdV.mjs.map → planner-produced-postgres-migration-D7y-PEHK.mjs.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.d.mts +2 -2
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +2 -2
- package/dist/{postgres-database-schema-node-DJOTywwQ.d.mts → postgres-database-schema-node-CJv5bfbs.d.mts} +2 -11
- package/dist/postgres-database-schema-node-CJv5bfbs.d.mts.map +1 -0
- package/dist/{postgres-migration-ulfqRGA1.d.mts → postgres-migration-DbckK1su.d.mts} +2 -27
- package/dist/postgres-migration-DbckK1su.d.mts.map +1 -0
- package/dist/{postgres-migration-Bt3sXoID.mjs → postgres-migration-arMSWU9b.mjs} +2 -18
- package/dist/postgres-migration-arMSWU9b.mjs.map +1 -0
- package/dist/{postgres-role-schema-node-bg32e7I-.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs} +2 -3
- package/dist/postgres-role-schema-node-Cm-j0ZGM.mjs.map +1 -0
- package/dist/types.d.mts +2 -3
- package/dist/types.mjs +3 -3
- package/package.json +20 -20
- package/src/core/migrations/contract-to-postgres-database-schema-node.ts +19 -99
- package/src/core/migrations/control-policy.ts +3 -4
- package/src/core/migrations/diff-database-schema.ts +3 -3
- package/src/core/migrations/issue-planner.ts +80 -41
- package/src/core/migrations/op-factory-call.ts +14 -38
- package/src/core/migrations/planner-strategies.ts +4 -5
- package/src/core/migrations/planner.ts +4 -5
- package/src/core/migrations/postgres-migration.ts +0 -60
- package/src/core/migrations/verify-postgres-namespaces.ts +1 -0
- package/src/core/schema-ir/postgres-policy-schema-node.ts +2 -12
- package/src/exports/op-factory-call.ts +0 -5
- package/src/exports/types.ts +0 -1
- package/dist/control-policy-DaLdbcYE.mjs.map +0 -1
- package/dist/diff-database-schema-oY3brcLj.mjs.map +0 -1
- package/dist/op-factory-call-CvH0JeBW.d.mts.map +0 -1
- package/dist/op-factory-call-tBcLo_B8.mjs.map +0 -1
- package/dist/planner-ootbxGty.mjs.map +0 -1
- package/dist/postgres-database-schema-node-DJOTywwQ.d.mts.map +0 -1
- package/dist/postgres-migration-Bt3sXoID.mjs.map +0 -1
- package/dist/postgres-migration-ulfqRGA1.d.mts.map +0 -1
- package/dist/postgres-role-schema-node-bg32e7I-.mjs.map +0 -1
- package/dist/schema-node-kinds-CrYzCR1i.d.mts +0 -30
- package/dist/schema-node-kinds-CrYzCR1i.d.mts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-D7y-PEHK.mjs","names":["#calls","#meta","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `PN-MIG-2001` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache:\n | readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[]\n | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, { from: this.#meta.from, to: this.#meta.to });\n }\n}\n"],"mappings":";;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CACA;CACA;CAOA,YACE,OACA,MACA,SACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,WAAW;CAClB;CAEA,IAAa,aAGT;EACF,KAAKC,qBAAqB,UAAU,KAAKJ,QAAQ,KAAKG,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKH;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAAE,MAAM,KAAKC,MAAM;GAAM,IAAI,KAAKA,MAAM;EAAG,CAAC;CAC1F;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BEY1T0Xm.mjs";
|
|
2
2
|
export { TypeScriptRenderablePostgresMigration };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-D7y-PEHK.mjs";
|
|
2
2
|
export { TypeScriptRenderablePostgresMigration };
|
package/dist/planner.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-
|
|
1
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-CJv5bfbs.mjs";
|
|
2
2
|
import { t as PostgresContract } from "./postgres-schema-DKq6s1P3.mjs";
|
|
3
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
3
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-BEY1T0Xm.mjs";
|
|
4
4
|
import { ContractToSchemaIROptions, MigrationOperationPolicy, SqlPlannerConflict, SqlPlannerFailureResult } from "@prisma-next/family-sql/control";
|
|
5
5
|
import { MigrationPlanWithAuthoringSurface, MigrationPlanner, MigrationScaffoldContext, SchemaOwnership } from "@prisma-next/framework-components/control";
|
|
6
6
|
import { Contract } from "@prisma-next/contract/types";
|
package/dist/planner.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/planner.ts"],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"planner.d.mts","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/planner.ts"],"mappings":";;;;;;;;;;;;;;;;;AAkDA;;;;;;;;;;;;;iBAAgB,oCAAA,CACd,QAAA,EAAU,gBAAA,SACV,OAAA,EAAS,yBAAA,GACR,0BAAA;;;iBCWa,8BAAA,CACd,OAAA,EAAS,qBAAA,GACR,wBAAwB;;;;ADhB3B;;;;KC2BY,kBAAA;EAAA,SAEG,IAAA;EAAA,SACA,IAAA,EAAM,qCAAA;EAAA,SACN,QAAA,YAAoB,kBAAA;AAAA,IAE/B,uBAAA;;;;;;AD9ByB;;;;ACW7B;;;;;;;;AAE2B;cAqCd,wBAAA,YAAoC,gBAAA;EAAA;cAGnC,OAAA,GAAU,qBAAA;EAItB,IAAA,CAAK,OAAA;IAAA,SACM,QAAA;IAAA,SACA,MAAA;IAAA,SACA,MAAA,EAAQ,wBAAA;IA9BM;;;;;;;;AAAA;AAoB3B;;;;;IApB2B,SA6Cd,YAAA,EAAc,QAAA;IAAA,SACd,UAAA;IAAA,SACA,mBAAA,EAAqB,aAAA,CAAc,8BAAA;IAWvB;;;;;IAAA,SALZ,OAAA;IAjCoD;;;;IAAA,SAsCpD,SAAA,GAAY,eAAA;EAAA,IACnB,kBAAA;EAIJ,cAAA,CACE,OAAA,EAAS,wBAAA,EACT,OAAA,WACC,iCAAA;EAAA,QAYK,OAAA;EAjDG;;;;;;;;;;;;;;;;;;;;;;;EAAA,QAiPH,sBAAA;EAAA,QAiHA,oBAAA;AAAA"}
|
package/dist/planner.mjs
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-
|
|
2
|
-
import { t as createPostgresMigrationPlanner } from "./planner-
|
|
1
|
+
import { r as contractToPostgresDatabaseSchemaNode } from "./diff-database-schema-Bfgshz4v.mjs";
|
|
2
|
+
import { t as createPostgresMigrationPlanner } from "./planner-BvUu6b9C.mjs";
|
|
3
3
|
export { contractToPostgresDatabaseSchemaNode, createPostgresMigrationPlanner };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { r as RlsPolicyOperation } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
2
2
|
import { PrimaryKey, SqlAnnotations, SqlCheckConstraintIR, SqlColumnIR, SqlForeignKeyIR, SqlIndexIR, SqlSchemaIRNode, SqlTableIRInput, SqlUniqueIR } from "@prisma-next/sql-schema-ir/types";
|
|
3
|
-
import { DiffableNode
|
|
3
|
+
import { DiffableNode } from "@prisma-next/framework-components/control";
|
|
4
4
|
import { ControlPolicy } from "@prisma-next/contract/types";
|
|
5
5
|
|
|
6
6
|
//#region src/core/schema-ir/postgres-native-enum-schema-node.d.ts
|
|
@@ -66,13 +66,6 @@ interface PostgresPolicySchemaNodeInput {
|
|
|
66
66
|
readonly withCheck?: string;
|
|
67
67
|
/** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */
|
|
68
68
|
readonly permissive: boolean;
|
|
69
|
-
/**
|
|
70
|
-
* This policy's table node, plus one entry per role it grants to — each
|
|
71
|
-
* as the root-anchored chain the differ pairs siblings with. Stamped by
|
|
72
|
-
* the derivation, which holds the parent (database/namespace) context.
|
|
73
|
-
* Never compared by `isEqualTo`.
|
|
74
|
-
*/
|
|
75
|
-
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
76
69
|
}
|
|
77
70
|
/**
|
|
78
71
|
* Schema-diff leaf node for a Postgres row-level security policy.
|
|
@@ -96,8 +89,6 @@ declare class PostgresPolicySchemaNode extends SqlSchemaIRNode implements Diffab
|
|
|
96
89
|
readonly using?: string;
|
|
97
90
|
readonly withCheck?: string;
|
|
98
91
|
readonly permissive: boolean;
|
|
99
|
-
/** See {@link PostgresPolicySchemaNodeInput.dependsOn}. Non-enumerable so it stays out of JSON and structural equality, matching `SqlColumnIR.codecRef`. */
|
|
100
|
-
readonly dependsOn?: readonly SchemaNodeRef[];
|
|
101
92
|
constructor(input: PostgresPolicySchemaNodeInput);
|
|
102
93
|
get id(): string;
|
|
103
94
|
children(): readonly DiffableNode[];
|
|
@@ -268,4 +259,4 @@ declare class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements Diff
|
|
|
268
259
|
}
|
|
269
260
|
//#endregion
|
|
270
261
|
export { PostgresNamespaceSchemaNode as a, PostgresTableSchemaNodeInput as c, PostgresNativeEnumSchemaNode as d, PostgresNativeEnumSchemaNodeInput as f, PostgresRoleSchemaNodeInput as i, PostgresPolicySchemaNode as l, PostgresDatabaseSchemaNodeInput as n, PostgresNamespaceSchemaNodeInput as o, PostgresRoleSchemaNode as r, PostgresTableSchemaNode as s, PostgresDatabaseSchemaNode as t, PostgresPolicySchemaNodeInput as u };
|
|
271
|
-
//# sourceMappingURL=postgres-database-schema-node-
|
|
262
|
+
//# sourceMappingURL=postgres-database-schema-node-CJv5bfbs.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-database-schema-node-CJv5bfbs.d.mts","names":[],"sources":["../src/core/schema-ir/postgres-native-enum-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-table-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts","../src/core/schema-ir/postgres-database-schema-node.ts"],"mappings":";;;;;;UAOiB,iCAAA;;WAEN,QAAA;EAFM;EAAA,SAIN,WAAA;;WAEA,OAAA;EAJA;EAAA,SAMA,OAAA,GAAU,aAAa;AAAA;;;;AAAA;AAsBlC;;;;;;;;;;;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AA,WAA0B,IAAA,IAAQ,2BAAA;AAAA;;;UC5DvC,2BAAA;EAAA,SACN,IAAA;;;AJAX;;WIKW,WAAW;AAAA;;;;;;;AJGY;AAsBlC;;;;;cIVa,sBAAA,SAA+B,eAAA,YAA2B,YAAA;EAAA,SACnD,QAAA;EAAA,SAET,IAAA;EAAA,SACA,WAAA;cAEG,KAAA,EAAO,2BAAA;EAAA,IAOf,EAAA;EAIJ,QAAA,aAAqB,YAAA;EAIrB,SAAA,CAAU,KAAA,EAAO,YAAA;EAAA,OASV,EAAA,CAAG,IAAA,EAAM,eAAA,GAAkB,IAAA,IAAQ,sBAAA;EAAA,OAInC,MAAA,CAAO,IAAA,EAAM,eAAA,WAA0B,IAAA,IAAQ,sBAAA;AAAA;;;UCtDvC,+BAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,2BAAA;EAAA,SACpC,KAAA,WAAgB,sBAAA;EAAA,SAChB,eAAA;EAAA,SACA,SAAA;AAAA;;;;;;;ALIuB;AAsBlC;;;cKba,0BAAA,SAAmC,eAAA,YAA2B,YAAA;EAAA,SACvD,QAAA;EAAA,SAET,UAAA,EAAY,QAAA,CAAS,MAAA,SAAe,2BAAA;EAAA,SACpC,KAAA,WAAgB,sBAAA;EAAA,SAChB,eAAA;EAAA,SACA,SAAA;cAEG,KAAA,EAAO,+BAAA;EAAA,IASf,EAAA;EAIJ,SAAA,CAAU,KAAA,EAAO,YAAA;EAIjB,QAAA,aAAqB,YAAA;EAAA,OAId,EAAA,CAAG,IAAA,EAAM,eAAA,GAAkB,IAAA,IAAQ,0BAAA;EAAA,OAInC,MAAA,CAAO,IAAA,EAAM,eAAA,WAA0B,IAAA,IAAQ,0BAAA;AAAA"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO.mjs";
|
|
2
2
|
import { n as DataTransformOptions } from "./data-transform-DPzwBMhW.mjs";
|
|
3
|
-
import {
|
|
4
|
-
import { N as ForeignKeySpec, l as AlterColumnTypeOptions } from "./op-factory-call-CvH0JeBW.mjs";
|
|
3
|
+
import { O as ForeignKeySpec, l as AlterColumnTypeOptions } from "./op-factory-call-Bn9zDx4_.mjs";
|
|
5
4
|
import { t as PostgresContractView } from "./postgres-contract-view-C9j5cqP0.mjs";
|
|
6
5
|
import { DdlColumn, DdlTableConstraint } from "@prisma-next/sql-relational-core/ast";
|
|
7
6
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
@@ -225,31 +224,7 @@ declare abstract class PostgresMigration<Start extends Contract<SqlStorage> = Co
|
|
|
225
224
|
readonly id: string;
|
|
226
225
|
readonly label?: string;
|
|
227
226
|
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
228
|
-
protected enableRowLevelSecurity(options: {
|
|
229
|
-
readonly schema: string;
|
|
230
|
-
readonly table: string;
|
|
231
|
-
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
232
|
-
protected disableRowLevelSecurity(options: {
|
|
233
|
-
readonly schema: string;
|
|
234
|
-
readonly table: string;
|
|
235
|
-
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
236
|
-
protected createRlsPolicy(options: {
|
|
237
|
-
readonly schema: string;
|
|
238
|
-
readonly table: string;
|
|
239
|
-
readonly policy: PostgresRlsPolicyInput;
|
|
240
|
-
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
241
|
-
protected dropRlsPolicy(options: {
|
|
242
|
-
readonly schema: string;
|
|
243
|
-
readonly table: string;
|
|
244
|
-
readonly policy: string;
|
|
245
|
-
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
246
|
-
protected renameRlsPolicy(options: {
|
|
247
|
-
readonly schema: string;
|
|
248
|
-
readonly table: string;
|
|
249
|
-
readonly from: string;
|
|
250
|
-
readonly to: string;
|
|
251
|
-
}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>;
|
|
252
227
|
}
|
|
253
228
|
//#endregion
|
|
254
229
|
export { PostgresMigration as t };
|
|
255
|
-
//# sourceMappingURL=postgres-migration-
|
|
230
|
+
//# sourceMappingURL=postgres-migration-DbckK1su.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-DbckK1su.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAmBiB,iBAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA,GAAU,MAAM;AAAA;;;AAF3B;;;;;;;;AAE2B;;;;AC8C3B;;;;;;;;;;;;;;;ADhDA,uBCgDsB,iBAAA,eACN,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,eAClC,QAAA,CAAS,UAAA,IAAc,QAAA,CAAS,UAAA,WACpC,SAAA,CAAa,yBAAA,cAAuC,KAAA,EAAO,GAAA;EAAA;WAC1D,QAAA;EAwDiC;;;;;;EAAA,mBAhDvB,cAAA,EAAgB,iBAAA;cAavB,KAAA,GAAQ,YAAA;EAgDjB;;;;;EAAA,QAjCK,iBAAA;EAiE8B;;;;;EAAA,IArDlC,WAAA,IAAe,oBAAA,CAAqB,GAAA;EAgFF;;;;EAAA,IAxElC,aAAA,IAAiB,oBAAA,CAAqB,KAAA;EAwFtC;;;;;EAAA,UA/EM,aAAA,mBAAgC,QAAA,CAAS,UAAA,GACjD,QAAA,EAAU,SAAA,EACV,IAAA,UACA,OAAA,EAAS,oBAAA,GACR,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAgGzB;;;;;EAAA,UAvFF,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,WAAA;IAAA,SACA,OAAA,WAAkB,SAAA;IAAA,SAClB,WAAA,YAAuB,kBAAA;EAAA,IAC9B,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAsIA;;;;;EAAA,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AA0B,yBAAA;EAAA,UAM5B,WAAA,CAAY,OAAA;IAAA,SACX,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;IAAA,SACA,MAAA,GAAS,iBAAA;EAAA,IAChB,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAU5B,SAAA,CAAU,OAAA;IAAA,SACT,MAAA;IAAA,SACA,KAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;EAAA,UAM5B,gBAAA,CAAiB,OAAA;IAAA,SAChB,aAAA;IAAA,SACA,WAAA;IAAA,SACA,EAAA;IAAA,SACA,KAAA;EAAA,IACP,OAAA,CAAQ,yBAAA,CAA0B,yBAAA;AAAA"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { A as SetDefaultCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as installExtension, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetNotNullCall, k as RenamePostgresRlsPolicyCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-tBcLo_B8.mjs";
|
|
1
|
+
import { A as SetDefaultCall, C as DropNativeEnumTypeCall, E as DropTableCall, F as installExtension, S as DropIndexCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetNotNullCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-C38NzvQD.mjs";
|
|
3
2
|
import { t as errorPostgresMigrationStackMissing } from "./errors-DO-w0EUS.mjs";
|
|
4
3
|
import { t as PostgresContractView } from "./postgres-contract-view-DM8sN1Ot.mjs";
|
|
5
4
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
@@ -172,23 +171,8 @@ var PostgresMigration = class extends Migration {
|
|
|
172
171
|
installExtension(options) {
|
|
173
172
|
return installExtension(options, this.controlAdapterFor("installExtension"));
|
|
174
173
|
}
|
|
175
|
-
enableRowLevelSecurity(options) {
|
|
176
|
-
return new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("enableRowLevelSecurity"));
|
|
177
|
-
}
|
|
178
|
-
disableRowLevelSecurity(options) {
|
|
179
|
-
return new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor("disableRowLevelSecurity"));
|
|
180
|
-
}
|
|
181
|
-
createRlsPolicy(options) {
|
|
182
|
-
return new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy(options.policy)).toOp(this.controlAdapterFor("createRlsPolicy"));
|
|
183
|
-
}
|
|
184
|
-
dropRlsPolicy(options) {
|
|
185
|
-
return new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor("dropRlsPolicy"));
|
|
186
|
-
}
|
|
187
|
-
renameRlsPolicy(options) {
|
|
188
|
-
return new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor("renameRlsPolicy"));
|
|
189
|
-
}
|
|
190
174
|
};
|
|
191
175
|
//#endregion
|
|
192
176
|
export { PostgresMigration as t };
|
|
193
177
|
|
|
194
|
-
//# sourceMappingURL=postgres-migration-
|
|
178
|
+
//# sourceMappingURL=postgres-migration-arMSWU9b.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-migration-arMSWU9b.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { PostgresContractView } from '../postgres-contract-view';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddNativeEnumValueCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateNativeEnumTypeCall,\n CreateSchemaCall,\n CreateTableCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNativeEnumTypeCall,\n DropNotNullCall,\n DropTableCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\n/**\n * Target-owned base class for Postgres migrations.\n *\n * Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n * abstract `targetId` to the Postgres target-id string literal, so both\n * user-authored migrations and renderer-generated scaffolds (the output of\n * `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n * redeclaring target-local identity.\n *\n * Mirrors `MongoMigration` in `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/postgres/migration`, keeping the authoring surface\n * target-scoped rather than family-scoped.\n *\n * The constructor materializes a single Postgres `SqlControlAdapter` from\n * `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n * instance method forwards to the free `dataTransform` factory with that\n * stored adapter, so user migrations can write `this.dataTransform(...)`\n * without threading the adapter through every call.\n *\n * Every method requires an explicit `schema`. Postgres migrations name their\n * schema deliberately — there is no default and no `search_path`-relative\n * option. A migration that left the schema unspecified would resolve against\n * whatever `search_path` the connection happened to carry, and that ambiguity\n * is an antipattern in a migration. (The unbound/unspecified namespace concept\n * remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n */\nexport abstract class PostgresMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a PN-MIG-2007 in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a PN-MIG-2007 naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'postgres'> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return dataTransform(contract, name, options, this.controlAdapterFor('dataTransform'));\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapterFor('createTable'));\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor('createSchema'));\n }\n\n /**\n * Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n * native enum. Builds a typed DDL node and lowers it through the stored\n * control adapter (members render in declaration order). Throws if no adapter\n * is present.\n */\n protected createNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly members: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(\n this.controlAdapterFor('createNativeEnumType'),\n );\n }\n\n /**\n * Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n * through the stored control adapter. Throws if no adapter is present.\n */\n protected dropNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(\n this.controlAdapterFor('dropNativeEnumType'),\n );\n }\n\n /**\n * Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n * member to a managed native enum, lowered through the stored control\n * adapter. Throws if no adapter is present. Every appended value is its\n * own operation — call this once per value to append more than one.\n */\n protected addNativeEnumValue(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly value: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(\n this.controlAdapterFor('addNativeEnumValue'),\n );\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addPrimaryKey'));\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addUnique'));\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapterFor('addForeignKey'),\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapterFor('addCheckConstraint'));\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapterFor('dropCheckConstraint'),\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapterFor('dropConstraint'));\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropTableCall(options.schema, options.table).toOp(\n this.controlAdapterFor('dropTable'),\n );\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapterFor('alterColumnType'));\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('setNotNull'),\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropNotNull'),\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapterFor('setDefault'));\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropDefault'),\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapterFor('createIndex'));\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return installExtension(options, this.controlAdapterFor('installExtension'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAmEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,kBAA0B,WAAkD;EAC1E,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC,SAAS;EAEpD,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,cAAyC;EAC3C,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAoD;EACtD,OAAO,KAAKC,WAAW;CACzB;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,kBAAkB,eAAe,CAAC;CACvF;;;;;;CAOA,YAAsB,SAM4C;EAChE,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,SACR,QAAQ,WACV,CAAC,CAAC,KAAK,KAAK,kBAAkB,aAA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AAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KACxE,KAAK,kBAAkB,aAAa,CACtC;CACF;CAEA,YAAsB,SAM4C;EAChE,OAAO,IAAI,gBACT,QAAQ,QACR,QAAQ,OACR,QAAQ,OACR,QAAQ,SACR,QAAQ,MACV,CAAC,CAAC,KAAK,KAAK,kBAAkB,aAAa,CAAC;CAC9C;CAEA,UAAoB,SAI8C;EAChE,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KACrE,KAAK,kBAAkB,WAAW,CACpC;CACF;CAEA,iBAA2B,SAKuC;EAChE,OAAO,iBAAiB,SAAS,KAAK,kBAAkB,kBAAkB,CAAC;CAC7E;AACF"}
|
package/dist/{postgres-role-schema-node-bg32e7I-.mjs → postgres-role-schema-node-Cm-j0ZGM.mjs}
RENAMED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { r as PostgresSchemaNodeKind } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
2
2
|
import { freezeNode } from "@prisma-next/framework-components/ir";
|
|
3
3
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
4
|
-
import { SqlSchemaIRNode, assertNode
|
|
4
|
+
import { SqlSchemaIRNode, assertNode } from "@prisma-next/sql-schema-ir/types";
|
|
5
5
|
//#region src/core/schema-ir/postgres-database-schema-node.ts
|
|
6
6
|
/**
|
|
7
7
|
* The root of the Postgres schema-diff tree: one node per database.
|
|
@@ -122,7 +122,6 @@ var PostgresPolicySchemaNode = class PostgresPolicySchemaNode extends SqlSchemaI
|
|
|
122
122
|
if (input.using !== void 0) this.using = input.using;
|
|
123
123
|
if (input.withCheck !== void 0) this.withCheck = input.withCheck;
|
|
124
124
|
this.permissive = input.permissive;
|
|
125
|
-
defineNonEnumerable(this, "dependsOn", input.dependsOn);
|
|
126
125
|
freezeNode(this);
|
|
127
126
|
}
|
|
128
127
|
get id() {
|
|
@@ -188,4 +187,4 @@ var PostgresRoleSchemaNode = class PostgresRoleSchemaNode extends SqlSchemaIRNod
|
|
|
188
187
|
//#endregion
|
|
189
188
|
export { PostgresDatabaseSchemaNode as i, PostgresPolicySchemaNode as n, PostgresNamespaceSchemaNode as r, PostgresRoleSchemaNode as t };
|
|
190
189
|
|
|
191
|
-
//# sourceMappingURL=postgres-role-schema-node-
|
|
190
|
+
//# sourceMappingURL=postgres-role-schema-node-Cm-j0ZGM.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"postgres-role-schema-node-Cm-j0ZGM.mjs","names":[],"sources":["../src/core/schema-ir/postgres-database-schema-node.ts","../src/core/schema-ir/postgres-namespace-schema-node.ts","../src/core/schema-ir/postgres-policy-schema-node.ts","../src/core/schema-ir/postgres-role-schema-node.ts"],"sourcesContent":["import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNamespaceSchemaNode } from './postgres-namespace-schema-node';\nimport type { PostgresRoleSchemaNode } from './postgres-role-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresDatabaseSchemaNodeInput {\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n}\n\n/**\n * The root of the Postgres schema-diff tree: one node per database.\n *\n * `id` is the fixed sentinel `'database'` — the root has no siblings and\n * the value is never emitted into migration paths. `isEqualTo` is identity\n * (roots always share the `'database'` id). `children()` yields the namespace\n * nodes followed by the role nodes — both are root-level diff subjects. The\n * differ pairs siblings by `(nodeKind, id)`, so a role and a namespace may\n * share a name without colliding.\n */\nexport class PostgresDatabaseSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.database;\n\n readonly namespaces: Readonly<Record<string, PostgresNamespaceSchemaNode>>;\n readonly roles: readonly PostgresRoleSchemaNode[];\n readonly existingSchemas: readonly string[];\n readonly pgVersion: string;\n\n constructor(input: PostgresDatabaseSchemaNodeInput) {\n super();\n this.namespaces = Object.freeze({ ...input.namespaces });\n this.roles = Object.freeze([...input.roles]);\n this.existingSchemas = Object.freeze([...input.existingSchemas]);\n this.pgVersion = input.pgVersion;\n freezeNode(this);\n }\n\n get id(): string {\n return 'database';\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.namespaces), ...this.roles];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresDatabaseSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.database;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresDatabaseSchemaNode {\n assertNode(node, 'PostgresDatabaseSchemaNode', PostgresDatabaseSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport type { PostgresNativeEnumSchemaNode } from './postgres-native-enum-schema-node';\nimport type { PostgresTableSchemaNode } from './postgres-table-schema-node';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresNamespaceSchemaNodeInput {\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n /**\n * The native-enum diff nodes belonging to this namespace, member values in\n * `pg_enum.enumsortorder` (declaration) order. The expected\n * (contract-projected) side attaches each node's `control` (the contract\n * entity's grade); introspection builds nodes with no `control`.\n */\n readonly nativeEnums?: readonly PostgresNativeEnumSchemaNode[];\n}\n\n/**\n * One-per-Postgres-schema diff-tree node. Groups the tables belonging to a\n * single namespace. Per-schema consumers (the relational planner,\n * toSchemaView) read this node's `tables` field structurally via\n * `blindCast`/`SqlSchemaIRNode` — not through a static `SqlSchemaIR`\n * assignment — because `nodeKind` carries this node's own literal\n * (`postgres-namespace`), distinct from `SqlSchemaIR`'s own (`sql-schema`).\n *\n * `id` is the schema name; `isEqualTo` is identity on it; `children()` returns\n * the table nodes plus `nativeEnums`.\n *\n * `nativeEnums` is the diff-tree representation of native enum types the\n * differ pairs — the sole enum carrier, built directly by both sides: the\n * expected (contract-projected) side and introspection alike hand in\n * `PostgresNativeEnumSchemaNode`s.\n */\nexport class PostgresNamespaceSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.namespace;\n\n readonly schemaName: string;\n readonly tables: Readonly<Record<string, PostgresTableSchemaNode>>;\n readonly nativeEnums: readonly PostgresNativeEnumSchemaNode[];\n\n constructor(input: PostgresNamespaceSchemaNodeInput) {\n super();\n this.schemaName = input.schemaName;\n this.tables = Object.freeze({ ...input.tables });\n this.nativeEnums = Object.freeze([...(input.nativeEnums ?? [])]);\n freezeNode(this);\n }\n\n get id(): string {\n return this.schemaName;\n }\n\n isEqualTo(other: DiffableNode): boolean {\n return this.id === other.id;\n }\n\n children(): readonly DiffableNode[] {\n return [...Object.values(this.tables), ...this.nativeEnums];\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresNamespaceSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.namespace;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresNamespaceSchemaNode {\n assertNode(node, 'PostgresNamespaceSchemaNode', PostgresNamespaceSchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport type { RlsPolicyOperation } from '../postgres-rls-policy';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresPolicySchemaNodeInput {\n /** Full wire name: `<prefix>_<8hex>`. */\n readonly name: string;\n /** User-supplied prefix (the part before the `_<8hex>` suffix). */\n readonly prefix: string;\n /** Name of the table this policy attaches to, by name within the same schema. */\n readonly tableName: string;\n /** Namespace coordinate (schema name). */\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n /** Sorted role names rendered in `TO <roles>`. */\n readonly roles: readonly string[];\n /** USING predicate SQL string, if present. */\n readonly using?: string;\n /** WITH CHECK predicate SQL string, if present. */\n readonly withCheck?: string;\n /** `true` = `AS PERMISSIVE`, `false` = `AS RESTRICTIVE`. */\n readonly permissive: boolean;\n}\n\n/**\n * Schema-diff leaf node for a Postgres row-level security policy.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRlsPolicy` contract entities / introspected rows.\n *\n * `id` is the wire name (`<prefix>_<sha256(body)[0..8]>`), so name-equality is\n * body-equality. `isEqualTo` compares names only — never byte-compare predicate\n * bodies, because Postgres reprints them.\n */\nexport class PostgresPolicySchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.policy;\n\n readonly name: string;\n readonly prefix: string;\n readonly tableName: string;\n readonly namespaceId: string;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n declare readonly using?: string;\n declare readonly withCheck?: string;\n readonly permissive: boolean;\n\n constructor(input: PostgresPolicySchemaNodeInput) {\n super();\n this.name = input.name;\n this.prefix = input.prefix;\n this.tableName = input.tableName;\n this.namespaceId = input.namespaceId;\n this.operation = input.operation;\n this.roles = Object.freeze([...input.roles]);\n if (input.using !== undefined) this.using = input.using;\n if (input.withCheck !== undefined) this.withCheck = input.withCheck;\n this.permissive = input.permissive;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-policy kinds'\n >(other);\n PostgresPolicySchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresPolicySchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.policy;\n }\n\n static assert(node: SqlSchemaIRNode | undefined): asserts node is PostgresPolicySchemaNode {\n assertNode(node, 'PostgresPolicySchemaNode', PostgresPolicySchemaNode.is);\n }\n}\n","import type { DiffableNode } from '@prisma-next/framework-components/control';\nimport { freezeNode } from '@prisma-next/framework-components/ir';\nimport { assertNode, SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { PostgresSchemaNodeKind } from './schema-node-kinds';\n\nexport interface PostgresRoleSchemaNodeInput {\n readonly name: string;\n /**\n * Namespace coordinate. Roles are cluster-scoped; callers pass\n * `UNBOUND_NAMESPACE_ID` from `@prisma-next/framework-components/ir`.\n */\n readonly namespaceId: string;\n}\n\n/**\n * Schema-diff leaf node for a Postgres database role.\n *\n * This is a derived, transient node walked by the differ — it is NEVER serialized.\n * Built by project-from-contract and project-from-database from their respective\n * `PostgresRole` contract entities / introspected rows.\n *\n * Roles are cluster-scoped, so `id` is the bare role name. The differ pairs\n * siblings by `(nodeKind, id)`, so a role and a namespace may share a name\n * (role `public`, schema `public`) without colliding. `isEqualTo` compares\n * ids — name-equality is role-equality for cluster-scoped objects.\n */\nexport class PostgresRoleSchemaNode extends SqlSchemaIRNode implements DiffableNode {\n override readonly nodeKind = PostgresSchemaNodeKind.role;\n\n readonly name: string;\n readonly namespaceId: string;\n\n constructor(input: PostgresRoleSchemaNodeInput) {\n super();\n this.name = input.name;\n this.namespaceId = input.namespaceId;\n freezeNode(this);\n }\n\n get id(): string {\n return this.name;\n }\n\n children(): readonly DiffableNode[] {\n return [];\n }\n\n isEqualTo(other: DiffableNode): boolean {\n const node = blindCast<\n SqlSchemaIRNode,\n 'every diff-tree node the differ pairs is a SqlSchemaIRNode; the guard rejects non-role kinds'\n >(other);\n PostgresRoleSchemaNode.assert(node);\n return this.id === node.id;\n }\n\n static is(node: SqlSchemaIRNode): node is PostgresRoleSchemaNode {\n return node.nodeKind === PostgresSchemaNodeKind.role;\n }\n\n static assert(node: SqlSchemaIRNode): asserts node is PostgresRoleSchemaNode {\n assertNode(node, 'PostgresRoleSchemaNode', PostgresRoleSchemaNode.is);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;AAwBA,IAAa,6BAAb,MAAa,mCAAmC,gBAAwC;CACtF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CACA;CAEA,YAAY,OAAwC;EAClD,MAAM;EACN,KAAK,aAAa,OAAO,OAAO,EAAE,GAAG,MAAM,WAAW,CAAC;EACvD,KAAK,QAAQ,OAAO,OAAO,CAAC,GAAG,MAAM,KAAK,CAAC;EAC3C,KAAK,kBAAkB,OAAO,OAAO,CAAC,GAAG,MAAM,eAAe,CAAC;EAC/D,KAAK,YAAY,MAAM;EACvB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO;CACT;CAEA,UAAU,OAA8B;EACtC,OAAO,KAAK,OAAO,MAAM;CAC3B;CAEA,WAAoC;EAClC,OAAO,CAAC,GAAG,OAAO,OAAO,KAAK,UAAU,GAAG,GAAG,KAAK,KAAK;CAC1D;CAEA,OAAO,GAAG,MAA2D;EACnE,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAAmE;EAC/E,WAAW,MAAM,8BAA8B,2BAA2B,EAAE;CAC9E;AACF;;;;;;;;;;;;;;;;;;;ACzBA,IAAa,8BAAb,MAAa,oCAAoC,gBAAwC;CACvF,WAA6B,uBAAuB;CAEpD;CACA;CACA;CAEA,YAAY,OAAyC;EACnD,MAAM;EACN,KAAK,aAAa,MAAM;EACxB,KAAK,SAAS,OAAO,OAAO,EAAE,GAAG,MAAM,OAAO,CAAC;EAC/C,KAAK,cAAc,OAAO,OAAO,CAAC,GAAI,MAAM,eAAe,CAAC,CAAE,CAAC;EAC/D,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,O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AAoC;EAC9C,MAAM;EACN,KAAK,OAAO,MAAM;EAClB,KAAK,cAAc,MAAM;EACzB,WAAW,IAAI;CACjB;CAEA,IAAI,KAAa;EACf,OAAO,KAAK;CACd;CAEA,WAAoC;EAClC,OAAO,CAAC;CACV;CAEA,UAAU,OAA8B;EACtC,MAAM,OAAO,UAGX,KAAK;EACP,uBAAuB,OAAO,IAAI;EAClC,OAAO,KAAK,OAAO,KAAK;CAC1B;CAEA,OAAO,GAAG,MAAuD;EAC/D,OAAO,KAAK,aAAa,uBAAuB;CAClD;CAEA,OAAO,OAAO,MAA+D;EAC3E,WAAW,MAAM,0BAA0B,uBAAuB,EAAE;CACtE;AACF"}
|
package/dist/types.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, d as PostgresNativeEnumSchemaNode, f as PostgresNativeEnumSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-
|
|
1
|
+
import { a as PostgresNamespaceSchemaNode, c as PostgresTableSchemaNodeInput, d as PostgresNativeEnumSchemaNode, f as PostgresNativeEnumSchemaNodeInput, i as PostgresRoleSchemaNodeInput, l as PostgresPolicySchemaNode, n as PostgresDatabaseSchemaNodeInput, o as PostgresNamespaceSchemaNodeInput, r as PostgresRoleSchemaNode, s as PostgresTableSchemaNode, t as PostgresDatabaseSchemaNode, u as PostgresPolicySchemaNodeInput } from "./postgres-database-schema-node-CJv5bfbs.mjs";
|
|
2
2
|
import { n as PostgresRlsPolicyInput, r as RlsPolicyOperation, t as PostgresRlsPolicy } from "./postgres-rls-policy--CSddvMR.mjs";
|
|
3
|
-
import { t as PostgresSchemaNodeKind } from "./schema-node-kinds-CrYzCR1i.mjs";
|
|
4
3
|
import { t as PostgresColumnDefault } from "./types-BDKkx8MA.mjs";
|
|
5
4
|
import { a as postgresCreateNamespace, c as PostgresRlsEnablement, d as PostgresNativeEnumInput, i as isPostgresSchema, l as PostgresRlsEnablementInput, n as PostgresSchema, o as PostgresRole, r as PostgresUnboundSchema, s as PostgresRoleInput, t as PostgresContract, u as PostgresNativeEnum } from "./postgres-schema-DKq6s1P3.mjs";
|
|
6
|
-
export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, PostgresNativeEnumSchemaNode, type PostgresNativeEnumSchemaNodeInput, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsEnablement, type PostgresRlsEnablementInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema,
|
|
5
|
+
export { type PostgresColumnDefault, type PostgresContract, PostgresDatabaseSchemaNode, type PostgresDatabaseSchemaNodeInput, PostgresNamespaceSchemaNode, type PostgresNamespaceSchemaNodeInput, PostgresNativeEnum, type PostgresNativeEnumInput, PostgresNativeEnumSchemaNode, type PostgresNativeEnumSchemaNodeInput, PostgresPolicySchemaNode, type PostgresPolicySchemaNodeInput, PostgresRlsEnablement, type PostgresRlsEnablementInput, PostgresRlsPolicy, type PostgresRlsPolicyInput, PostgresRole, type PostgresRoleInput, PostgresRoleSchemaNode, type PostgresRoleSchemaNodeInput, PostgresSchema, PostgresTableSchemaNode, type PostgresTableSchemaNodeInput, PostgresUnboundSchema, type RlsPolicyOperation, isPostgresSchema, postgresCreateNamespace };
|
package/dist/types.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as PostgresNativeEnum } from "./postgres-native-enum-BwVNf0Ku.mjs";
|
|
2
2
|
import { _ as PostgresRlsEnablement, g as PostgresRlsPolicy, i as postgresCreateNamespace, m as PostgresRole, n as PostgresUnboundSchema, r as isPostgresSchema, t as PostgresSchema } from "./postgres-schema-Cm4DtiGA.mjs";
|
|
3
|
-
import { n as PostgresNativeEnumSchemaNode,
|
|
4
|
-
import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-
|
|
5
|
-
export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema,
|
|
3
|
+
import { n as PostgresNativeEnumSchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
4
|
+
import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-Cm-j0ZGM.mjs";
|
|
5
|
+
export { PostgresDatabaseSchemaNode, PostgresNamespaceSchemaNode, PostgresNativeEnum, PostgresNativeEnumSchemaNode, PostgresPolicySchemaNode, PostgresRlsEnablement, PostgresRlsPolicy, PostgresRole, PostgresRoleSchemaNode, PostgresSchema, PostgresTableSchemaNode, PostgresUnboundSchema, isPostgresSchema, postgresCreateNamespace };
|
package/package.json
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prisma-next/target-postgres",
|
|
3
|
-
"version": "0.15.0-dev.
|
|
3
|
+
"version": "0.15.0-dev.2",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"description": "Postgres target pack for Prisma Next",
|
|
8
8
|
"dependencies": {
|
|
9
|
-
"@prisma-next/cli": "0.15.0-dev.
|
|
10
|
-
"@prisma-next/contract": "0.15.0-dev.
|
|
11
|
-
"@prisma-next/errors": "0.15.0-dev.
|
|
12
|
-
"@prisma-next/family-sql": "0.15.0-dev.
|
|
13
|
-
"@prisma-next/framework-components": "0.15.0-dev.
|
|
14
|
-
"@prisma-next/migration-tools": "0.15.0-dev.
|
|
15
|
-
"@prisma-next/psl-parser": "0.15.0-dev.
|
|
16
|
-
"@prisma-next/sql-contract": "0.15.0-dev.
|
|
17
|
-
"@prisma-next/sql-errors": "0.15.0-dev.
|
|
18
|
-
"@prisma-next/sql-operations": "0.15.0-dev.
|
|
19
|
-
"@prisma-next/sql-relational-core": "0.15.0-dev.
|
|
20
|
-
"@prisma-next/sql-schema-ir": "0.15.0-dev.
|
|
21
|
-
"@prisma-next/ts-render": "0.15.0-dev.
|
|
22
|
-
"@prisma-next/utils": "0.15.0-dev.
|
|
9
|
+
"@prisma-next/cli": "0.15.0-dev.2",
|
|
10
|
+
"@prisma-next/contract": "0.15.0-dev.2",
|
|
11
|
+
"@prisma-next/errors": "0.15.0-dev.2",
|
|
12
|
+
"@prisma-next/family-sql": "0.15.0-dev.2",
|
|
13
|
+
"@prisma-next/framework-components": "0.15.0-dev.2",
|
|
14
|
+
"@prisma-next/migration-tools": "0.15.0-dev.2",
|
|
15
|
+
"@prisma-next/psl-parser": "0.15.0-dev.2",
|
|
16
|
+
"@prisma-next/sql-contract": "0.15.0-dev.2",
|
|
17
|
+
"@prisma-next/sql-errors": "0.15.0-dev.2",
|
|
18
|
+
"@prisma-next/sql-operations": "0.15.0-dev.2",
|
|
19
|
+
"@prisma-next/sql-relational-core": "0.15.0-dev.2",
|
|
20
|
+
"@prisma-next/sql-schema-ir": "0.15.0-dev.2",
|
|
21
|
+
"@prisma-next/ts-render": "0.15.0-dev.2",
|
|
22
|
+
"@prisma-next/utils": "0.15.0-dev.2",
|
|
23
23
|
"@standard-schema/spec": "^1.1.0",
|
|
24
24
|
"arktype": "^2.2.2",
|
|
25
25
|
"pathe": "^2.0.3"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@prisma-next/psl-printer": "0.15.0-dev.
|
|
29
|
-
"@prisma-next/sql-contract-psl": "0.15.0-dev.
|
|
30
|
-
"@prisma-next/test-utils": "0.15.0-dev.
|
|
31
|
-
"@prisma-next/tsconfig": "0.15.0-dev.
|
|
32
|
-
"@prisma-next/tsdown": "0.15.0-dev.
|
|
28
|
+
"@prisma-next/psl-printer": "0.15.0-dev.2",
|
|
29
|
+
"@prisma-next/sql-contract-psl": "0.15.0-dev.2",
|
|
30
|
+
"@prisma-next/test-utils": "0.15.0-dev.2",
|
|
31
|
+
"@prisma-next/tsconfig": "0.15.0-dev.2",
|
|
32
|
+
"@prisma-next/tsdown": "0.15.0-dev.2",
|
|
33
33
|
"tsdown": "0.22.3",
|
|
34
34
|
"typescript": "5.9.3",
|
|
35
35
|
"vitest": "4.1.10"
|
|
@@ -1,14 +1,7 @@
|
|
|
1
1
|
import type { ContractToSchemaIROptions } from '@prisma-next/family-sql/control';
|
|
2
2
|
import { contractNamespaceToSchemaIR } from '@prisma-next/family-sql/control';
|
|
3
|
-
import type { SchemaNodeRef } from '@prisma-next/framework-components/control';
|
|
4
3
|
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
|
|
5
|
-
import {
|
|
6
|
-
PrimaryKey,
|
|
7
|
-
RelationalSchemaNodeKind,
|
|
8
|
-
SqlForeignKeyIR,
|
|
9
|
-
SqlIndexIR,
|
|
10
|
-
SqlUniqueIR,
|
|
11
|
-
} from '@prisma-next/sql-schema-ir/types';
|
|
4
|
+
import { SqlForeignKeyIR } from '@prisma-next/sql-schema-ir/types';
|
|
12
5
|
import { ifDefined } from '@prisma-next/utils/defined';
|
|
13
6
|
import type { PostgresRlsPolicy } from '../postgres-rls-policy';
|
|
14
7
|
import type { PostgresContract } from '../postgres-schema';
|
|
@@ -19,43 +12,8 @@ import { PostgresNativeEnumSchemaNode } from '../schema-ir/postgres-native-enum-
|
|
|
19
12
|
import { PostgresPolicySchemaNode } from '../schema-ir/postgres-policy-schema-node';
|
|
20
13
|
import { PostgresRoleSchemaNode } from '../schema-ir/postgres-role-schema-node';
|
|
21
14
|
import { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';
|
|
22
|
-
import { PostgresSchemaNodeKind } from '../schema-ir/schema-node-kinds';
|
|
23
15
|
import { resolveDdlSchemaForNamespaceStorage } from './resolve-ddl-schema';
|
|
24
16
|
|
|
25
|
-
/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */
|
|
26
|
-
function databaseStep(): { readonly nodeKind: string; readonly id: string } {
|
|
27
|
-
return { nodeKind: PostgresSchemaNodeKind.database, id: 'database' };
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function tableDependsOn(namespaceId: string, tableName: string): SchemaNodeRef {
|
|
31
|
-
return [
|
|
32
|
-
databaseStep(),
|
|
33
|
-
{ nodeKind: PostgresSchemaNodeKind.namespace, id: namespaceId },
|
|
34
|
-
{ nodeKind: PostgresSchemaNodeKind.table, id: tableName },
|
|
35
|
-
];
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function roleDependsOn(role: string): SchemaNodeRef {
|
|
39
|
-
return [databaseStep(), { nodeKind: PostgresSchemaNodeKind.role, id: role }];
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
/**
|
|
43
|
-
* The chains from a table-child object (foreign key, index, unique, primary
|
|
44
|
-
* key) to each of the own columns it is built on, in the Postgres tree.
|
|
45
|
-
* Dropping a covered column auto-drops the object, so the object's drop must
|
|
46
|
-
* precede the column's; the graph derives that direction from these edges.
|
|
47
|
-
*/
|
|
48
|
-
function columnDependsOn(
|
|
49
|
-
namespaceId: string,
|
|
50
|
-
tableName: string,
|
|
51
|
-
columns: readonly string[],
|
|
52
|
-
): readonly SchemaNodeRef[] {
|
|
53
|
-
return columns.map((column) => [
|
|
54
|
-
...tableDependsOn(namespaceId, tableName),
|
|
55
|
-
{ nodeKind: RelationalSchemaNodeKind.column, id: `column:${column}` },
|
|
56
|
-
]);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
17
|
function toPolicyNode(policy: PostgresRlsPolicy, namespaceId: string): PostgresPolicySchemaNode {
|
|
60
18
|
return new PostgresPolicySchemaNode({
|
|
61
19
|
name: policy.name,
|
|
@@ -67,7 +25,6 @@ function toPolicyNode(policy: PostgresRlsPolicy, namespaceId: string): PostgresP
|
|
|
67
25
|
...ifDefined('using', policy.using),
|
|
68
26
|
...ifDefined('withCheck', policy.withCheck),
|
|
69
27
|
permissive: policy.permissive,
|
|
70
|
-
dependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)],
|
|
71
28
|
});
|
|
72
29
|
}
|
|
73
30
|
|
|
@@ -158,67 +115,30 @@ export function contractToPostgresDatabaseSchemaNode(
|
|
|
158
115
|
// clauses, and resolves the real live DDL schema — introspected FKs
|
|
159
116
|
// already carry the live schema, so this is what lets an expected FK
|
|
160
117
|
// pair (by diff-node id) with its introspected counterpart.
|
|
161
|
-
const foreignKeys = sqlTable.foreignKeys.map(
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
dependsOn: [
|
|
177
|
-
tableDependsOn(resolvedReferencedNamespace, fk.referencedTable),
|
|
178
|
-
...columnDependsOn(ddlSchema, tableName, fk.columns),
|
|
179
|
-
],
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
// The family stamped these children's own-column `dependsOn` with the
|
|
183
|
-
// flat (single-schema) chain; the Postgres tree nests them under a
|
|
184
|
-
// namespace, so re-stamp with the multi-schema chain that matches this
|
|
185
|
-
// tree's paths. Every other field is carried through unchanged.
|
|
186
|
-
const uniques = sqlTable.uniques.map(
|
|
187
|
-
(u) =>
|
|
188
|
-
new SqlUniqueIR({
|
|
189
|
-
columns: u.columns,
|
|
190
|
-
...ifDefined('name', u.name),
|
|
191
|
-
...ifDefined('annotations', u.annotations),
|
|
192
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, u.columns),
|
|
193
|
-
}),
|
|
194
|
-
);
|
|
195
|
-
const indexes = sqlTable.indexes.map(
|
|
196
|
-
(i) =>
|
|
197
|
-
new SqlIndexIR({
|
|
198
|
-
columns: i.columns,
|
|
199
|
-
unique: i.unique,
|
|
200
|
-
...ifDefined('name', i.name),
|
|
201
|
-
...ifDefined('type', i.type),
|
|
202
|
-
...ifDefined('options', i.options),
|
|
203
|
-
...ifDefined('annotations', i.annotations),
|
|
204
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, i.columns),
|
|
118
|
+
const foreignKeys = sqlTable.foreignKeys.map(
|
|
119
|
+
(fk) =>
|
|
120
|
+
new SqlForeignKeyIR({
|
|
121
|
+
columns: fk.columns,
|
|
122
|
+
referencedTable: fk.referencedTable,
|
|
123
|
+
referencedColumns: fk.referencedColumns,
|
|
124
|
+
referencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,
|
|
125
|
+
...ifDefined('name', fk.name),
|
|
126
|
+
...ifDefined('onDelete', fk.onDelete),
|
|
127
|
+
...ifDefined('onUpdate', fk.onUpdate),
|
|
128
|
+
...ifDefined('annotations', fk.annotations),
|
|
129
|
+
resolvedReferencedNamespace: resolveDdlSchemaForNamespaceStorage(
|
|
130
|
+
contract.storage,
|
|
131
|
+
fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,
|
|
132
|
+
),
|
|
205
133
|
}),
|
|
206
134
|
);
|
|
207
|
-
const primaryKey =
|
|
208
|
-
sqlTable.primaryKey !== undefined
|
|
209
|
-
? new PrimaryKey({
|
|
210
|
-
columns: sqlTable.primaryKey.columns,
|
|
211
|
-
...ifDefined('name', sqlTable.primaryKey.name),
|
|
212
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns),
|
|
213
|
-
})
|
|
214
|
-
: undefined;
|
|
215
135
|
tables[tableName] = new PostgresTableSchemaNode({
|
|
216
136
|
name: sqlTable.name,
|
|
217
137
|
columns: sqlTable.columns,
|
|
218
138
|
foreignKeys,
|
|
219
|
-
uniques,
|
|
220
|
-
indexes,
|
|
221
|
-
...ifDefined('primaryKey', primaryKey),
|
|
139
|
+
uniques: sqlTable.uniques,
|
|
140
|
+
indexes: sqlTable.indexes,
|
|
141
|
+
...ifDefined('primaryKey', sqlTable.primaryKey),
|
|
222
142
|
...ifDefined('annotations', sqlTable.annotations),
|
|
223
143
|
...ifDefined('checks', sqlTable.checks),
|
|
224
144
|
policies: policiesByTable.get(tableName) ?? [],
|
|
@@ -5,7 +5,6 @@ import type {
|
|
|
5
5
|
SuppressionRecord,
|
|
6
6
|
} from '@prisma-next/family-sql/control';
|
|
7
7
|
import type { SchemaDiffIssue } from '@prisma-next/framework-components/control';
|
|
8
|
-
import { issueOutcome } from '@prisma-next/framework-components/control';
|
|
9
8
|
import { entityAt, UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
|
|
10
9
|
import type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';
|
|
11
10
|
import { blindCast } from '@prisma-next/utils/casts';
|
|
@@ -253,7 +252,7 @@ const POSTGRES_NODE_CREATION_FACTORY: Readonly<Record<string, string>> = Object.
|
|
|
253
252
|
* it is not admitted as creation-class here.
|
|
254
253
|
*/
|
|
255
254
|
function isEnablementCreationIssue(issue: SchemaDiffIssue<SqlSchemaDiffNode>): boolean {
|
|
256
|
-
if (
|
|
255
|
+
if (issue.reason !== 'not-equal') return false;
|
|
257
256
|
const { expected, actual } = issue;
|
|
258
257
|
return (
|
|
259
258
|
expected !== undefined &&
|
|
@@ -271,7 +270,7 @@ export function resolvePostgresNodeIssueCreationFactoryName(
|
|
|
271
270
|
if (isEnablementCreationIssue(issue)) {
|
|
272
271
|
return 'enableRowLevelSecurity';
|
|
273
272
|
}
|
|
274
|
-
if (
|
|
273
|
+
if (issue.reason !== 'not-found') return undefined;
|
|
275
274
|
const node = issue.expected ?? issue.actual;
|
|
276
275
|
if (node === undefined) return undefined;
|
|
277
276
|
return POSTGRES_NODE_CREATION_FACTORY[node.nodeKind];
|
|
@@ -299,7 +298,7 @@ export function resolvePostgresNodeIssueControlPolicySubject(
|
|
|
299
298
|
>(node);
|
|
300
299
|
return {
|
|
301
300
|
namespaceId: resolveNamespaceIdForDdlSchema(contract, namespaceNode.schemaName),
|
|
302
|
-
createsNewObject:
|
|
301
|
+
createsNewObject: issue.reason === 'not-found',
|
|
303
302
|
};
|
|
304
303
|
}
|
|
305
304
|
|
|
@@ -4,7 +4,7 @@ import { buildNativeTypeExpander } from '@prisma-next/family-sql/control';
|
|
|
4
4
|
import { classifyDiffSubjectGranularity } from '@prisma-next/family-sql/diff';
|
|
5
5
|
import type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';
|
|
6
6
|
import type { DiffableNode, SchemaDiffIssue } from '@prisma-next/framework-components/control';
|
|
7
|
-
import { diffSchemas
|
|
7
|
+
import { diffSchemas } from '@prisma-next/framework-components/control';
|
|
8
8
|
import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';
|
|
9
9
|
import type { SqlStorage } from '@prisma-next/sql-contract/types';
|
|
10
10
|
import type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';
|
|
@@ -140,7 +140,7 @@ export function diffPostgresSchema(input: {
|
|
|
140
140
|
const relationalOwned = ownedSchemaNames(expected);
|
|
141
141
|
const structuralOwned = ownedSchemaNames(fullExpected);
|
|
142
142
|
const issues = diffSchemas(expected, actual).filter((issue) => {
|
|
143
|
-
if (
|
|
143
|
+
if (issue.reason !== 'not-expected') return true;
|
|
144
144
|
if (isClusterScopedIssue(issue)) return true;
|
|
145
145
|
const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
|
|
146
146
|
const namespaceSegment = issue.path[1];
|
|
@@ -240,7 +240,7 @@ export function buildPostgresPlanDiff(input: {
|
|
|
240
240
|
readonly SchemaDiffIssue<SqlSchemaDiffNode>[],
|
|
241
241
|
'both trees are PostgresDatabaseSchemaNodes, so every diff-issue node is a SqlSchemaDiffNode'
|
|
242
242
|
>(diffSchemas(expected, paddedActual)).filter((issue) => {
|
|
243
|
-
if (
|
|
243
|
+
if (issue.reason !== 'not-expected') return true;
|
|
244
244
|
if (isClusterScopedIssue(issue)) return true;
|
|
245
245
|
const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
|
|
246
246
|
const namespaceSegment = issue.path[1];
|