@prisma/orm-target-postgres 8.0.0-rc.17-dev.18 → 8.0.0-rc.17-dev.20

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.
Files changed (57) hide show
  1. package/dist/adapter__control.mjs +1 -1
  2. package/dist/{control-CM6c5oIC.mjs → control-DgXESsdx.mjs} +4 -4
  3. package/dist/{control-CM6c5oIC.mjs.map → control-DgXESsdx.mjs.map} +1 -1
  4. package/dist/{control-policy-DbDoLxrp-OpWBtviT.mjs → control-policy-C5VoaD11-lzAw5cjN.mjs} +3 -3
  5. package/dist/{control-policy-DbDoLxrp-OpWBtviT.mjs.map → control-policy-C5VoaD11-lzAw5cjN.mjs.map} +1 -1
  6. package/dist/{diff-database-schema-CByLrBg6-BLLJDUpg.mjs → diff-database-schema-CUSXh2y2-CWRGCPL7.mjs} +3 -3
  7. package/dist/{diff-database-schema-CByLrBg6-BLLJDUpg.mjs.map → diff-database-schema-CUSXh2y2-CWRGCPL7.mjs.map} +1 -1
  8. package/dist/{issue-planner-BwcfQagl.d.mts → issue-planner-BLOtwO3z.d.mts} +2 -2
  9. package/dist/{issue-planner-BwcfQagl.d.mts.map → issue-planner-BLOtwO3z.d.mts.map} +1 -1
  10. package/dist/{migration-PTHAY9Cv.mjs → migration-C9ZH26Nj.mjs} +3 -2
  11. package/dist/{migration-PTHAY9Cv.mjs.map → migration-C9ZH26Nj.mjs.map} +1 -1
  12. package/dist/{migration-D5f4UTR3.d.mts → migration-CQeS0oqg.d.mts} +5 -4
  13. package/dist/migration-CQeS0oqg.d.mts.map +1 -0
  14. package/dist/op-factory-call-CBqqbXBb.d.mts +1 -0
  15. package/dist/{op-factory-call-BaT4DlIo-BnVxOrwv.d.mts → op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts} +8 -2
  16. package/dist/op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts.map +1 -0
  17. package/dist/{op-factory-call-BfGiIbUO-BqaxwJhg.mjs → op-factory-call-DiwaNQVO-NSekrcmI.mjs} +86 -37
  18. package/dist/op-factory-call-DiwaNQVO-NSekrcmI.mjs.map +1 -0
  19. package/dist/{planner-BkGEylgU.d.mts → planner-C6vpC6nq.d.mts} +2 -2
  20. package/dist/{planner-BkGEylgU.d.mts.map → planner-C6vpC6nq.d.mts.map} +1 -1
  21. package/dist/{planner-BRKlBIQL-UpgxpNL9.mjs → planner-D3OjQpHY-B9tIFKaP.mjs} +7 -7
  22. package/dist/{planner-BRKlBIQL-UpgxpNL9.mjs.map → planner-D3OjQpHY-B9tIFKaP.mjs.map} +1 -1
  23. package/dist/{planner-produced-postgres-migration-DYSPvP11-C6kel47a.mjs → planner-produced-postgres-migration-BrmqIRBo-BdMkuPMA.mjs} +4 -4
  24. package/dist/{planner-produced-postgres-migration-DYSPvP11-C6kel47a.mjs.map → planner-produced-postgres-migration-BrmqIRBo-BdMkuPMA.mjs.map} +1 -1
  25. package/dist/{planner-produced-postgres-migration-BwZrjNPg-Ch67sFwK.d.mts → planner-produced-postgres-migration-CoLy4THO-CkCRWsv_.d.mts} +3 -3
  26. package/dist/planner-produced-postgres-migration-CoLy4THO-CkCRWsv_.d.mts.map +1 -0
  27. package/dist/planner-produced-postgres-migration-D7zijd5s.d.mts +1 -0
  28. package/dist/{postgres-migration-Cg6Rwgok--hvAHrSo.mjs → postgres-migration-CSoO3zgR-CV46TdXI.mjs} +32 -11
  29. package/dist/postgres-migration-CSoO3zgR-CV46TdXI.mjs.map +1 -0
  30. package/dist/{postgres-migration-D2Xs7BfD-Df3OpTyw.d.mts → postgres-migration-Dajq9YrO-_sZwyRnK.d.mts} +19 -8
  31. package/dist/postgres-migration-Dajq9YrO-_sZwyRnK.d.mts.map +1 -0
  32. package/dist/{render-ops-DjsYroU7-Nqqlj8co.mjs → render-ops-D1lOuFbE-d95NrYqF.mjs} +3 -3
  33. package/dist/{render-ops-DjsYroU7-Nqqlj8co.mjs.map → render-ops-D1lOuFbE-d95NrYqF.mjs.map} +1 -1
  34. package/dist/target.d.mts +9 -9
  35. package/dist/target.mjs +10 -10
  36. package/dist/target__control.mjs +2 -2
  37. package/dist/target__diff-database-schema.mjs +1 -1
  38. package/dist/target__issue-planner.d.mts +1 -1
  39. package/dist/target__issue-planner.mjs +1 -1
  40. package/dist/target__migration.d.mts +3 -3
  41. package/dist/target__migration.mjs +4 -4
  42. package/dist/target__op-factory-call.d.mts +2 -2
  43. package/dist/target__op-factory-call.mjs +1 -1
  44. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  45. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  46. package/dist/target__planner.d.mts +1 -1
  47. package/dist/target__planner.mjs +2 -2
  48. package/dist/target__render-ops.mjs +1 -1
  49. package/package.json +9 -9
  50. package/dist/migration-D5f4UTR3.d.mts.map +0 -1
  51. package/dist/op-factory-call-BaT4DlIo-BnVxOrwv.d.mts.map +0 -1
  52. package/dist/op-factory-call-BfGiIbUO-BqaxwJhg.mjs.map +0 -1
  53. package/dist/op-factory-call-CwFkWbuo.d.mts +0 -1
  54. package/dist/planner-produced-postgres-migration-BwZrjNPg-Ch67sFwK.d.mts.map +0 -1
  55. package/dist/planner-produced-postgres-migration-eDPWYNBo.d.mts +0 -1
  56. package/dist/postgres-migration-Cg6Rwgok--hvAHrSo.mjs.map +0 -1
  57. package/dist/postgres-migration-D2Xs7BfD-Df3OpTyw.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"diff-database-schema-CByLrBg6-BLLJDUpg.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-CByLrBg6.mjs"],"sourcesContent":["import { s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { i as fullTextIndexDefinitionOf, t as FULL_TEXT_INDEX_TYPE } from \"./full-text-index-definition-D-QC3DO2.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-DIaAgaL6.mjs\";\nimport { t as postgresAccessMethodOf } from \"./index-types-Bdy_UGfY.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Bf_Fhv4v.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { n as renderFullTextIndexDocument } from \"./full-text-search-document-DJd-9K-K.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-b746rtzf.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-DbDoLxrp.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { contractNamespaceToSchemaIR, sqlTypeLookupsOf } from \"@internal/family-sql/control\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\n\t\toperation: policy.operation,\n\t\troles: [...policy.roles],\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\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*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst fullText = fullTextIndexDefinitionOf(i);\n\t\t\t\tif (fullText !== void 0) return new SqlIndexIR({\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: postgresAccessMethodOf(FULL_TEXT_INDEX_TYPE),\n\t\t\t\t\toptions: void 0,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\texpression: renderFullTextIndexDocument(fullText),\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, fullText.weightGroups.flat())\n\t\t\t\t});\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\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) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\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(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\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(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\n}\n/**\n* The Postgres full-tree node diff for the family verify verdict: derive\n* the expected tree (resolved leaf values, 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*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst types = sqlTypeLookupsOf(input.frameworkComponents);\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\tdataTypeLookup: types.dataTypeLookup,\n\t\tcodecLookup: types.codecLookup,\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\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(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\n}\n/**\n* The Postgres planner's diff input: the SAME tree-building\n* `diffPostgresSchema` uses (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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst types = sqlTypeLookupsOf(input.frameworkComponents);\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\tdataTypeLookup: types.dataTypeLookup,\n\t\tcodecLookup: types.codecLookup,\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-CByLrBg6.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;CACD;AACD;AACA,SAAS,cAAc,MAAM;CAC5B,OAAO,CAAC,aAAa,GAAG;EACvB,UAAU,uBAAuB;EACjC,IAAI;CACL,CAAC;AACF;;;;;;;AAOA,SAAS,gBAAgB,aAAa,WAAW,SAAS;CACzD,OAAO,QAAQ,KAAK,WAAW,CAAC,GAAG,eAAe,aAAa,SAAS,GAAG;EAC1E,UAAU,yBAAyB;EACnC,IAAI,UAAU;CACf,CAAC,CAAC;AACH;AACA,SAAS,aAAa,QAAQ,aAAa;CAC1C,OAAO,IAAI,yBAAyB;EACnC,QAAQ,SAAS,OAAO,MAAM,OAAO,MAAM;EAC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AA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"diff-database-schema-CUSXh2y2-CWRGCPL7.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-CUSXh2y2.mjs"],"sourcesContent":["import { s as postgresError } from \"./errors-DYyzTYzE.mjs\";\nimport { i as fullTextIndexDefinitionOf, t as FULL_TEXT_INDEX_TYPE } from \"./full-text-index-definition-D-QC3DO2.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-DIaAgaL6.mjs\";\nimport { t as postgresAccessMethodOf } from \"./index-types-Bdy_UGfY.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Bf_Fhv4v.mjs\";\nimport { a as postgresDiffSubjectGranularity, n as PostgresNativeEnumSchemaNode, r as PostgresSchemaNodeKind, t as PostgresTableSchemaNode } from \"./postgres-table-schema-node-BBkitBQh.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode, t as PostgresRoleSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { n as renderFullTextIndexDocument } from \"./full-text-search-document-DJd-9K-K.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-b746rtzf.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-C5VoaD11.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { contractNamespaceToSchemaIR, sqlTypeLookupsOf } from \"@internal/family-sql/control\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\n//#region src/core/migrations/contract-to-postgres-database-schema-node.ts\n/** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */\nfunction databaseStep() {\n\treturn {\n\t\tnodeKind: PostgresSchemaNodeKind.database,\n\t\tid: \"database\"\n\t};\n}\nfunction tableDependsOn(namespaceId, tableName) {\n\treturn [\n\t\tdatabaseStep(),\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.namespace,\n\t\t\tid: namespaceId\n\t\t},\n\t\t{\n\t\t\tnodeKind: PostgresSchemaNodeKind.table,\n\t\t\tid: tableName\n\t\t}\n\t];\n}\nfunction roleDependsOn(role) {\n\treturn [databaseStep(), {\n\t\tnodeKind: PostgresSchemaNodeKind.role,\n\t\tid: role\n\t}];\n}\n/**\n* The chains from a table-child object (foreign key, index, unique, primary\n* key) to each of the own columns it is built on, in the Postgres tree.\n* Dropping a covered column auto-drops the object, so the object's drop must\n* precede the column's; the graph derives that direction from these edges.\n*/\nfunction columnDependsOn(namespaceId, tableName, columns) {\n\treturn columns.map((column) => [...tableDependsOn(namespaceId, tableName), {\n\t\tnodeKind: RelationalSchemaNodeKind.column,\n\t\tid: `column:${column}`\n\t}]);\n}\nfunction toPolicyNode(policy, namespaceId) {\n\treturn new PostgresPolicySchemaNode({\n\t\tnaming: namingOf(policy.name, policy.prefix),\n\t\ttableName: policy.tableName,\n\t\tnamespaceId,\n\t\toperation: policy.operation,\n\t\troles: [...policy.roles],\n\t\tusing: policy.using,\n\t\twithCheck: policy.withCheck,\n\t\tpermissive: policy.permissive,\n\t\tdependsOn: [tableDependsOn(namespaceId, policy.tableName), ...policy.roles.map(roleDependsOn)]\n\t});\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*/\nfunction contractToPostgresDatabaseSchemaNode(contract, options) {\n\tif (contract === null) return new PostgresDatabaseSchemaNode({\n\t\tnamespaces: {},\n\t\troles: [],\n\t\texistingSchemas: [],\n\t\tpgVersion: \"\"\n\t});\n\tconst namespaces = {};\n\tconst roles = [];\n\tconst ownedSchemas = [];\n\tfor (const ns of Object.values(contract.storage.namespaces)) {\n\t\tif (!isPostgresSchema(ns)) continue;\n\t\tfor (const role of Object.values(ns.role)) roles.push(new PostgresRoleSchemaNode({\n\t\t\tname: role.name,\n\t\t\tnamespaceId: role.namespaceId\n\t\t}));\n\t\tif (ns.id === UNBOUND_NAMESPACE_ID) {\n\t\t\tif (!Object.entries(ns.entries).some(([entriesKey, slot]) => entriesKey !== \"role\" && Object.keys(slot).length > 0)) continue;\n\t\t}\n\t\tconst ddlSchema = resolveDdlSchemaForNamespaceStorage(contract.storage, ns.id);\n\t\townedSchemas.push(ddlSchema);\n\t\tconst sqlTables = contractNamespaceToSchemaIR(contract.storage, ns.id, options).tables;\n\t\tconst policiesByTable = /* @__PURE__ */ new Map();\n\t\tfor (const policy of Object.values(ns.policy)) {\n\t\t\tconst list = policiesByTable.get(policy.tableName) ?? [];\n\t\t\tlist.push(toPolicyNode(policy, ddlSchema));\n\t\t\tpoliciesByTable.set(policy.tableName, list);\n\t\t}\n\t\tconst tables = {};\n\t\tfor (const tableName of Object.keys(ns.table)) {\n\t\t\tconst sqlTable = sqlTables[tableName];\n\t\t\tif (sqlTable === void 0) continue;\n\t\t\tconst foreignKeys = sqlTable.foreignKeys.map((fk) => {\n\t\t\t\tconst resolvedReferencedNamespace = resolveDdlSchemaForNamespaceStorage(contract.storage, fk.referencedSchema ?? UNBOUND_NAMESPACE_ID);\n\t\t\t\treturn new SqlForeignKeyIR({\n\t\t\t\t\tcolumns: fk.columns,\n\t\t\t\t\treferencedTable: fk.referencedTable,\n\t\t\t\t\treferencedColumns: fk.referencedColumns,\n\t\t\t\t\treferencedSchema: fk.referencedSchema ?? UNBOUND_NAMESPACE_ID,\n\t\t\t\t\t...ifDefined(\"name\", fk.name),\n\t\t\t\t\t...ifDefined(\"onDelete\", fk.onDelete),\n\t\t\t\t\t...ifDefined(\"onUpdate\", fk.onUpdate),\n\t\t\t\t\t...ifDefined(\"annotations\", fk.annotations),\n\t\t\t\t\tresolvedReferencedNamespace,\n\t\t\t\t\tdependsOn: [tableDependsOn(resolvedReferencedNamespace, fk.referencedTable), ...columnDependsOn(ddlSchema, tableName, fk.columns)]\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst uniques = sqlTable.uniques.map((u) => new SqlUniqueIR({\n\t\t\t\tcolumns: u.columns,\n\t\t\t\t...ifDefined(\"name\", u.name),\n\t\t\t\t...ifDefined(\"annotations\", u.annotations),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, u.columns)\n\t\t\t}));\n\t\t\tconst indexes = sqlTable.indexes.map((i) => {\n\t\t\t\tconst fullText = fullTextIndexDefinitionOf(i);\n\t\t\t\tif (fullText !== void 0) return new SqlIndexIR({\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: postgresAccessMethodOf(FULL_TEXT_INDEX_TYPE),\n\t\t\t\t\toptions: void 0,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\texpression: renderFullTextIndexDocument(fullText),\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, fullText.weightGroups.flat())\n\t\t\t\t});\n\t\t\t\tconst base = {\n\t\t\t\t\tnaming: namingOf(i.name, i.prefix),\n\t\t\t\t\twhere: i.where,\n\t\t\t\t\tunique: i.unique,\n\t\t\t\t\tpartial: i.partial,\n\t\t\t\t\ttype: i.type,\n\t\t\t\t\toptions: i.options,\n\t\t\t\t\tannotations: i.annotations,\n\t\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, i.columns ?? Object.keys(sqlTable.columns))\n\t\t\t\t};\n\t\t\t\treturn new SqlIndexIR(i.expression !== void 0 ? {\n\t\t\t\t\t...base,\n\t\t\t\t\texpression: i.expression\n\t\t\t\t} : {\n\t\t\t\t\t...base,\n\t\t\t\t\tcolumns: i.columns ?? []\n\t\t\t\t});\n\t\t\t});\n\t\t\tconst primaryKey = sqlTable.primaryKey !== void 0 ? new PrimaryKey({\n\t\t\t\tcolumns: sqlTable.primaryKey.columns,\n\t\t\t\t...ifDefined(\"name\", sqlTable.primaryKey.name),\n\t\t\t\tdependsOn: columnDependsOn(ddlSchema, tableName, sqlTable.primaryKey.columns)\n\t\t\t}) : void 0;\n\t\t\ttables[tableName] = new PostgresTableSchemaNode({\n\t\t\t\tname: sqlTable.name,\n\t\t\t\tcolumns: sqlTable.columns,\n\t\t\t\tforeignKeys,\n\t\t\t\tuniques,\n\t\t\t\tindexes,\n\t\t\t\t...ifDefined(\"primaryKey\", primaryKey),\n\t\t\t\t...ifDefined(\"annotations\", sqlTable.annotations),\n\t\t\t\t...ifDefined(\"checks\", sqlTable.checks),\n\t\t\t\tpolicies: policiesByTable.get(tableName) ?? [],\n\t\t\t\trlsEnabled: Object.hasOwn(ns.rls, tableName)\n\t\t\t});\n\t\t}\n\t\tfor (const [tableName, tablePolicies] of policiesByTable) {\n\t\t\tif (!(tableName in tables)) {\n\t\t\t\tconst policyName = tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyName}\" references table \"${tableName}\" not present in namespace \"${ddlSchema}\"`, { meta: {\n\t\t\t\t\tpolicyName,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-missing\"\n\t\t\t\t} });\n\t\t\t}\n\t\t\tif (!Object.hasOwn(ns.rls, tableName)) {\n\t\t\t\tconst policyLabel = tablePolicies[0]?.prefix ?? tablePolicies[0]?.name ?? \"(unknown)\";\n\t\t\t\tthrow postgresError(\"CONTRACT.POLICY_INVALID\", `contract-to-postgres-database-schema-node: policy \"${policyLabel}\" targets table \"${tableName}\" in namespace \"${ddlSchema}\", which is not RLS-controlled. Mark the model with @@rls (entries.rls[\"${tableName}\"]) or remove the policy.`, { meta: {\n\t\t\t\t\tpolicyName: policyLabel,\n\t\t\t\t\ttableName,\n\t\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\t\treason: \"table-not-rls-controlled\"\n\t\t\t\t} });\n\t\t\t}\n\t\t}\n\t\tnamespaces[ddlSchema] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlSchema,\n\t\t\ttables,\n\t\t\tnativeEnums: Object.values(ns.entries.native_enum ?? {}).map((entity) => new PostgresNativeEnumSchemaNode({\n\t\t\t\ttypeName: entity.typeName,\n\t\t\t\tnamespaceId: ddlSchema,\n\t\t\t\tmembers: entity.members,\n\t\t\t\t...ifDefined(\"control\", entity.control)\n\t\t\t}))\n\t\t});\n\t}\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles,\n\t\texistingSchemas: ownedSchemas,\n\t\tpgVersion: \"\"\n\t});\n}\n//#endregion\n//#region src/core/migrations/diff-database-schema.ts\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) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && nodeNamespaceId(node) === UNBOUND_NAMESPACE_ID;\n}\nfunction nodeNamespaceId(node) {\n\tif (!Object.hasOwn(node, \"namespaceId\")) return void 0;\n\treturn blindCast(node).namespaceId;\n}\nfunction ownedSchemaNames(expected) {\n\tconst policyNamespaces = Object.values(expected.namespaces).flatMap((ns) => Object.values(ns.tables).flatMap((t) => t.policies.map((p) => p.namespaceId)));\n\treturn /* @__PURE__ */ new Set([...policyNamespaces, ...expected.existingSchemas]);\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(expected) {\n\tconst namespaces = Object.fromEntries(Object.entries(expected.namespaces).filter(([, ns]) => Object.keys(ns.tables).length > 0));\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...expected.roles],\n\t\texistingSchemas: expected.existingSchemas.filter((s) => namespaces[s] !== void 0),\n\t\tpgVersion: expected.pgVersion\n\t});\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(issue, contract) {\n\treturn resolvePostgresNodeIssueControlPolicySubject(blindCast(issue), contract)?.explicitNodeControlPolicy;\n}\n/**\n* The Postgres full-tree node diff for the family verify verdict: derive\n* the expected tree (resolved leaf values, 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*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst types = sqlTypeLookupsOf(input.frameworkComponents);\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\tdataTypeLookup: types.dataTypeLookup,\n\t\tcodecLookup: types.codecLookup,\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\tissues: diffSchemas(expected, actual).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t}),\n\t\tresolveControlPolicy: (issue) => resolveControlPolicy(issue, postgresContract),\n\t\tnamespacePairs: Object.values(expected.namespaces).map((ns) => ({ actual: actual.namespaces[ns.schemaName] }))\n\t};\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(expected, actual) {\n\tconst namespaces = { ...actual.namespaces };\n\tlet padded = false;\n\tfor (const schemaName of Object.keys(expected.namespaces)) if (namespaces[schemaName] === void 0) {\n\t\tnamespaces[schemaName] = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName,\n\t\t\ttables: {}\n\t\t});\n\t\tpadded = true;\n\t}\n\tif (!padded) return actual;\n\treturn new PostgresDatabaseSchemaNode({\n\t\tnamespaces,\n\t\troles: [...actual.roles],\n\t\texistingSchemas: [...actual.existingSchemas],\n\t\tpgVersion: actual.pgVersion\n\t});\n}\n/**\n* The Postgres planner's diff input: the SAME tree-building\n* `diffPostgresSchema` uses (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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst types = sqlTypeLookupsOf(input.frameworkComponents);\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\tdataTypeLookup: types.dataTypeLookup,\n\t\tcodecLookup: types.codecLookup,\n\t\tresolveDefault: postgresResolveDefault\n\t});\n\tconst expected = pruneTableLessNamespaces(fullExpected);\n\tconst paddedActual = padActualNamespaces(expected, actual);\n\tconst relationalOwned = ownedSchemaNames(expected);\n\tconst structuralOwned = ownedSchemaNames(fullExpected);\n\treturn {\n\t\texpected,\n\t\tactual: paddedActual,\n\t\tissues: blindCast(diffSchemas(expected, paddedActual)).filter((issue) => {\n\t\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\t\tif (isClusterScopedIssue(issue)) return true;\n\t\t\tconst granularity = classifyDiffSubjectGranularity(issue, postgresDiffSubjectGranularity);\n\t\t\tconst namespaceSegment = issue.path[1];\n\t\t\tif (namespaceSegment === void 0) return true;\n\t\t\treturn (granularity === \"structural\" ? structuralOwned : relationalOwned).has(namespaceSegment);\n\t\t})\n\t};\n}\n//#endregion\nexport { diffPostgresSchema as n, contractToPostgresDatabaseSchemaNode as r, buildPostgresPlanDiff as t };\n\n//# sourceMappingURL=diff-database-schema-CUSXh2y2.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,eAAe;CACvB,OAAO;EACN,UAAU,uBAAuB;EACjC,IAAI;CACL;AACD;AACA,SAAS,eAAe,aAAa,WAAW;CAC/C,OAAO;EACN,aAAa;EACb;GACC,UAAU,uBAAuB;GACjC,IAAI;EACL;EACA;GACC,UAAU,uBAAuB;GACjC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;CACzD,MAAM,kBAAkB,iBAAiB,QAAQ;CACjD,MAAM,kBAAkB,iBAAiB,YAAY;CACrD,OAAO;EACN;EACA,QAAQ;EACR,QAAQ,UAAU,YAAY,UAAU,YAAY,CAAC,CAAC,CAAC,QAAQ,UAAU;GACxE,IAAI,aAAa,KAAK,MAAM,gBAAgB,OAAO;GACnD,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,MAAM,cAAc,+BAA+B,OAAO,8BAA8B;GACxF,MAAM,mBAAmB,MAAM,KAAK;GACpC,IAAI,qBAAqB,KAAK,GAAG,OAAO;GACxC,QAAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
@@ -1,4 +1,4 @@
1
- import { M as PostgresOpFactoryCall } from "./op-factory-call-BaT4DlIo-BnVxOrwv.mjs";
1
+ import { M as PostgresOpFactoryCall } from "./op-factory-call-DF9ijUbg-CSF8ZhJM.mjs";
2
2
  import { SqlTypeLookups } from "@prisma/orm-family-sql/contract/data-type";
3
3
  import { SqlStorage, StorageTypeInstance } from "@prisma/orm-family-sql/contract/types";
4
4
  import { DiffableNode, SchemaDiffIssue } from "@prisma/orm-framework/components/control";
@@ -107,4 +107,4 @@ interface IssuePlannerOptions {
107
107
  declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
108
108
  //#endregion
109
109
  export { planIssues as n, coalesceSubtreeIssues as t };
110
- //# sourceMappingURL=issue-planner-BwcfQagl.d.mts.map
110
+ //# sourceMappingURL=issue-planner-BLOtwO3z.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issue-planner-BwcfQagl.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAmBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;WACtC,QAAQ;WACR,QAAQ;WACR,qBAAqB,cAAc;;;;;;;;;KASzC,yBAAyB,iBAAiB,mBAAmB,SAAS;EACzE;EACA,iBAAiB;EACjB,gBAAgB;;;;;;;;EAQhB;;EAEA;;;;UAIQ;WACC,gBAAgB;;;;;;;;;;;iBAWV,sBAAsB,cAAc,eAAe,cAAc,iBAAiB,gBAAgB,oBAAoB,gBAAgB;UAC7I;WACC,iBAAiB;WACjB,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;;;;;;;;WAQtC,SAAS;;;;;;WAMT,SAAS;;;;;WAKT,sBAAsB,cAAc;WACpC,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
1
+ {"version":3,"file":"issue-planner-BLOtwO3z.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;UAmBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;WACtC,QAAQ;WACR,QAAQ;WACR,qBAAqB,cAAc;;;;;;;;;KASzC,yBAAyB,iBAAiB,mBAAmB,SAAS;EACzE;EACA,iBAAiB;EACjB,gBAAgB;;;;;;;;EAQhB;;EAEA;;;;UAIQ;WACC,gBAAgB;;;;;;;;;;;iBAWV,sBAAsB,cAAc,eAAe,cAAc,iBAAiB,gBAAgB,oBAAoB,gBAAgB;UAC7I;WACC,iBAAiB;WACjB,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;;;;;;;;WAQtC,SAAS;;;;;;WAMT,SAAS;;;;;WAKT,sBAAsB,cAAc;WACpC,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
@@ -1,4 +1,5 @@
1
1
  import { checkExpression, col as col$1, fn as fn$1, foreignKey, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
2
+ import { sql } from "@prisma/orm-family-sql/contract/sql-expression";
2
3
  import { placeholder } from "@prisma/orm-framework/errors/migration";
3
4
  import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
4
5
  //#region ../../../3-targets/3-targets/postgres/dist/migration.mjs
@@ -16,6 +17,6 @@ function rawSql(op) {
16
17
  return op;
17
18
  }
18
19
  //#endregion
19
- export { foreignKey as a, primaryKey as c, fn$1 as i, rawSql as l, checkExpression as n, lit$1 as o, col$1 as r, placeholder as s, MigrationCLI as t, unique as u };
20
+ export { foreignKey as a, primaryKey as c, unique as d, fn$1 as i, rawSql as l, checkExpression as n, lit$1 as o, col$1 as r, placeholder as s, MigrationCLI as t, sql as u };
20
21
 
21
- //# sourceMappingURL=migration-PTHAY9Cv.mjs.map
22
+ //# sourceMappingURL=migration-C9ZH26Nj.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-PTHAY9Cv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { V as createExtension } from \"./op-factory-call-BfGiIbUO.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-Cg6Rwgok.mjs\";\nimport { t as dataTransform } from \"./data-transform-Bo32KRbq.mjs\";\nimport { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from \"@internal/sql-relational-core/contract-free\";\nimport { placeholder } from \"@internal/errors/migration\";\nimport { MigrationCLI } from \"@internal/cli/migration-cli\";\n//#region src/core/migrations/operations/raw.ts\n/**\n* Identity factory for an already-materialized `SqlMigrationPlanOperation`.\n*\n* The planner uses this via `liftOpToCall` to carry ops produced by SQL\n* family methods, codec control hooks, and component database dependencies\n* alongside migration IR without reverse-engineering them. Users writing\n* raw migrations can pass a full op shape directly — typically built by\n* composing SQL family helpers — to author a migration that bypasses the\n* structured call classes.\n*/\nfunction rawSql(op) {\n\treturn op;\n}\n//#endregion\nexport { PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, unique };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;;;;;;;AAiBA,SAAS,OAAO,IAAI;CACnB,OAAO;AACR"}
1
+ {"version":3,"file":"migration-C9ZH26Nj.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { V as createExtension } from \"./op-factory-call-DiwaNQVO.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-CSoO3zgR.mjs\";\nimport { t as dataTransform } from \"./data-transform-Bo32KRbq.mjs\";\nimport { sql } from \"@internal/sql-contract/sql-expression\";\nimport { checkExpression, col, fn, foreignKey, lit, primaryKey, unique } from \"@internal/sql-relational-core/contract-free\";\nimport { placeholder } from \"@internal/errors/migration\";\nimport { MigrationCLI } from \"@internal/cli/migration-cli\";\n//#region src/core/migrations/operations/raw.ts\n/**\n* Identity factory for an already-materialized `SqlMigrationPlanOperation`.\n*\n* The planner uses this via `liftOpToCall` to carry ops produced by SQL\n* family methods, codec control hooks, and component database dependencies\n* alongside migration IR without reverse-engineering them. Users writing\n* raw migrations can pass a full op shape directly — typically built by\n* composing SQL family helpers — to author a migration that bypasses the\n* structured call classes.\n*/\nfunction rawSql(op) {\n\treturn op;\n}\n//#endregion\nexport { PostgresMigration as Migration, MigrationCLI, checkExpression, col, createExtension, dataTransform, fn, foreignKey, lit, placeholder, primaryKey, rawSql, sql, unique };\n\n//# sourceMappingURL=migration.mjs.map"],"mappings":";;;;;;;;;;;;;;;AAkBA,SAAS,OAAO,IAAI;CACnB,OAAO;AACR"}
@@ -1,7 +1,8 @@
1
1
  import "./data-transform-Ck5FbyNO-BNE7QlAo.mjs";
2
- import { j as Op$1 } from "./op-factory-call-BaT4DlIo-BnVxOrwv.mjs";
3
- import "./postgres-migration-D2Xs7BfD-Df3OpTyw.mjs";
2
+ import { j as Op$1 } from "./op-factory-call-DF9ijUbg-CSF8ZhJM.mjs";
3
+ import "./postgres-migration-Dajq9YrO-_sZwyRnK.mjs";
4
4
  import { checkExpression, col as col$1, fn as fn$1, foreignKey, lit as lit$1, primaryKey, unique } from "@prisma/orm-family-sql/relational-core/contract-free";
5
+ import { sql } from "@prisma/orm-family-sql/contract/sql-expression";
5
6
  import { placeholder } from "@prisma/orm-framework/errors/migration";
6
7
  import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
7
8
  //#region ../../../3-targets/3-targets/postgres/dist/migration.d.mts
@@ -21,5 +22,5 @@ declare function createExtension(extensionName: string): Op$1;
21
22
  */
22
23
  declare function rawSql(op: Op$1): Op$1;
23
24
  //#endregion
24
- export { fn$1 as a, placeholder as c, unique as d, createExtension as i, primaryKey as l, checkExpression as n, foreignKey as o, col$1 as r, lit$1 as s, MigrationCLI as t, rawSql as u };
25
- //# sourceMappingURL=migration-D5f4UTR3.d.mts.map
25
+ export { fn$1 as a, placeholder as c, sql as d, unique as f, createExtension as i, primaryKey as l, checkExpression as n, foreignKey as o, col$1 as r, lit$1 as s, MigrationCLI as t, rawSql as u };
26
+ //# sourceMappingURL=migration-CQeS0oqg.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migration-CQeS0oqg.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;;iBASiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,OAAK"}
@@ -0,0 +1 @@
1
+ import "./op-factory-call-DF9ijUbg-CSF8ZhJM.mjs";
@@ -9,7 +9,7 @@ import { MigrationOperationClass, OpFactoryCall } from "@prisma/orm-framework/co
9
9
  import { SqlMigrationPlanOperation } from "@prisma/orm-family-sql/family/control";
10
10
  import { ImportRequirement, TsExpression } from "@prisma/orm-framework/ts-render";
11
11
  import { ExecuteRequestLowerer, Lowerer } from "@prisma/orm-family-sql/family/control-adapter";
12
- //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-BaT4DlIo.d.mts
12
+ //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-DF9ijUbg.d.mts
13
13
  //#region src/core/migrations/operations/shared.d.ts
14
14
  type Op$1 = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
15
15
  /**
@@ -62,6 +62,7 @@ declare abstract class PostgresOpFactoryCallNode extends TsExpression implements
62
62
  protected freeze(): void;
63
63
  }
64
64
  declare class CreateTableCall extends PostgresOpFactoryCallNode {
65
+ #private;
65
66
  readonly factoryName: "createTable";
66
67
  readonly operationClass: "additive";
67
68
  readonly schemaName: string;
@@ -107,6 +108,7 @@ declare class RenameTableCall extends PostgresOpFactoryCallNode {
107
108
  importRequirements(): readonly ImportRequirement[];
108
109
  }
109
110
  declare class AddColumnCall extends PostgresOpFactoryCallNode {
111
+ #private;
110
112
  readonly factoryName: "addColumn";
111
113
  readonly operationClass: "additive";
112
114
  readonly schemaName: string;
@@ -194,6 +196,7 @@ declare class DropNotNullCall extends PostgresOpFactoryCallNode {
194
196
  importRequirements(): readonly ImportRequirement[];
195
197
  }
196
198
  declare class SetDefaultCall extends PostgresOpFactoryCallNode {
199
+ #private;
197
200
  readonly factoryName: "setDefault";
198
201
  readonly operationClass: 'additive' | 'widening';
199
202
  readonly schemaName: string;
@@ -337,6 +340,7 @@ declare class RenameConstraintCall extends PostgresOpFactoryCallNode {
337
340
  importRequirements(): readonly ImportRequirement[];
338
341
  }
339
342
  declare class AddCheckConstraintCall extends PostgresOpFactoryCallNode {
343
+ #private;
340
344
  readonly factoryName: "addCheckConstraint";
341
345
  readonly operationClass: "additive";
342
346
  readonly schemaName: string;
@@ -363,6 +367,7 @@ declare class DropCheckConstraintCall extends PostgresOpFactoryCallNode {
363
367
  importRequirements(): readonly ImportRequirement[];
364
368
  }
365
369
  declare class CreateIndexCall extends PostgresOpFactoryCallNode {
370
+ #private;
366
371
  readonly factoryName: "createIndex";
367
372
  readonly operationClass: "additive";
368
373
  readonly schemaName: string;
@@ -513,6 +518,7 @@ declare class DataTransformCall extends PostgresOpFactoryCallNode {
513
518
  importRequirements(): readonly ImportRequirement[];
514
519
  }
515
520
  declare class CreatePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
521
+ #private;
516
522
  readonly factoryName: "createRlsPolicy";
517
523
  readonly operationClass: "additive";
518
524
  readonly schemaName: string;
@@ -574,4 +580,4 @@ declare class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
574
580
  type PostgresOpFactoryCall = CreateTableCall | DropTableCall | RenameTableCall | AddColumnCall | RenameColumnCall | DropColumnCall | AlterColumnTypeCall | SetNotNullCall | DropNotNullCall | SetDefaultCall | DropDefaultCall | AddNotNullColumnDirectCall | AddNotNullColumnWithTempDefaultCall | AddPrimaryKeyCall | AddForeignKeyCall | AddUniqueCall | AddCheckConstraintCall | RenameConstraintCall | DropCheckConstraintCall | CreateIndexCall | RenameIndexCall | DropIndexCall | DropConstraintCall | RawSqlCall | CreateExtensionCall | CreateSchemaCall | CreateNativeEnumTypeCall | DropNativeEnumTypeCall | AddNativeEnumValueCall | CreatePostgresRlsPolicyCall | DropPostgresRlsPolicyCall | EnableRowLevelSecurityCall | DisableRowLevelSecurityCall | RenamePostgresRlsPolicyCall | DataTransformCall;
575
581
  //#endregion
576
582
  export { ForeignKeySpec as A, SetDefaultCall as B, DropDefaultCall as C, DropPostgresRlsPolicyCall as D, DropNotNullCall as E, RenameColumnCall as F, RenameConstraintCall as I, RenameIndexCall as L, PostgresOpFactoryCall as M, RawSqlCall as N, DropTableCall as O, RenamableConstraintKind as P, RenamePostgresRlsPolicyCall as R, DropConstraintCall as S, DropNativeEnumTypeCall as T, SetNotNullCall as V, CreateTableCall as _, AddNotNullColumnWithTempDefaultCall as a, DropCheckConstraintCall as b, AlterColumnTypeCall as c, CreateExtensionCall as d, CreateIndexCall as f, CreateSchemaCall as g, CreatePostgresRlsPolicyCall as h, AddNativeEnumValueCall as i, Op$1 as j, EnableRowLevelSecurityCall as k, AlterColumnTypeClass as l, CreateNativeEnumTypeCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateIndexExtras as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, AlterColumnTypeOptions as u, DataTransformCall as v, DropIndexCall as w, DropColumnCall as x, DisableRowLevelSecurityCall as y, RenameTableCall as z };
577
- //# sourceMappingURL=op-factory-call-BaT4DlIo-BnVxOrwv.d.mts.map
583
+ //# sourceMappingURL=op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op-factory-call-DF9ijUbg-CSF8ZhJM.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/op-factory-call-DF9ijUbg.d.mts"],"mappings":";;;;;;;;;;;;;KAYK,OAAO,0BAA0B;;;;;;UAM5B;WACC;WACA;WACA;aACE;aACA;aACA;;WAEF,WAAW;WACX,WAAW;;;;;KAKjB;;;KAGA;;;UAGK;WACC;WACA,UAAU;;;;;;WAMV;WACA;;;;KAIN,KAAK,0BAA0B;uBACb,kCAAkC,wBAAwB;oBAC7D;oBACA,gBAAgB;oBAChB;WACT,KAAK,UAAU,UAAU,KAAK,QAAQ;;EAE/C,MAAM,UAAU,kCAAkC,KAAK,QAAQ;EAC/D,+BAA+B;YACrB;;cAEE,wBAAwB;;WAE3B;WACA;WACA;WACA;WACA,kBAAkB;WAClB,sBAAsB;WACtB;EACT,YAAY,oBAAoB,mBAAmB,kBAAkB,aAAa,uBAAuB;EACzG,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;cAEnB,sBAAsB;WACzB;WACA;WACA;WACA;WACA;EACT,YAAY,oBAAoB;EAChC,KAAK,UAAU,wBAAwB,QAAQ;EAC/C;EACA,+BAA+B;;;KAG5B,sBAAsB,uBAAuB;cACpC,wBAAwB;WAC3B;WACA;WACA;WACA;;WAEA;WACA;;;;;WA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qBAAqB,aAAa,sBAAsB,mBAAmB,2BAA2B,yBAAyB,yBAAyB,8BAA8B,4BAA4B,6BAA6B,8BAA8B,8BAA8B"}
@@ -11,11 +11,12 @@ import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
11
11
  import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
12
12
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
13
13
  import { col } from "@prisma/orm-family-sql/relational-core/contract-free";
14
+ import { createSqlTextSources } from "@prisma/orm-family-sql/family/control";
14
15
  import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
15
16
  import { unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
16
- import { TsExpression, jsonToTsSource, tsObjectSource, tsQuotedTextSource } from "@prisma/orm-framework/ts-render";
17
+ import { TsExpression, jsonToTsSource, tsObjectSource } from "@prisma/orm-framework/ts-render";
17
18
  import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
18
- //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-BfGiIbUO.mjs
19
+ //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-DiwaNQVO.mjs
19
20
  /**
20
21
  * Maps a planner schema name to the contract-free DDL builder's optional
21
22
  * `schema` field: the unbound sentinel becomes `undefined` (the builder omits
@@ -975,21 +976,21 @@ function postgresDefaultToDdlColumnDefault(columnDefault) {
975
976
  }
976
977
  }
977
978
  }
978
- function renderDdlColumnDefault(def) {
979
+ function renderDdlColumnDefault(def, sql) {
979
980
  if (!def) return "";
980
981
  if (def.kind === "literal") return `lit(${jsonToTsSource(def.value)})`;
981
- return `fn(${tsQuotedTextSource(def.expression.text)})`;
982
+ return `fn(${sql.source(def.expression.text)})`;
982
983
  }
983
- function renderDdlColumnAsTsCall(col) {
984
+ function renderDdlColumnAsTsCall(col, sql) {
984
985
  const opts = [];
985
986
  if (col.notNull) opts.push("notNull: true");
986
987
  if (col.primaryKey) opts.push("primaryKey: true");
987
- if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default)}`);
988
+ if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default, sql)}`);
988
989
  if (col.codecRef) opts.push(`codecRef: ${jsonToTsSource(col.codecRef)}`);
989
990
  const optsStr = opts.length > 0 ? `, { ${opts.join(", ")} }` : "";
990
991
  return `col(${jsonToTsSource(col.name)}, ${jsonToTsSource(col.type)}${optsStr})`;
991
992
  }
992
- function renderDdlConstraintAsTsCall(constraint) {
993
+ function renderDdlConstraintAsTsCall(constraint, sql) {
993
994
  switch (constraint.kind) {
994
995
  case "primary-key": {
995
996
  const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
@@ -1007,7 +1008,7 @@ function renderDdlConstraintAsTsCall(constraint) {
1007
1008
  const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : "";
1008
1009
  return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;
1009
1010
  }
1010
- case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${tsQuotedTextSource(constraint.expression.text)})`;
1011
+ case "check-expression": return `checkExpression(${jsonToTsSource(constraint.name)}, ${sql.source(constraint.expression.text)})`;
1011
1012
  }
1012
1013
  }
1013
1014
  function needsColOrConstraintImport(columns) {
@@ -1075,14 +1076,21 @@ var CreateTableCall = class extends PostgresOpFactoryCallNode {
1075
1076
  };
1076
1077
  }
1077
1078
  renderTypeScript() {
1078
- const columnsList = this.columns.map(renderDdlColumnAsTsCall).join(", ");
1079
- const constraintsList = this.constraints ? this.constraints.map(renderDdlConstraintAsTsCall).join(", ") : void 0;
1079
+ return this.#written().source;
1080
+ }
1081
+ #written() {
1082
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
1083
+ const columnsList = this.columns.map((column) => renderDdlColumnAsTsCall(column, sql)).join(", ");
1084
+ const constraintsList = this.constraints ? this.constraints.map((constraint) => renderDdlConstraintAsTsCall(constraint, sql)).join(", ") : void 0;
1080
1085
  const opts = [];
1081
1086
  if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
1082
1087
  opts.push(`table: ${jsonToTsSource(this.tableName)}`);
1083
1088
  opts.push(`columns: [${columnsList}]`);
1084
1089
  if (constraintsList) opts.push(`constraints: [${constraintsList}]`);
1085
- return `this.createTable({ ${opts.join(", ")} })`;
1090
+ return {
1091
+ source: `this.createTable({ ${opts.join(", ")} })`,
1092
+ imports: sql.imports()
1093
+ };
1086
1094
  }
1087
1095
  importRequirements() {
1088
1096
  const req = [];
@@ -1100,6 +1108,7 @@ var CreateTableCall = class extends PostgresOpFactoryCallNode {
1100
1108
  moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1101
1109
  symbol: sym
1102
1110
  });
1111
+ req.push(...this.#written().imports);
1103
1112
  return req;
1104
1113
  }
1105
1114
  };
@@ -1214,11 +1223,18 @@ var AddColumnCall = class extends PostgresOpFactoryCallNode {
1214
1223
  };
1215
1224
  }
1216
1225
  renderTypeScript() {
1226
+ return this.#written().source;
1227
+ }
1228
+ #written() {
1229
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
1217
1230
  const opts = [];
1218
1231
  if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
1219
1232
  opts.push(`table: ${jsonToTsSource(this.tableName)}`);
1220
- opts.push(`column: ${renderDdlColumnAsTsCall(this.column)}`);
1221
- return `this.addColumn({ ${opts.join(", ")} })`;
1233
+ opts.push(`column: ${renderDdlColumnAsTsCall(this.column, sql)}`);
1234
+ return {
1235
+ source: `this.addColumn({ ${opts.join(", ")} })`,
1236
+ imports: sql.imports()
1237
+ };
1222
1238
  }
1223
1239
  importRequirements() {
1224
1240
  const req = [{
@@ -1229,6 +1245,7 @@ var AddColumnCall = class extends PostgresOpFactoryCallNode {
1229
1245
  moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1230
1246
  symbol: sym
1231
1247
  });
1248
+ req.push(...this.#written().imports);
1232
1249
  return req;
1233
1250
  }
1234
1251
  };
@@ -1422,21 +1439,32 @@ var SetDefaultCall = class extends PostgresOpFactoryCallNode {
1422
1439
  return setDefault(this.schemaName, this.tableName, this.column, lowerer, this.operationClass);
1423
1440
  }
1424
1441
  renderTypeScript() {
1442
+ return this.#written().source;
1443
+ }
1444
+ #written() {
1445
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
1425
1446
  const opts = [];
1426
1447
  if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
1427
1448
  opts.push(`table: ${jsonToTsSource(this.tableName)}`);
1428
- opts.push(`column: ${renderDdlColumnAsTsCall(this.column)}`);
1449
+ opts.push(`column: ${renderDdlColumnAsTsCall(this.column, sql)}`);
1429
1450
  if (this.operationClass !== "additive") opts.push(`operationClass: ${jsonToTsSource(this.operationClass)}`);
1430
- return `this.setDefault({ ${opts.join(", ")} })`;
1451
+ return {
1452
+ source: `this.setDefault({ ${opts.join(", ")} })`,
1453
+ imports: sql.imports()
1454
+ };
1431
1455
  }
1432
1456
  importRequirements() {
1433
- return [{
1434
- moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1435
- symbol: "col"
1436
- }, ...defaultImportSymbols([this.column]).map((symbol) => ({
1437
- moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1438
- symbol
1439
- }))];
1457
+ return [
1458
+ {
1459
+ moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1460
+ symbol: "col"
1461
+ },
1462
+ ...defaultImportSymbols([this.column]).map((symbol) => ({
1463
+ moduleSpecifier: POSTGRES_MIGRATION_FACADE,
1464
+ symbol
1465
+ })),
1466
+ ...this.#written().imports
1467
+ ];
1440
1468
  }
1441
1469
  };
1442
1470
  var DropDefaultCall = class extends PostgresOpFactoryCallNode {
@@ -1742,10 +1770,17 @@ var AddCheckConstraintCall = class extends PostgresOpFactoryCallNode {
1742
1770
  return addCheckConstraint(this.schemaName, this.tableName, this.constraintName, this.expression, lowerer);
1743
1771
  }
1744
1772
  renderTypeScript() {
1745
- return `this.addCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, expression: ${tsQuotedTextSource(this.expression)} })`;
1773
+ return this.#written().source;
1746
1774
  }
1747
1775
  importRequirements() {
1748
- return [];
1776
+ return this.#written().imports;
1777
+ }
1778
+ #written() {
1779
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
1780
+ return {
1781
+ source: `this.addCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, expression: ${sql.source(this.expression)} })`,
1782
+ imports: sql.imports()
1783
+ };
1749
1784
  }
1750
1785
  };
1751
1786
  var DropCheckConstraintCall = class extends PostgresOpFactoryCallNode {
@@ -1813,24 +1848,31 @@ var CreateIndexCall = class extends PostgresOpFactoryCallNode {
1813
1848
  return createIndex(this.schemaName, this.tableName, this.indexName, this.columns !== void 0 ? { columns: this.columns } : { expression: this.expression ?? "" }, lowerer, extras);
1814
1849
  }
1815
1850
  renderTypeScript() {
1851
+ return this.#written().source;
1852
+ }
1853
+ importRequirements() {
1854
+ return this.#written().imports;
1855
+ }
1856
+ #written() {
1857
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
1816
1858
  const opts = [];
1817
1859
  if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
1818
1860
  opts.push(`table: ${jsonToTsSource(this.tableName)}`);
1819
1861
  opts.push(`index: ${jsonToTsSource(this.indexName)}`);
1820
1862
  if (this.columns !== void 0) opts.push(`columns: ${jsonToTsSource(this.columns)}`);
1821
- else opts.push(`expression: ${tsQuotedTextSource(this.expression ?? "")}`);
1863
+ else opts.push(`expression: ${sql.source(this.expression ?? "")}`);
1822
1864
  if (this.indexType !== void 0 || this.options !== void 0 || this.where !== void 0 || this.unique) {
1823
1865
  const extrasParts = [];
1824
1866
  if (this.indexType !== void 0) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);
1825
1867
  if (this.options !== void 0) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);
1826
- if (this.where !== void 0) extrasParts.push(`where: ${tsQuotedTextSource(this.where)}`);
1868
+ if (this.where !== void 0) extrasParts.push(`where: ${sql.source(this.where)}`);
1827
1869
  if (this.unique) extrasParts.push("unique: true");
1828
1870
  opts.push(`extras: { ${extrasParts.join(", ")} }`);
1829
1871
  }
1830
- return `this.createIndex({ ${opts.join(", ")} })`;
1831
- }
1832
- importRequirements() {
1833
- return [];
1872
+ return {
1873
+ source: `this.createIndex({ ${opts.join(", ")} })`,
1874
+ imports: sql.imports()
1875
+ };
1834
1876
  }
1835
1877
  };
1836
1878
  var RenameIndexCall = class extends PostgresOpFactoryCallNode {
@@ -2168,6 +2210,13 @@ var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
2168
2210
  return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);
2169
2211
  }
2170
2212
  renderTypeScript() {
2213
+ return this.#written().source;
2214
+ }
2215
+ importRequirements() {
2216
+ return this.#written().imports;
2217
+ }
2218
+ #written() {
2219
+ const sql = createSqlTextSources(POSTGRES_MIGRATION_FACADE);
2171
2220
  const p = this.policy;
2172
2221
  const input = {
2173
2222
  naming: namingOf(p.name, p.prefix),
@@ -2185,15 +2234,15 @@ var CreatePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
2185
2234
  namespaceId: jsonToTsSource(input.namespaceId),
2186
2235
  operation: jsonToTsSource(input.operation),
2187
2236
  roles: jsonToTsSource(input.roles),
2188
- using: input.using === void 0 ? void 0 : tsQuotedTextSource(input.using),
2189
- withCheck: input.withCheck === void 0 ? void 0 : tsQuotedTextSource(input.withCheck),
2237
+ using: input.using === void 0 ? void 0 : sql.source(input.using),
2238
+ withCheck: input.withCheck === void 0 ? void 0 : sql.source(input.withCheck),
2190
2239
  permissive: jsonToTsSource(input.permissive)
2191
2240
  };
2192
2241
  const policy = tsObjectSource(Object.entries(sources).flatMap(([key, source]) => source === void 0 ? [] : [[key, source]]));
2193
- return `this.createRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${policy} })`;
2194
- }
2195
- importRequirements() {
2196
- return [];
2242
+ return {
2243
+ source: `this.createRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${policy} })`,
2244
+ imports: sql.imports()
2245
+ };
2197
2246
  }
2198
2247
  };
2199
2248
  var DropPostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
@@ -2306,4 +2355,4 @@ function columnNameOfCall(call) {
2306
2355
  //#endregion
2307
2356
  export { RenameConstraintCall as A, isPostgresOpFactoryCall as B, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, SetNotNullCall as F, renameTableStatement as H, buildTargetDetails as I, columnNameOfCall as L, RenamePostgresRlsPolicyCall as M, RenameTableCall as N, RawSqlCall as O, SetDefaultCall as P, createExtension as R, DropIndexCall as S, DropPostgresRlsPolicyCall as T, postgresDefaultToDdlColumnDefault as V, 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, RenameIndexCall as j, RenameColumnCall 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, installExtension as z };
2308
2357
 
2309
- //# sourceMappingURL=op-factory-call-BfGiIbUO-BqaxwJhg.mjs.map
2358
+ //# sourceMappingURL=op-factory-call-DiwaNQVO-NSekrcmI.mjs.map