@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,54 +1,16 @@
|
|
|
1
1
|
import { r as isPostgresSchema } from "./postgres-schema-Cm4DtiGA.mjs";
|
|
2
|
-
import { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode,
|
|
3
|
-
import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-
|
|
2
|
+
import { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, t as PostgresTableSchemaNode } from "./postgres-table-schema-node-D6LvInCe.mjs";
|
|
3
|
+
import { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from "./postgres-role-schema-node-Cm-j0ZGM.mjs";
|
|
4
4
|
import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-XyBaaenM.mjs";
|
|
5
|
-
import { i as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-
|
|
5
|
+
import { i as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-1Tcf7Tyu.mjs";
|
|
6
6
|
import { UNBOUND_NAMESPACE_ID } from "@prisma-next/framework-components/ir";
|
|
7
7
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
8
8
|
import { buildNativeTypeExpander, contractNamespaceToSchemaIR } from "@prisma-next/family-sql/control";
|
|
9
9
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
10
|
-
import {
|
|
10
|
+
import { SqlForeignKeyIR } from "@prisma-next/sql-schema-ir/types";
|
|
11
11
|
import { classifyDiffSubjectGranularity } from "@prisma-next/family-sql/diff";
|
|
12
|
-
import { diffSchemas
|
|
12
|
+
import { diffSchemas } from "@prisma-next/framework-components/control";
|
|
13
13
|
//#region src/core/migrations/contract-to-postgres-database-schema-node.ts
|
|
14
|
-
/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */
|
|
15
|
-
function databaseStep() {
|
|
16
|
-
return {
|
|
17
|
-
nodeKind: PostgresSchemaNodeKind.database,
|
|
18
|
-
id: "database"
|
|
19
|
-
};
|
|
20
|
-
}
|
|
21
|
-
function tableDependsOn(namespaceId, tableName) {
|
|
22
|
-
return [
|
|
23
|
-
databaseStep(),
|
|
24
|
-
{
|
|
25
|
-
nodeKind: PostgresSchemaNodeKind.namespace,
|
|
26
|
-
id: namespaceId
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
nodeKind: PostgresSchemaNodeKind.table,
|
|
30
|
-
id: tableName
|
|
31
|
-
}
|
|
32
|
-
];
|
|
33
|
-
}
|
|
34
|
-
function roleDependsOn(role) {
|
|
35
|
-
return [databaseStep(), {
|
|
36
|
-
nodeKind: PostgresSchemaNodeKind.role,
|
|
37
|
-
id: role
|
|
38
|
-
}];
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* The chains from a table-child object (foreign key, index, unique, primary
|
|
42
|
-
* key) to each of the own columns it is built on, in the Postgres tree.
|
|
43
|
-
* Dropping a covered column auto-drops the object, so the object's drop must
|
|
44
|
-
* precede the column's; the graph derives that direction from these edges.
|
|
45
|
-
*/
|
|
46
|
-
function columnDependsOn(namespaceId, tableName, columns) {
|
|
47
|
-
return columns.map((column) => [...tableDependsOn(namespaceId, tableName), {
|
|
48
|
-
nodeKind: RelationalSchemaNodeKind.column,
|
|
49
|
-
id: `column:${column}`
|
|
50
|
-
}]);
|
|
51
|
-
}
|
|
52
14
|
function toPolicyNode(policy, namespaceId) {
|
|
53
15
|
return new PostgresPolicySchemaNode({
|
|
54
16
|
name: policy.name,
|
|
@@ -59,8 +21,7 @@ function toPolicyNode(policy, namespaceId) {
|
|
|
59
21
|
roles: [...policy.roles],
|
|
60
22
|
...ifDefined("using", policy.using),
|
|
61
23
|
...ifDefined("withCheck", policy.withCheck),
|
|
62
|
-
permissive: policy.permissive
|
|
63
|
-
dependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]
|
|
24
|
+
permissive: policy.permissive
|
|
64
25
|
});
|
|
65
26
|
}
|
|
66
27
|
/**
|
|
@@ -115,48 +76,24 @@ function contractToPostgresDatabaseSchemaNode(contract, options) {
|
|
|
115
76
|
for (const tableName of Object.keys(ns.table)) {
|
|
116
77
|
const sqlTable = sqlTables[tableName];
|
|
117
78
|
if (sqlTable === void 0) continue;
|
|
118
|
-
const foreignKeys = sqlTable.foreignKeys.map((fk) => {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
...ifDefined("annotations", fk.annotations),
|
|
129
|
-
resolvedReferencedNamespace,
|
|
130
|
-
dependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]
|
|
131
|
-
});
|
|
132
|
-
});
|
|
133
|
-
const uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({
|
|
134
|
-
columns: u.columns,
|
|
135
|
-
...ifDefined("name", u.name),
|
|
136
|
-
...ifDefined("annotations", u.annotations),
|
|
137
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, u.columns)
|
|
138
|
-
}));
|
|
139
|
-
const indexes = sqlTable.indexes.map((i) => new SqlIndexIR({
|
|
140
|
-
columns: i.columns,
|
|
141
|
-
unique: i.unique,
|
|
142
|
-
...ifDefined("name", i.name),
|
|
143
|
-
...ifDefined("type", i.type),
|
|
144
|
-
...ifDefined("options", i.options),
|
|
145
|
-
...ifDefined("annotations", i.annotations),
|
|
146
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, i.columns)
|
|
79
|
+
const foreignKeys = sqlTable.foreignKeys.map((fk) => new SqlForeignKeyIR({
|
|
80
|
+
columns: fk.columns,
|
|
81
|
+
referencedTable: fk.referencedTable,
|
|
82
|
+
referencedColumns: fk.referencedColumns,
|
|
83
|
+
referencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,
|
|
84
|
+
...ifDefined("name", fk.name),
|
|
85
|
+
...ifDefined("onDelete", fk.onDelete),
|
|
86
|
+
...ifDefined("onUpdate", fk.onUpdate),
|
|
87
|
+
...ifDefined("annotations", fk.annotations),
|
|
88
|
+
resolvedReferencedNamespace: resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID)
|
|
147
89
|
}));
|
|
148
|
-
const primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({
|
|
149
|
-
columns: sqlTable.primaryKey.columns,
|
|
150
|
-
...ifDefined("name", sqlTable.primaryKey.name),
|
|
151
|
-
dependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)
|
|
152
|
-
}) : void 0;
|
|
153
90
|
tables[tableName] = new PostgresTableSchemaNode({
|
|
154
91
|
name: sqlTable.name,
|
|
155
92
|
columns: sqlTable.columns,
|
|
156
93
|
foreignKeys,
|
|
157
|
-
uniques,
|
|
158
|
-
indexes,
|
|
159
|
-
...ifDefined("primaryKey", primaryKey),
|
|
94
|
+
uniques: sqlTable.uniques,
|
|
95
|
+
indexes: sqlTable.indexes,
|
|
96
|
+
...ifDefined("primaryKey", sqlTable.primaryKey),
|
|
160
97
|
...ifDefined("annotations", sqlTable.annotations),
|
|
161
98
|
...ifDefined("checks", sqlTable.checks),
|
|
162
99
|
policies: policiesByTable.get(tableName) ?? [],
|
|
@@ -284,7 +221,7 @@ function diffPostgresSchema(input) {
|
|
|
284
221
|
const structuralOwned = ownedSchemaNames(fullExpected);
|
|
285
222
|
return {
|
|
286
223
|
issues: diffSchemas(expected, actual).filter((issue) => {
|
|
287
|
-
if (
|
|
224
|
+
if (issue.reason !== "not-expected") return true;
|
|
288
225
|
if (isClusterScopedIssue(issue)) return true;
|
|
289
226
|
const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
|
|
290
227
|
const namespaceSegment = issue.path[1];
|
|
@@ -353,7 +290,7 @@ function buildPostgresPlanDiff(input) {
|
|
|
353
290
|
expected,
|
|
354
291
|
actual: paddedActual,
|
|
355
292
|
issues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {
|
|
356
|
-
if (
|
|
293
|
+
if (issue.reason !== "not-expected") return true;
|
|
357
294
|
if (isClusterScopedIssue(issue)) return true;
|
|
358
295
|
const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);
|
|
359
296
|
const namespaceSegment = issue.path[1];
|
|
@@ -365,4 +302,4 @@ function buildPostgresPlanDiff(input) {
|
|
|
365
302
|
//#endregion
|
|
366
303
|
export { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };
|
|
367
304
|
|
|
368
|
-
//# sourceMappingURL=diff-database-schema-
|
|
305
|
+
//# sourceMappingURL=diff-database-schema-Bfgshz4v.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"diff-database-schema-Bfgshz4v.mjs","names":[],"sources":["../src/core/migrations/contract-to-postgres-database-schema-node.ts","../src/core/migrations/diff-database-schema.ts"],"sourcesContent":["import type { ContractToSchemaIROptions } from '@prisma-next/family-sql/control';\nimport { contractNamespaceToSchemaIR } from '@prisma-next/family-sql/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { SqlForeignKeyIR } from '@prisma-next/sql-schema-ir/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresRlsPolicy } from '../postgres-rls-policy';\nimport type { PostgresContract } from '../postgres-schema';\nimport { isPostgresSchema } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport { PostgresNativeEnumSchemaNode } from '../schema-ir/postgres-native-enum-schema-node';\nimport { PostgresPolicySchemaNode } from '../schema-ir/postgres-policy-schema-node';\nimport { PostgresRoleSchemaNode } from '../schema-ir/postgres-role-schema-node';\nimport { PostgresTableSchemaNode } from '../schema-ir/postgres-table-schema-node';\nimport { resolveDdlSchemaForNamespaceStorage } from './resolve-ddl-schema';\n\nfunction toPolicyNode(policy: PostgresRlsPolicy, namespaceId: string): PostgresPolicySchemaNode {\n return new PostgresPolicySchemaNode({\n name: policy.name,\n prefix: policy.prefix,\n tableName: policy.tableName,\n namespaceId,\n operation: policy.operation,\n roles: [...policy.roles],\n ...ifDefined('using', policy.using),\n ...ifDefined('withCheck', policy.withCheck),\n permissive: policy.permissive,\n });\n}\n\n/**\n * Projects a Postgres contract into the expected schema-diff tree: a\n * `PostgresDatabaseSchemaNode` root holding one `PostgresNamespaceSchemaNode`\n * per Postgres namespace, each holding its `PostgresTableSchemaNode`s with\n * their `PostgresPolicySchemaNode`s, plus the database roles on the root.\n *\n * Not a duplicate of the family's `contractToSchemaIR`: that builds a flat,\n * single `{ tables }` map (and throws on cross-namespace name collisions, with\n * no RLS/role concept) for SQLite's single-schema world. This is the\n * Postgres-specific *tree* shape — multi-schema, RLS-policy-aware, role-aware.\n * It reuses the family's per-namespace table conversion (`contractNamespaceToSchemaIR`)\n * for column/FK/index building and only adds the Postgres tree/policy/role shape.\n *\n * Tables are grouped by their owning namespace (resolved DDL schema name) so\n * the tree mirrors Postgres's object hierarchy. The DDL schema name is\n * resolved once per namespace.\n *\n * A policy that references a table absent from its namespace is a malformed\n * contract — the loop throws rather than fabricating a stub table.\n */\nexport function contractToPostgresDatabaseSchemaNode(\n contract: PostgresContract | null,\n options: ContractToSchemaIROptions,\n): PostgresDatabaseSchemaNode {\n if (contract === null) {\n return new PostgresDatabaseSchemaNode({\n namespaces: {},\n roles: [],\n existingSchemas: [],\n pgVersion: '',\n });\n }\n\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = {};\n const roles: PostgresRoleSchemaNode[] = [];\n const ownedSchemas: string[] = [];\n\n for (const ns of Object.values(contract.storage.namespaces)) {\n if (!isPostgresSchema(ns)) continue;\n\n // Role entries are root-level diff subjects: they hoist to the database\n // root from every slot and never count toward whether a namespace\n // materializes a schema node.\n for (const role of Object.values(ns.role)) {\n roles.push(new PostgresRoleSchemaNode({ name: role.name, namespaceId: role.namespaceId }));\n }\n\n // The unbound slot resolves its DDL schema to 'public', so it\n // materializes a schema node exactly when it has non-role content — a\n // late-binding contract keeps today's behavior (the slot carries the\n // tables), while a roles-only unbound slot alongside named namespaces\n // contributes only root roles and no node (which would otherwise be a\n // spurious empty 'public' node, clobbering a real bound 'public'\n // namespace's node keyed by the same resolved schema name).\n if (ns.id === UNBOUND_NAMESPACE_ID) {\n const hasNonRoleContent = Object.entries(ns.entries).some(\n ([entriesKey, slot]) => entriesKey !== 'role' && Object.keys(slot).length > 0,\n );\n if (!hasNonRoleContent) continue;\n }\n\n const ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n ownedSchemas.push(ddlSchema);\n\n // Convert only THIS namespace's tables (passing the full storage for\n // type/value-set/enum resolution that spans namespaces), so the same table\n // name can exist in two schemas without colliding in a bare-keyed record.\n const sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\n const policiesByTable = new Map<string, PostgresPolicySchemaNode[]>();\n for (const policy of Object.values(ns.policy)) {\n const list = policiesByTable.get(policy.tableName) ?? [];\n list.push(toPolicyNode(policy, ddlSchema));\n policiesByTable.set(policy.tableName, list);\n }\n\n const tables: Record<string, PostgresTableSchemaNode> = {};\n for (const tableName of Object.keys(ns.table)) {\n const sqlTable = sqlTables[tableName];\n if (sqlTable === undefined) continue;\n // The family conversion stamps `referencedSchema` only for bound FK\n // targets; an absent value means the FK targets the unbound namespace.\n // Postgres restores its own coordinate for that slot (the unbound\n // singleton's id) so the raw coordinate keeps qualifying REFERENCES\n // clauses, and resolves the real live DDL schema — introspected FKs\n // already carry the live schema, so this is what lets an expected FK\n // pair (by diff-node id) with its introspected counterpart.\n const foreignKeys = sqlTable.foreignKeys.map(\n (fk) =>\n new SqlForeignKeyIR({\n columns: fk.columns,\n referencedTable: fk.referencedTable,\n referencedColumns: fk.referencedColumns,\n referencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n ...ifDefined('name', fk.name),\n ...ifDefined('onDelete', fk.onDelete),\n ...ifDefined('onUpdate', fk.onUpdate),\n ...ifDefined('annotations', fk.annotations),\n resolvedReferencedNamespace: resolveDdlSchemaForNamespaceStorage(\n contract.storage,\n fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n ),\n }),\n );\n tables[tableName] = new PostgresTableSchemaNode({\n name: sqlTable.name,\n columns: sqlTable.columns,\n foreignKeys,\n uniques: sqlTable.uniques,\n indexes: sqlTable.indexes,\n ...ifDefined('primaryKey', sqlTable.primaryKey),\n ...ifDefined('annotations', sqlTable.annotations),\n ...ifDefined('checks', sqlTable.checks),\n policies: policiesByTable.get(tableName) ?? [],\n // Marker-driven, never derived from the policy set: the `rls` entry\n // is the single authored source of enablement.\n rlsEnabled: Object.hasOwn(ns.rls, tableName),\n });\n }\n\n for (const [tableName, tablePolicies] of policiesByTable) {\n if (!(tableName in tables)) {\n const policyName = tablePolicies[0]?.name ?? '(unknown)';\n throw new Error(\n `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`,\n );\n }\n if (!Object.hasOwn(ns.rls, tableName)) {\n const policyPrefix = tablePolicies[0]?.prefix ?? '(unknown)';\n throw new Error(\n `contract-to-postgres-database-schema-node: policy \"${policyPrefix}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`,\n );\n }\n }\n\n const nativeEnums = Object.values(ns.entries.native_enum ?? {}).map(\n (entity) =>\n new PostgresNativeEnumSchemaNode({\n typeName: entity.typeName,\n namespaceId: ddlSchema,\n members: entity.members,\n ...ifDefined('control', entity.control),\n }),\n );\n\n namespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n schemaName: ddlSchema,\n tables,\n nativeEnums,\n });\n }\n\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles,\n existingSchemas: ownedSchemas,\n pgVersion: '',\n });\n}\n","import type { Contract, ControlPolicy } from '@prisma-next/contract/types';\nimport type { SqlSchemaDiffResult } from '@prisma-next/family-sql/control';\nimport { buildNativeTypeExpander } from '@prisma-next/family-sql/control';\nimport { classifyDiffSubjectGranularity } from '@prisma-next/family-sql/diff';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { DiffableNode, SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { diffSchemas } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { PostgresContract } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport {\n postgresDiffSubjectGranularity,\n type SqlSchemaDiffNode,\n} from '../schema-ir/schema-node-kinds';\nimport { contractToPostgresDatabaseSchemaNode } from './contract-to-postgres-database-schema-node';\nimport { resolvePostgresNodeIssueControlPolicySubject } from './control-policy';\n\n/**\n * Whether a diff issue's subject node is cluster-scoped — it carries its own\n * `namespaceId` field (only role and policy diff nodes do) and that\n * coordinate is the unbound sentinel, meaning the node is not owned by any\n * schema/namespace. A role node is always cluster-scoped (roles are\n * cluster-level objects); a policy node's `namespaceId` is always its\n * table's resolved DDL schema, never the sentinel. Namespace-ownership\n * scoping (which compares `issue.path[1]` against the set of DDL schemas\n * the contract owns) makes no sense for a cluster-scoped subject — its path\n * segment at that index is the object's own name, not a schema name — so\n * such an issue bypasses that scoping entirely.\n */\nfunction isClusterScopedIssue(issue: SchemaDiffIssue): boolean {\n const node = issue.expected ?? issue.actual;\n return node !== undefined && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\n\nfunction nodeNamespaceId(node: DiffableNode): string | undefined {\n if (!Object.hasOwn(node, 'namespaceId')) return undefined;\n return blindCast<\n { namespaceId: string },\n 'presence of an own namespaceId field was just checked via Object.hasOwn'\n >(node).namespaceId;\n}\n\nfunction ownedSchemaNames(expected: PostgresDatabaseSchemaNode): ReadonlySet<string> {\n const policyNamespaces = Object.values(expected.namespaces).flatMap((ns) =>\n Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)),\n );\n return new Set([...policyNamespaces, ...expected.existingSchemas]);\n}\n\n/**\n * Drops contract namespaces that declare no tables from the verdict-diff\n * expected tree and the relational owned-schema set. The legacy relational\n * walk skipped a table-less namespace (e.g. an enums-only schema) before\n * pairing, so neither its DDL schema's absence nor that schema's live\n * relational contents ever reached the verdict — the pruned tree\n * reproduces that. The prune loses no expected policies: policies attach\n * to tables, so a table-less namespace carries none (the projection\n * throws on a policy referencing an absent table). Live policies in a\n * pruned schema remain governed via the full owned set (see\n * {@link diffPostgresSchema}).\n */\nfunction pruneTableLessNamespaces(\n expected: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces = Object.fromEntries(\n Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0),\n );\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...expected.roles],\n existingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== undefined),\n pgVersion: expected.pgVersion,\n });\n}\n\n/**\n * Resolves a verdict-diff issue's subject's declared control policy directly\n * from the contract, by delegating to the same node-typed resolver\n * ({@link resolvePostgresNodeIssueControlPolicySubject}) the planner uses to\n * gate DDL calls. `undefined` when the issue resolves to no contract subject.\n *\n * A role issue resolves through that same resolver to `external`\n * unconditionally (see its role branch), regardless of the contract's own\n * default policy: a role is referenced by the contract but not owned, and\n * `external`'s existing semantics — a missing declared subject still fails,\n * every extra is suppressed — are exactly the wanted asymmetric grading for\n * a cluster object the framework does not own.\n */\nfunction resolveControlPolicy(\n issue: SchemaDiffIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicy | undefined {\n const nodeIssue = blindCast<\n SchemaDiffIssue<SqlSchemaDiffNode>,\n 'every node in a Postgres schema diff tree is a SqlSchemaDiffNode'\n >(issue);\n return resolvePostgresNodeIssueControlPolicySubject(nodeIssue, contract)\n ?.explicitNodeControlPolicy;\n}\n\n/**\n * The Postgres full-tree node diff for the family verify verdict: derive\n * the expected tree (resolved leaf values, expander threaded, FK schemas\n * resolved, table-less namespaces pruned), run the generic\n * differ over the trees as derived, and scope out `not-expected` findings under namespaces the\n * contract does not own. Ownership scoping bypasses cluster-scoped subjects\n * (roles today), mirroring the legacy decomposition: relational extras check\n * the PRUNED owned set (the legacy\n * per-namespace walk never visited a table-less namespace, so its live\n * relational contents are invisible), while `structural` extras (RLS\n * policies) check the FULL owned set (the legacy policy diff governed\n * every contract schema regardless of tables — RLS governance does not\n * shrink because a namespace declares no tables). The codec `verifyType`\n * hooks run once per contract namespace with tables against that\n * namespace's paired actual node (the hooks read namespace-scoped state\n * such as `nativeEnums`).\n */\nexport function diffPostgresSchema(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): SqlSchemaDiffResult {\n const postgresContract = blindCast<\n PostgresContract,\n 'diffPostgresSchema is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.schema);\n const actual = input.schema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n });\n const expected = pruneTableLessNamespaces(fullExpected);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = diffSchemas(expected, actual).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n if (isClusterScopedIssue(issue)) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n const namespacePairs = Object.values(expected.namespaces).map((ns) => ({\n actual: actual.namespaces[ns.schemaName],\n }));\n return {\n issues,\n resolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n namespacePairs,\n };\n}\n\n/**\n * Adds an empty namespace node to the actual tree for every expected namespace\n * absent from it. The relational plan diff pairs on namespace: a contract\n * namespace whose live schema does not exist yet must surface each of its\n * tables as `not-found` (→ `CREATE TABLE`), NOT as a single namespace\n * `not-found` that subtree-coalescing would collapse (leaving `CREATE SCHEMA`\n * with no tables). Padding makes the namespaces pair, so only table/column/\n * policy drift surfaces; `CREATE SCHEMA` comes separately from the synthesized\n * namespace-presence stitch (`verifyPostgresNamespacePresence`), never from the\n * tree diff — matching the retired per-namespace-paired relational walk, which\n * paired a missing schema against an empty namespace node.\n */\nfunction padActualNamespaces(\n expected: PostgresDatabaseSchemaNode,\n actual: PostgresDatabaseSchemaNode,\n): PostgresDatabaseSchemaNode {\n const namespaces: Record<string, PostgresNamespaceSchemaNode> = { ...actual.namespaces };\n let padded = false;\n for (const schemaName of Object.keys(expected.namespaces)) {\n if (namespaces[schemaName] === undefined) {\n namespaces[schemaName] = new PostgresNamespaceSchemaNode({\n schemaName,\n tables: {},\n });\n padded = true;\n }\n }\n if (!padded) return actual;\n return new PostgresDatabaseSchemaNode({\n namespaces,\n roles: [...actual.roles],\n existingSchemas: [...actual.existingSchemas],\n pgVersion: actual.pgVersion,\n });\n}\n\nexport interface PostgresPlanDiff {\n /** The desired (\"end\") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */\n readonly expected: PostgresDatabaseSchemaNode;\n /** The live (\"start\") tree, padded with empty namespaces so a missing schema's tables pair. */\n readonly actual: PostgresDatabaseSchemaNode;\n /** The one node diff over the two trees: relational + policy drift, cluster-scope-aware ownership filtered. */\n readonly issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[];\n}\n\n/**\n * The Postgres planner's diff input: the SAME tree-building\n * `diffPostgresSchema` uses (expander threaded, FK schemas resolved,\n * table-less namespaces pruned, cluster-scope-aware ownership filter) plus\n * actual namespace padding (so a missing\n * schema's tables surface as `not-found` instead of a swallowed namespace\n * `not-found`). One differ drives both verify and plan; this is the\n * plan-side derivation. The single issue list covers tables / columns /\n * constraints / indexes / defaults AND policies — the caller splits it\n * (relational → `mapNodeIssueToCall`; policy → RLS ops) and stitches in\n * `CREATE SCHEMA` separately.\n */\nexport function buildPostgresPlanDiff(input: {\n readonly contract: Contract<SqlStorage>;\n readonly actualSchema: SqlSchemaIRNode;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}): PostgresPlanDiff {\n const postgresContract = blindCast<\n PostgresContract,\n 'buildPostgresPlanDiff is only called with a postgres contract'\n >(input.contract);\n PostgresDatabaseSchemaNode.assert(input.actualSchema);\n const actual = input.actualSchema;\n const expandNativeType = buildNativeTypeExpander(input.frameworkComponents);\n const projectionOptions = {\n annotationNamespace: 'pg',\n ...ifDefined('expandNativeType', expandNativeType),\n };\n const fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, projectionOptions);\n const expected = pruneTableLessNamespaces(fullExpected);\n const paddedActual = padActualNamespaces(expected, actual);\n const relationalOwned = ownedSchemaNames(expected);\n const structuralOwned = ownedSchemaNames(fullExpected);\n const issues = blindCast<\n readonly SchemaDiffIssue<SqlSchemaDiffNode>[],\n 'both trees are PostgresDatabaseSchemaNodes, so every diff-issue node is a SqlSchemaDiffNode'\n >(diffSchemas(expected, paddedActual)).filter((issue) => {\n if (issue.reason !== 'not-expected') return true;\n if (isClusterScopedIssue(issue)) return true;\n const granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n const namespaceSegment = issue.path[1];\n if (namespaceSegment === undefined) return true;\n const owned = granularity === 'structural' ? structuralOwned : relationalOwned;\n return owned.has(namespaceSegment);\n });\n return { expected, actual: paddedActual, issues };\n}\n"],"mappings":";;;;;;;;;;;;;AAgBA,SAAS,aAAa,QAA2B,aAA+C;CAC9F,OAAO,IAAI,yBAAyB;EAClC,MAAM,OAAO;EACb,QAAQ,OAAO;EACf,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,GAAG,UAAU,SAAS,OAAO,KAAK;EAClC,GAAG,UAAU,aAAa,OAAO,SAAS;EAC1C,YAAY,OAAO;CACrB,CAAC;AACH;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,qCACd,UACA,SAC4B;CAC5B,IAAI,aAAa,MACf,OAAO,IAAI,2BAA2B;EACpC,YAAY,CAAC;EACb,OAAO,CAAC;EACR,iBAAiB,CAAC;EAClB,WAAW;CACb,CAAC;CAGH,MAAM,aAA0D,CAAC;CACjE,MAAM,QAAkC,CAAC;CACzC,MAAM,eAAyB,CAAC;CAEhC,KAAK,MAAM,MAAM,OAAO,OAAO,SAAS,QAAQ,UAAU,GAAG;EAC3D,IAAI,CAAC,iBAAiB,EAAE,GAAG;EAK3B,KAAK,MAAM,QAAQ,OAAO,OAAO,GAAG,IAAI,GACtC,MAAM,KAAK,IAAI,uBAAuB;GAAE,MAAM,KAAK;GAAM,aAAa,KAAK;EAAY,CAAC,CAAC;EAU3F,IAAI,GAAG,OAAO;OAIR,CA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C5C,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM,cAAc,+BAA+B,OAAO,8BAA8B;GACxF,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAA,GAAW,OAAO;GAE3C,QADc,gBAAgB,eAAe,kBAAkB,gBAAA,CAClD,IAAI,gBAAgB;EACnC,CAC8C;CAAE;AAClD"}
|
|
@@ -1,11 +1,20 @@
|
|
|
1
|
-
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-
|
|
2
|
-
import { n as SqlSchemaDiffNode } from "./schema-node-kinds-CrYzCR1i.mjs";
|
|
1
|
+
import { t as PostgresDatabaseSchemaNode } from "./postgres-database-schema-node-CJv5bfbs.mjs";
|
|
3
2
|
import { SqlStorage } from "@prisma-next/sql-contract/types";
|
|
4
3
|
import { SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
5
|
-
import { SchemaDiffIssue } from "@prisma-next/framework-components/control";
|
|
4
|
+
import { DiffableNode, SchemaDiffIssue } from "@prisma-next/framework-components/control";
|
|
6
5
|
import { Contract } from "@prisma-next/contract/types";
|
|
7
6
|
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
8
7
|
|
|
8
|
+
//#region src/core/schema-ir/schema-node-kinds.d.ts
|
|
9
|
+
/**
|
|
10
|
+
* A Postgres schema-diff-tree node: a `SqlSchemaIRNode` that also implements
|
|
11
|
+
* `DiffableNode` (the five `Postgres*SchemaNode` classes). `SqlSchemaIRNode`
|
|
12
|
+
* alone is not a `DiffableNode` — its relational subclasses (`SqlColumnIR`, …)
|
|
13
|
+
* carry no `id`/`isEqualTo`/`children` — so this intersection is the honest node
|
|
14
|
+
* type the differ produces and the planner consumes (`SchemaDiff<SqlSchemaDiffNode>`).
|
|
15
|
+
*/
|
|
16
|
+
type SqlSchemaDiffNode = SqlSchemaIRNode & DiffableNode;
|
|
17
|
+
//#endregion
|
|
9
18
|
//#region src/core/migrations/diff-database-schema.d.ts
|
|
10
19
|
interface PostgresPlanDiff {
|
|
11
20
|
/** The desired ("end") tree — resolved leaf values (incl. `codecRef`) on every column, table-less namespaces pruned. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diff-database-schema.d.mts","names":[],"sources":["../src/core/migrations/diff-database-schema.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"diff-database-schema.d.mts","names":[],"sources":["../src/core/schema-ir/schema-node-kinds.ts","../src/core/migrations/diff-database-schema.ts"],"mappings":";;;;;;;;;;;;;;;KAiBY,iBAAA,GAAoB,eAAA,GAAkB,YAAY;;;UCmL7C,gBAAA;EAMW;EAAA,SAJjB,QAAA,EAAU,0BAAA;EAIwC;EAAA,SAFlD,MAAA,EAAQ,0BAAA;EAiBH;EAAA,SAfL,MAAA,WAAiB,eAAA,CAAgB,iBAAA;AAAA;;;;;;;;;;;;;iBAe5B,qBAAA,CAAsB,KAAA;EAAA,SAC3B,QAAA,EAAU,QAAA,CAAS,UAAA;EAAA,SACnB,YAAA,EAAc,eAAA;EAAA,SACd,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA,IAC1C,gBAAA"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as buildPostgresPlanDiff } from "./diff-database-schema-
|
|
1
|
+
import { t as buildPostgresPlanDiff } from "./diff-database-schema-Bfgshz4v.mjs";
|
|
2
2
|
export { buildPostgresPlanDiff };
|
package/dist/issue-planner.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { w as PostgresOpFactoryCall } from "./op-factory-call-Bn9zDx4_.mjs";
|
|
2
2
|
import { SqlStorage, StorageTable, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
3
3
|
import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma-next/family-sql/control";
|
|
4
4
|
import { SqlColumnIR, SqlSchemaIR, SqlSchemaIRNode } from "@prisma-next/sql-schema-ir/types";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"mappings":";;;;;;;;;;;;;;;;;;;UAwIiB,eAAA;EAAA,SACN,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAAA,SACtC,MAAA,EAAQ,WAAA;EAAA,SACR,MAAA,EAAQ,wBAAA;EAAA,SACR,mBAAA,EAAqB,aAAA,CAAc,8BAAA;AAAA;;AChB9C;;;;AACgD;AAkThD;KDrRY,qBAAA,IACV,MAAA,WAAiB,eAAA,IACjB,OAAA,EAAS,eAAA;EAGL,IAAA;EACA,MAAA,WAAiB,eAAA;EACjB,KAAA,WAAgB,qBAAA;EC+Qa;;;;;;;EDvQ7B,MAAA;AAAA;EAEA,IAAA;AAAA;;;UC/CW,iBAAA;EAAA,SACN,KAAA,WAAgB,qBAAqB;AAAA;;;;;;;;;;iBAkThC,qBAAA,eAAoC,YAAA,GAAe,YAAA,EACjE,MAAA,WAAiB,eAAA,CAAgB,KAAA,eACvB,eAAA,CAAgB,KAAA;AAAA,UAgiBX,mBAAA;EAAA,SACN,MAAA,WAAiB,eAAA;EAAA,SACjB,UAAA,EAAY,QAAA,CAAS,UAAA;EAAA,SACrB,YAAA,EAAc,QAAA,CAAS,UAAA;EAAA,SACvB,UAAA;EAAA,SACA,UAAA,EAAY,WAAA,SAAoB,iBAAA;EAAA,SAChC,YAAA,EAAc,QAAA,CAAS,MAAA,SAAe,mBAAA;EAviBd;;;;;;;EAAA,SA+iBxB,MAAA,GAAS,WAAA;EAhjB+C;;;;;EAAA,SAsjBxD,MAAA,GAAS,wBAAA;EApjBa;AAAA;AAgiBjC;;EAhiBiC,SAyjBtB,mBAAA,GAAsB,aAAA,CAAc,8BAAA;EAAA,SACpC,UAAA,YAAsB,qBAAA;AAAA;;;;;;;;iBAUjB,UAAA,CACd,OAAA,EAAS,mBAAA,GACR,MAAA,CAAO,iBAAA,WAA4B,kBAAA"}
|
package/dist/issue-planner.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { l as planIssues, o as coalesceSubtreeIssues } from "./control-policy-
|
|
1
|
+
import { l as planIssues, o as coalesceSubtreeIssues } from "./control-policy-1Tcf7Tyu.mjs";
|
|
2
2
|
export { coalesceSubtreeIssues, planIssues };
|
package/dist/migration.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { n as DataTransformOptions, r as dataTransform, t as DataTransformClosure } from "./data-transform-DPzwBMhW.mjs";
|
|
2
|
-
import {
|
|
3
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
2
|
+
import { k as Op } from "./op-factory-call-Bn9zDx4_.mjs";
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-DbckK1su.mjs";
|
|
4
4
|
import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
5
|
import { placeholder } from "@prisma-next/errors/migration";
|
|
6
6
|
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
package/dist/migration.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { P as createExtension } from "./op-factory-call-
|
|
1
|
+
import { P as createExtension } from "./op-factory-call-C38NzvQD.mjs";
|
|
2
2
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
3
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-arMSWU9b.mjs";
|
|
4
4
|
import { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from "@prisma-next/sql-relational-core/contract-free";
|
|
5
5
|
import { placeholder } from "@prisma-next/errors/migration";
|
|
6
6
|
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
|
@@ -171,6 +171,7 @@ declare class AddNotNullColumnDirectCall extends PostgresOpFactoryCallNode {
|
|
|
171
171
|
constructor(schemaName: string, tableName: string, columnName: string, column: DdlColumn);
|
|
172
172
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
173
173
|
renderTypeScript(): string;
|
|
174
|
+
importRequirements(): readonly ImportRequirement[];
|
|
174
175
|
}
|
|
175
176
|
/**
|
|
176
177
|
* Planner-internal call for adding a NOT NULL column (no contract default)
|
|
@@ -204,6 +205,7 @@ declare class AddNotNullColumnWithTempDefaultCall extends PostgresOpFactoryCallN
|
|
|
204
205
|
});
|
|
205
206
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
206
207
|
renderTypeScript(): string;
|
|
208
|
+
importRequirements(): readonly ImportRequirement[];
|
|
207
209
|
}
|
|
208
210
|
declare class AddPrimaryKeyCall extends PostgresOpFactoryCallNode {
|
|
209
211
|
readonly factoryName: "addPrimaryKey";
|
|
@@ -427,7 +429,6 @@ declare class CreatePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
427
429
|
constructor(schemaName: string, tableName: string, policy: PostgresRlsPolicy);
|
|
428
430
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
429
431
|
renderTypeScript(): string;
|
|
430
|
-
importRequirements(): readonly ImportRequirement[];
|
|
431
432
|
}
|
|
432
433
|
declare class DropPostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
433
434
|
readonly factoryName: "dropRlsPolicy";
|
|
@@ -439,7 +440,6 @@ declare class DropPostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
439
440
|
constructor(schemaName: string, tableName: string, policyName: string);
|
|
440
441
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
441
442
|
renderTypeScript(): string;
|
|
442
|
-
importRequirements(): readonly ImportRequirement[];
|
|
443
443
|
}
|
|
444
444
|
declare class EnableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
445
445
|
readonly factoryName: "enableRowLevelSecurity";
|
|
@@ -450,7 +450,6 @@ declare class EnableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
|
450
450
|
constructor(schemaName: string, tableName: string);
|
|
451
451
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
452
452
|
renderTypeScript(): string;
|
|
453
|
-
importRequirements(): readonly ImportRequirement[];
|
|
454
453
|
}
|
|
455
454
|
declare class DisableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
456
455
|
readonly factoryName: "disableRowLevelSecurity";
|
|
@@ -461,7 +460,6 @@ declare class DisableRowLevelSecurityCall extends PostgresOpFactoryCallNode {
|
|
|
461
460
|
constructor(schemaName: string, tableName: string);
|
|
462
461
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
463
462
|
renderTypeScript(): string;
|
|
464
|
-
importRequirements(): readonly ImportRequirement[];
|
|
465
463
|
}
|
|
466
464
|
declare class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
467
465
|
readonly factoryName: "renameRlsPolicy";
|
|
@@ -474,9 +472,8 @@ declare class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
|
|
|
474
472
|
constructor(schemaName: string, tableName: string, oldPolicyName: string, newPolicyName: string);
|
|
475
473
|
toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
|
|
476
474
|
renderTypeScript(): string;
|
|
477
|
-
importRequirements(): readonly ImportRequirement[];
|
|
478
475
|
}
|
|
479
476
|
type PostgresOpFactoryCall = CreateTableCall | DropTableCall | AddColumnCall | DropColumnCall | AlterColumnTypeCall | SetNotNullCall | DropNotNullCall | SetDefaultCall | DropDefaultCall | AddNotNullColumnDirectCall | AddNotNullColumnWithTempDefaultCall | AddPrimaryKeyCall | AddForeignKeyCall | AddUniqueCall | AddCheckConstraintCall | DropCheckConstraintCall | CreateIndexCall | DropIndexCall | DropConstraintCall | RawSqlCall | CreateExtensionCall | CreateSchemaCall | CreateNativeEnumTypeCall | DropNativeEnumTypeCall | AddNativeEnumValueCall | CreatePostgresRlsPolicyCall | DropPostgresRlsPolicyCall | EnableRowLevelSecurityCall | DisableRowLevelSecurityCall | RenamePostgresRlsPolicyCall | DataTransformCall;
|
|
480
477
|
//#endregion
|
|
481
|
-
export {
|
|
482
|
-
//# sourceMappingURL=op-factory-call-
|
|
478
|
+
export { DropTableCall as C, SetNotNullCall as D, SetDefaultCall as E, ForeignKeySpec as O, DropNotNullCall as S, RawSqlCall as T, DropColumnCall as _, AddNotNullColumnWithTempDefaultCall as a, DropIndexCall as b, AlterColumnTypeCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DropCheckConstraintCall as g, DataTransformCall as h, AddNativeEnumValueCall as i, Op$1 as k, AlterColumnTypeOptions as l, CreateTableCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateSchemaCall as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropConstraintCall as v, PostgresOpFactoryCall as w, DropNativeEnumTypeCall as x, DropDefaultCall as y };
|
|
479
|
+
//# sourceMappingURL=op-factory-call-Bn9zDx4_.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-factory-call-Bn9zDx4_.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/op-factory-call.ts"],"mappings":";;;;;;;;;;KAKY,IAAA,GAAK,yBAAyB,CAAC,yBAAA;;;;;;UAO1B,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAA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ACA,eAAA,GACA,0BAAA,GACA,mCAAA,GACA,iBAAA,GACA,iBAAA,GACA,aAAA,GACA,sBAAA,GACA,uBAAA,GACA,eAAA,GACA,aAAA,GACA,kBAAA,GACA,UAAA,GACA,mBAAA,GACA,gBAAA,GACA,wBAAA,GACA,sBAAA,GACA,sBAAA,GACA,2BAAA,GACA,yBAAA,GACA,0BAAA,GACA,2BAAA,GACA,2BAAA,GACA,iBAAA"}
|
|
@@ -1235,6 +1235,9 @@ var AddNotNullColumnDirectCall = class extends PostgresOpFactoryCallNode {
|
|
|
1235
1235
|
operationClass: "additive"
|
|
1236
1236
|
})})`;
|
|
1237
1237
|
}
|
|
1238
|
+
importRequirements() {
|
|
1239
|
+
return [];
|
|
1240
|
+
}
|
|
1238
1241
|
};
|
|
1239
1242
|
/**
|
|
1240
1243
|
* Planner-internal call for adding a NOT NULL column (no contract default)
|
|
@@ -1289,6 +1292,9 @@ var AddNotNullColumnWithTempDefaultCall = class extends PostgresOpFactoryCallNod
|
|
|
1289
1292
|
operationClass: "additive"
|
|
1290
1293
|
})})`;
|
|
1291
1294
|
}
|
|
1295
|
+
importRequirements() {
|
|
1296
|
+
return [];
|
|
1297
|
+
}
|
|
1292
1298
|
};
|
|
1293
1299
|
function constraintCallOptions(schemaName, tableName, constraintName) {
|
|
1294
1300
|
const opts = [];
|
|
@@ -1822,22 +1828,7 @@ var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1822
1828
|
return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
|
|
1823
1829
|
}
|
|
1824
1830
|
renderTypeScript() {
|
|
1825
|
-
|
|
1826
|
-
const input = {
|
|
1827
|
-
name: p.name,
|
|
1828
|
-
prefix: p.prefix,
|
|
1829
|
-
tableName: p.tableName,
|
|
1830
|
-
namespaceId: p.namespaceId,
|
|
1831
|
-
operation: p.operation,
|
|
1832
|
-
roles: p.roles,
|
|
1833
|
-
...ifDefined("using", p.using),
|
|
1834
|
-
...ifDefined("withCheck", p.withCheck),
|
|
1835
|
-
permissive: p.permissive
|
|
1836
|
-
};
|
|
1837
|
-
return `this.createRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${jsonToTsSource(input)} })`;
|
|
1838
|
-
}
|
|
1839
|
-
importRequirements() {
|
|
1840
|
-
return [];
|
|
1831
|
+
return `createRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policy)})`;
|
|
1841
1832
|
}
|
|
1842
1833
|
};
|
|
1843
1834
|
var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
@@ -1860,10 +1851,7 @@ var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1860
1851
|
return dropRlsPolicy(this.schemaName, this.tableName, this.policyName, lowerer);
|
|
1861
1852
|
}
|
|
1862
1853
|
renderTypeScript() {
|
|
1863
|
-
return `
|
|
1864
|
-
}
|
|
1865
|
-
importRequirements() {
|
|
1866
|
-
return [];
|
|
1854
|
+
return `dropRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.policyName)})`;
|
|
1867
1855
|
}
|
|
1868
1856
|
};
|
|
1869
1857
|
var EnableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
@@ -1884,10 +1872,7 @@ var EnableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
|
1884
1872
|
return enableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1885
1873
|
}
|
|
1886
1874
|
renderTypeScript() {
|
|
1887
|
-
return `
|
|
1888
|
-
}
|
|
1889
|
-
importRequirements() {
|
|
1890
|
-
return [];
|
|
1875
|
+
return `enableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1891
1876
|
}
|
|
1892
1877
|
};
|
|
1893
1878
|
var DisableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
@@ -1908,10 +1893,7 @@ var DisableRowLevelSecurityCall = class extends PostgresOpFactoryCallNode {
|
|
|
1908
1893
|
return disableRowLevelSecurity(this.schemaName, this.tableName, lowerer);
|
|
1909
1894
|
}
|
|
1910
1895
|
renderTypeScript() {
|
|
1911
|
-
return `
|
|
1912
|
-
}
|
|
1913
|
-
importRequirements() {
|
|
1914
|
-
return [];
|
|
1896
|
+
return `disableRowLevelSecurity(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)})`;
|
|
1915
1897
|
}
|
|
1916
1898
|
};
|
|
1917
1899
|
var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
@@ -1936,13 +1918,10 @@ var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
|
|
|
1936
1918
|
return renameRlsPolicy(this.schemaName, this.tableName, this.oldPolicyName, this.newPolicyName, lowerer);
|
|
1937
1919
|
}
|
|
1938
1920
|
renderTypeScript() {
|
|
1939
|
-
return `
|
|
1940
|
-
}
|
|
1941
|
-
importRequirements() {
|
|
1942
|
-
return [];
|
|
1921
|
+
return `renameRlsPolicy(${jsonToTsSource(this.schemaName)}, ${jsonToTsSource(this.tableName)}, ${jsonToTsSource(this.oldPolicyName)}, ${jsonToTsSource(this.newPolicyName)})`;
|
|
1943
1922
|
}
|
|
1944
1923
|
};
|
|
1945
1924
|
//#endregion
|
|
1946
1925
|
export { SetDefaultCall as A, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, installExtension as F, postgresDefaultToDdlColumnDefault as M, buildTargetDetails as N, RawSqlCall as O, createExtension as P, DropIndexCall as S, DropPostgresRlsPolicyCall as T, DisableRowLevelSecurityCall as _, AddNotNullColumnDirectCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddNativeEnumValueCall as i, SetNotNullCall as j, RenamePostgresRlsPolicyCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddNotNullColumnWithTempDefaultCall as o, CreatePostgresRlsPolicyCall as p, AddForeignKeyCall as r, AddPrimaryKeyCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y };
|
|
1947
1926
|
|
|
1948
|
-
//# sourceMappingURL=op-factory-call-
|
|
1927
|
+
//# sourceMappingURL=op-factory-call-C38NzvQD.mjs.map
|