@prisma/orm-target-postgres 8.0.0-rc.1-dev.3 → 8.0.0-rc.1-dev.5

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 (134) hide show
  1. package/dist/{adapter-Ddgpoq1S-D-Ftx9Ls.mjs → adapter-Ddgpoq1S-C7ylX0yv.mjs} +3 -3
  2. package/dist/{adapter-Ddgpoq1S-D-Ftx9Ls.mjs.map → adapter-Ddgpoq1S-C7ylX0yv.mjs.map} +1 -1
  3. package/dist/adapter.mjs +4 -4
  4. package/dist/adapter__adapter.mjs +1 -1
  5. package/dist/adapter__column-types.mjs +1 -1
  6. package/dist/adapter__control.mjs +2 -2
  7. package/dist/adapter__runtime.mjs +4 -4
  8. package/dist/adapter__sql-renderer.mjs +1 -1
  9. package/dist/{aggregates-ftUgi-eC.mjs → aggregates-BmF5h9ht.mjs} +6 -2
  10. package/dist/aggregates-BmF5h9ht.mjs.map +1 -0
  11. package/dist/{authoring-03FwIL2k-kPjZAp3s.mjs → authoring-bh6W1Fe5-D__Gfc6K.mjs} +27 -11
  12. package/dist/authoring-bh6W1Fe5-D__Gfc6K.mjs.map +1 -0
  13. package/dist/{codec-ids-CsOU3xDv-mPI0INiF.d.mts → codec-ids-Bqu_IwO0-DKOdPizQ.d.mts} +5 -3
  14. package/dist/codec-ids-Bqu_IwO0-DKOdPizQ.d.mts.map +1 -0
  15. package/dist/{codec-ids-tX7Svtz--BuOfRaVU.mjs → codec-ids-C5Rkltkw-DMf87l9s.mjs} +5 -3
  16. package/dist/codec-ids-C5Rkltkw-DMf87l9s.mjs.map +1 -0
  17. package/dist/codec-ids-DJ6j6pZc.d.mts +1 -0
  18. package/dist/{codec-types-mWhnDEAf-CAQzGFnF.d.mts → codec-types-BRU4F-7t-BaJbKF_i.d.mts} +5 -3
  19. package/dist/codec-types-BRU4F-7t-BaJbKF_i.d.mts.map +1 -0
  20. package/dist/codec-types-bX63JRLf.d.mts +2 -0
  21. package/dist/{codecs-rujsdlZR.mjs → codecs-BbkV3FUQ.mjs} +2 -2
  22. package/dist/codecs-BbkV3FUQ.mjs.map +1 -0
  23. package/dist/{codecs-Cvqvb9pV-Cdc51FKY.d.mts → codecs-D8tLswBi-_nbo-Z8x.d.mts} +53 -4
  24. package/dist/codecs-D8tLswBi-_nbo-Z8x.d.mts.map +1 -0
  25. package/dist/{codecs-CBl0nD44-CjInu_aV.mjs → codecs-DNf0Tmab-Bsdj1npb.mjs} +164 -12
  26. package/dist/codecs-DNf0Tmab-Bsdj1npb.mjs.map +1 -0
  27. package/dist/{codecs-DBn-uIv-.d.mts → codecs-DmCKO7dg.d.mts} +2 -2
  28. package/dist/codecs-DmCKO7dg.d.mts.map +1 -0
  29. package/dist/{column-types-CwAyCgp2.mjs → column-types-Bh92dNjD.mjs} +2 -2
  30. package/dist/{column-types-CwAyCgp2.mjs.map → column-types-Bh92dNjD.mjs.map} +1 -1
  31. package/dist/{contract-free-BZUS18FU.mjs → contract-free-DOV_X620.mjs} +4 -4
  32. package/dist/{contract-free-BZUS18FU.mjs.map → contract-free-DOV_X620.mjs.map} +1 -1
  33. package/dist/{control-8ofLM59h.mjs → control-Bg9zfwmi.mjs} +6 -6
  34. package/dist/{control-8ofLM59h.mjs.map → control-Bg9zfwmi.mjs.map} +1 -1
  35. package/dist/{control-adapter-D4fT5c42-nSea-5cg.mjs → control-adapter-D4fT5c42-CosMjFPJ.mjs} +5 -5
  36. package/dist/{control-adapter-D4fT5c42-nSea-5cg.mjs.map → control-adapter-D4fT5c42-CosMjFPJ.mjs.map} +1 -1
  37. package/dist/{control-policy-wC4BmQy8-Db4igfEn.mjs → control-policy-DHKvUOIr-DAyVIwLu.mjs} +9 -7
  38. package/dist/control-policy-DHKvUOIr-DAyVIwLu.mjs.map +1 -0
  39. package/dist/{ddl-BdP4q3KY-Duef4uHw.mjs → ddl-DfzxUAlg-DvJZAdQx.mjs} +4 -4
  40. package/dist/{ddl-BdP4q3KY-Duef4uHw.mjs.map → ddl-DfzxUAlg-DvJZAdQx.mjs.map} +1 -1
  41. package/dist/{descriptor-meta--MCrvIgj-DFsLFDj1.mjs → descriptor-meta--MCrvIgj-CwlRmzIb.mjs} +5 -5
  42. package/dist/{descriptor-meta--MCrvIgj-DFsLFDj1.mjs.map → descriptor-meta--MCrvIgj-CwlRmzIb.mjs.map} +1 -1
  43. package/dist/{descriptor-meta-B2fGOCSX-DTh_flIG.mjs → descriptor-meta-Bm8_p6kK-CjDa5ovb.mjs} +5 -5
  44. package/dist/{descriptor-meta-B2fGOCSX-DTh_flIG.mjs.map → descriptor-meta-Bm8_p6kK-CjDa5ovb.mjs.map} +1 -1
  45. package/dist/{diff-database-schema-wl9GusaU-BjDyKMS6.mjs → diff-database-schema-ad-D4dAq-DV_k33bS.mjs} +5 -5
  46. package/dist/{diff-database-schema-wl9GusaU-BjDyKMS6.mjs.map → diff-database-schema-ad-D4dAq-DV_k33bS.mjs.map} +1 -1
  47. package/dist/{issue-planner-aw7grdXe.d.mts → issue-planner-Biq9Ls7e.d.mts} +2 -2
  48. package/dist/{issue-planner-aw7grdXe.d.mts.map → issue-planner-Biq9Ls7e.d.mts.map} +1 -1
  49. package/dist/migration-PTHAY9Cv.mjs.map +1 -1
  50. package/dist/{migration-DyZpdeyj.d.mts → migration-aFeTWTOJ.d.mts} +3 -3
  51. package/dist/{migration-DyZpdeyj.d.mts.map → migration-aFeTWTOJ.d.mts.map} +1 -1
  52. package/dist/{op-factory-call-DJEyoQmT-DSMQffKu.d.mts → op-factory-call-BAeyLFYf-BAgG1h1C.d.mts} +17 -4
  53. package/dist/op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map +1 -0
  54. package/dist/op-factory-call-BTU8I_x0.d.mts +1 -0
  55. package/dist/{op-factory-call-rf1FJg8l-C6KLaBY1.mjs → op-factory-call-Brgoyup0-PVFU69JM.mjs} +61 -6
  56. package/dist/op-factory-call-Brgoyup0-PVFU69JM.mjs.map +1 -0
  57. package/dist/{pack-j8ePkv1A.d.mts → pack-BYwIb0CN.d.mts} +17 -3
  58. package/dist/pack-BYwIb0CN.d.mts.map +1 -0
  59. package/dist/{planner-CqFym7lA-BKHIkh3V.mjs → planner-BycBXxqk-DUExzUoz.mjs} +94 -11
  60. package/dist/planner-BycBXxqk-DUExzUoz.mjs.map +1 -0
  61. package/dist/{planner-BMBEF8Kc.d.mts → planner-CT-7zSfk.d.mts} +20 -2
  62. package/dist/{planner-BMBEF8Kc.d.mts.map → planner-CT-7zSfk.d.mts.map} +1 -1
  63. package/dist/{planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs → planner-ddl-builders-DJrx9cJg-Ct2ly5Em.mjs} +3 -3
  64. package/dist/{planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs.map → planner-ddl-builders-DJrx9cJg-Ct2ly5Em.mjs.map} +1 -1
  65. package/dist/{planner-produced-postgres-migration-Ci6O7OL5-5k5_6lcD.mjs → planner-produced-postgres-migration-B9P7yeDs-BgEtBGET.mjs} +3 -3
  66. package/dist/{planner-produced-postgres-migration-Ci6O7OL5-5k5_6lcD.mjs.map → planner-produced-postgres-migration-B9P7yeDs-BgEtBGET.mjs.map} +1 -1
  67. package/dist/{planner-produced-postgres-migration-Cs252KpU-BvXMZvzX.d.mts → planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts} +3 -3
  68. package/dist/planner-produced-postgres-migration-BaviT8KK-Yo9kw6rs.d.mts.map +1 -0
  69. package/dist/planner-produced-postgres-migration-D6C0T2xV.d.mts +1 -0
  70. package/dist/{planner-sql-checks-DRc_78n8-C9nHOrvU.mjs → planner-sql-checks-DKialyGJ-BlU4hEEw.mjs} +3 -3
  71. package/dist/{planner-sql-checks-DRc_78n8-C9nHOrvU.mjs.map → planner-sql-checks-DKialyGJ-BlU4hEEw.mjs.map} +1 -1
  72. package/dist/{postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs → postgres-contract-view-B_0-lbVi-C4lFy3bt.mjs} +5 -5
  73. package/dist/{postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs.map → postgres-contract-view-B_0-lbVi-C4lFy3bt.mjs.map} +1 -1
  74. package/dist/{postgres-migration-DPK9WNF5-DHAXtwys.d.mts → postgres-migration-BNsrwlxh-CwI5BqAu.d.mts} +9 -3
  75. package/dist/postgres-migration-BNsrwlxh-CwI5BqAu.d.mts.map +1 -0
  76. package/dist/{postgres-migration-DJqjEDIS-CP437pha.mjs → postgres-migration-BOVlNbh2-D3by-atW.mjs} +9 -5
  77. package/dist/postgres-migration-BOVlNbh2-D3by-atW.mjs.map +1 -0
  78. package/dist/{postgres-schema-KSzLDONj-CsXGoY8b.mjs → postgres-schema-CFOxDfUX-DTZtjh5X.mjs} +3 -3
  79. package/dist/{postgres-schema-KSzLDONj-CsXGoY8b.mjs.map → postgres-schema-CFOxDfUX-DTZtjh5X.mjs.map} +1 -1
  80. package/dist/{resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs → resolve-ddl-schema-BIy8VDVK-Cb6hoVTS.mjs} +3 -3
  81. package/dist/{resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs.map → resolve-ddl-schema-BIy8VDVK-Cb6hoVTS.mjs.map} +1 -1
  82. package/dist/{sql-renderer-CZE98PJj-Bx5D-Txz.mjs → sql-renderer-CZE98PJj-E5yVGXmL.mjs} +2 -2
  83. package/dist/{sql-renderer-CZE98PJj-Bx5D-Txz.mjs.map → sql-renderer-CZE98PJj-E5yVGXmL.mjs.map} +1 -1
  84. package/dist/target.d.mts +16 -16
  85. package/dist/target.mjs +19 -19
  86. package/dist/target__aggregates.mjs +1 -1
  87. package/dist/target__codec-ids.d.mts +3 -3
  88. package/dist/target__codec-ids.mjs +2 -2
  89. package/dist/target__codec-types.d.mts +3 -3
  90. package/dist/target__codecs.d.mts +3 -3
  91. package/dist/target__codecs.mjs +3 -3
  92. package/dist/target__contract-free.mjs +3 -3
  93. package/dist/target__control.mjs +1 -1
  94. package/dist/target__diff-database-schema.mjs +1 -1
  95. package/dist/target__issue-planner.d.mts +1 -1
  96. package/dist/target__issue-planner.mjs +1 -1
  97. package/dist/target__migration.d.mts +2 -2
  98. package/dist/target__migration.mjs +2 -2
  99. package/dist/target__op-factory-call.d.mts +3 -3
  100. package/dist/target__op-factory-call.mjs +2 -2
  101. package/dist/target__pack.d.mts +1 -1
  102. package/dist/target__pack.mjs +1 -1
  103. package/dist/target__planner-ddl-builders.mjs +1 -1
  104. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  105. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  106. package/dist/target__planner-sql-checks.mjs +1 -1
  107. package/dist/target__planner.d.mts +1 -1
  108. package/dist/target__planner.mjs +2 -2
  109. package/dist/target__runtime.mjs +1 -1
  110. package/dist/target__runtime.mjs.map +1 -1
  111. package/dist/target__schema-ir-annotations.mjs +1 -1
  112. package/dist/target__types.mjs +1 -1
  113. package/package.json +9 -9
  114. package/dist/aggregates-ftUgi-eC.mjs.map +0 -1
  115. package/dist/authoring-03FwIL2k-kPjZAp3s.mjs.map +0 -1
  116. package/dist/codec-ids-CsOU3xDv-mPI0INiF.d.mts.map +0 -1
  117. package/dist/codec-ids-fgafMLR7.d.mts +0 -1
  118. package/dist/codec-ids-tX7Svtz--BuOfRaVU.mjs.map +0 -1
  119. package/dist/codec-types-BHwY9Ff-.d.mts +0 -2
  120. package/dist/codec-types-mWhnDEAf-CAQzGFnF.d.mts.map +0 -1
  121. package/dist/codecs-CBl0nD44-CjInu_aV.mjs.map +0 -1
  122. package/dist/codecs-Cvqvb9pV-Cdc51FKY.d.mts.map +0 -1
  123. package/dist/codecs-DBn-uIv-.d.mts.map +0 -1
  124. package/dist/codecs-rujsdlZR.mjs.map +0 -1
  125. package/dist/control-policy-wC4BmQy8-Db4igfEn.mjs.map +0 -1
  126. package/dist/op-factory-call-ClseZgmP.d.mts +0 -1
  127. package/dist/op-factory-call-DJEyoQmT-DSMQffKu.d.mts.map +0 -1
  128. package/dist/op-factory-call-rf1FJg8l-C6KLaBY1.mjs.map +0 -1
  129. package/dist/pack-j8ePkv1A.d.mts.map +0 -1
  130. package/dist/planner-CqFym7lA-BKHIkh3V.mjs.map +0 -1
  131. package/dist/planner-produced-postgres-migration-Cs252KpU-BvXMZvzX.d.mts.map +0 -1
  132. package/dist/planner-produced-postgres-migration-Cua5YEYV.d.mts +0 -1
  133. package/dist/postgres-migration-DJqjEDIS-CP437pha.mjs.map +0 -1
  134. package/dist/postgres-migration-DPK9WNF5-DHAXtwys.d.mts.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"diff-database-schema-wl9GusaU-BjDyKMS6.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-wl9GusaU.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Ba5ZebHM.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.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 { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-wC4BmQy8.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\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 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, 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*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\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 (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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\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-wl9GusaU.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,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,MAA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AA2B;EACrC;EACA,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,iBAAiB,CAAC,GAAG,OAAO,eAAe;EAC3C,WAAW,OAAO;CACnB,CAAC;AACF;;;;;;;;;;;;;AAaA,SAAS,sBAAsB,OAAO;CACrC,MAAM,mBAAmB,UAAU,MAAM,QAAQ;CACjD,2BAA2B,OAAO,MAAM,YAAY;CACpD,MAAM,SAAS,MAAM;CACrB,MAAM,eAAe,qCAAqC,kBAAkB;EAC3E,qBAAqB;EACrB,GAAG,UAAU,oBAAoB,wBAAwB,MAAM,mBAAmB,CAAC;EACnF,gBAAgB;CACjB,CAAC;CACD,MAAM,WAAW,yBAAyB,YAAY;CACtD,MAAM,eAAe,oBAAoB,UAAU,MAAM;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
+ {"version":3,"file":"diff-database-schema-ad-D4dAq-DV_k33bS.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-ad-D4dAq.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as postgresResolveDefault } from \"./default-normalizer-Ba5ZebHM.mjs\";\nimport { r as isPostgresSchema } from \"./postgres-schema-CFOxDfUX.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 { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-BIy8VDVK.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-DHKvUOIr.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { buildNativeTypeExpander, contractNamespaceToSchemaIR } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf } from \"@internal/sql-schema-ir/naming\";\nimport { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from \"@internal/sql-schema-ir/types\";\nimport { classifyDiffSubjectGranularity } from \"@internal/family-sql/diff\";\nimport { diffSchemas, issueOutcome } from \"@internal/framework-components/control\";\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 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, 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*/\nfunction diffPostgresSchema(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.schema);\n\tconst actual = input.schema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\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 (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*/\nfunction buildPostgresPlanDiff(input) {\n\tconst postgresContract = blindCast(input.contract);\n\tPostgresDatabaseSchemaNode.assert(input.actualSchema);\n\tconst actual = input.actualSchema;\n\tconst fullExpected = contractToPostgresDatabaseSchemaNode(postgresContract, {\n\t\tannotationNamespace: \"pg\",\n\t\t...ifDefined(\"expandNativeType\", buildNativeTypeExpander(input.frameworkComponents)),\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-ad-D4dAq.mjs.map"],"mappings":";;;;;;;;;;;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,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 { j as PostgresOpFactoryCall } from "./op-factory-call-DJEyoQmT-DSMQffKu.mjs";
1
+ import { j as PostgresOpFactoryCall } from "./op-factory-call-BAeyLFYf-BAgG1h1C.mjs";
2
2
  import { SqlStorage, StorageTypeInstance } from "@prisma/orm-family-sql/contract/types";
3
3
  import { DiffableNode, SchemaDiffIssue } from "@prisma/orm-framework/components/control";
4
4
  import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma/orm-family-sql/family/control";
@@ -102,4 +102,4 @@ interface IssuePlannerOptions {
102
102
  declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
103
103
  //#endregion
104
104
  export { planIssues as n, coalesceSubtreeIssues as t };
105
- //# sourceMappingURL=issue-planner-aw7grdXe.d.mts.map
105
+ //# sourceMappingURL=issue-planner-Biq9Ls7e.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issue-planner-aw7grdXe.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;UAkBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;WAChC,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;WAChC,cAAc,SAAS,eAAe;;;;;;;;WAQtC,SAAS;;;;;;WAMT,SAAS;;;;;WAKT,sBAAsB,cAAc;WACpC,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
1
+ {"version":3,"file":"issue-planner-Biq9Ls7e.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;UAkBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;WAChC,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;WAChC,cAAc,SAAS,eAAe;;;;;;;;WAQtC,SAAS;;;;;;WAMT,SAAS;;;;;WAKT,sBAAsB,cAAc;WACpC,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
@@ -1 +1 @@
1
- {"version":3,"file":"migration-PTHAY9Cv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { F as createExtension } from \"./op-factory-call-rf1FJg8l.mjs\";\nimport { t as dataTransform } from \"./data-transform-ChZzy2dP.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-DJqjEDIS.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-PTHAY9Cv.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { I as createExtension } from \"./op-factory-call-Brgoyup0.mjs\";\nimport { t as dataTransform } from \"./data-transform-ChZzy2dP.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-BOVlNbh2.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,6 +1,6 @@
1
1
  import "./data-transform-Ck5FbyNO-BNE7QlAo.mjs";
2
- import { A as Op$1 } from "./op-factory-call-DJEyoQmT-DSMQffKu.mjs";
3
- import "./postgres-migration-DPK9WNF5-DHAXtwys.mjs";
2
+ import { A as Op$1 } from "./op-factory-call-BAeyLFYf-BAgG1h1C.mjs";
3
+ import "./postgres-migration-BNsrwlxh-CwI5BqAu.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
5
  import { placeholder } from "@prisma/orm-framework/errors/migration";
6
6
  import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
@@ -22,4 +22,4 @@ declare function createExtension(extensionName: string): Op$1;
22
22
  declare function rawSql(op: Op$1): Op$1;
23
23
  //#endregion
24
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-DyZpdeyj.d.mts.map
25
+ //# sourceMappingURL=migration-aFeTWTOJ.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-DyZpdeyj.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;iBAQiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,OAAK"}
1
+ {"version":3,"file":"migration-aFeTWTOJ.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;iBAQiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,OAAK"}
@@ -7,7 +7,7 @@ import { MigrationOperationClass, OpFactoryCall } from "@prisma/orm-framework/co
7
7
  import { CodecControlHooks, SqlMigrationPlanOperation } from "@prisma/orm-family-sql/family/control";
8
8
  import { ImportRequirement, TsExpression } from "@prisma/orm-framework/ts-render";
9
9
  import { ExecuteRequestLowerer, Lowerer } from "@prisma/orm-family-sql/family/control-adapter";
10
- //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-DJEyoQmT.d.mts
10
+ //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-BAeyLFYf.d.mts
11
11
  //#region src/core/migrations/operations/shared.d.ts
12
12
  type Op$1 = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
13
13
  /**
@@ -280,6 +280,19 @@ declare class DropConstraintCall extends PostgresOpFactoryCallNode {
280
280
  renderTypeScript(): string;
281
281
  importRequirements(): readonly ImportRequirement[];
282
282
  }
283
+ declare class RenameCheckConstraintCall extends PostgresOpFactoryCallNode {
284
+ readonly factoryName: "renameCheckConstraint";
285
+ readonly operationClass: "widening";
286
+ readonly schemaName: string;
287
+ readonly tableName: string;
288
+ readonly oldConstraintName: string;
289
+ readonly newConstraintName: string;
290
+ readonly label: string;
291
+ constructor(schemaName: string, tableName: string, oldConstraintName: string, newConstraintName: string);
292
+ toOp(lowerer?: ExecuteRequestLowerer): Promise<Op>;
293
+ renderTypeScript(): string;
294
+ importRequirements(): readonly ImportRequirement[];
295
+ }
283
296
  declare class AddCheckConstraintCall extends PostgresOpFactoryCallNode {
284
297
  readonly factoryName: "addCheckConstraint";
285
298
  readonly operationClass: "additive";
@@ -515,7 +528,7 @@ declare class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {
515
528
  renderTypeScript(): string;
516
529
  importRequirements(): readonly ImportRequirement[];
517
530
  }
518
- type PostgresOpFactoryCall = CreateTableCall | DropTableCall | AddColumnCall | DropColumnCall | AlterColumnTypeCall | SetNotNullCall | DropNotNullCall | SetDefaultCall | DropDefaultCall | AddNotNullColumnDirectCall | AddNotNullColumnWithTempDefaultCall | AddPrimaryKeyCall | AddForeignKeyCall | AddUniqueCall | AddCheckConstraintCall | DropCheckConstraintCall | CreateIndexCall | RenameIndexCall | DropIndexCall | DropConstraintCall | RawSqlCall | CreateExtensionCall | CreateSchemaCall | CreateNativeEnumTypeCall | DropNativeEnumTypeCall | AddNativeEnumValueCall | CreatePostgresRlsPolicyCall | DropPostgresRlsPolicyCall | EnableRowLevelSecurityCall | DisableRowLevelSecurityCall | RenamePostgresRlsPolicyCall | DataTransformCall;
531
+ type PostgresOpFactoryCall = CreateTableCall | DropTableCall | AddColumnCall | DropColumnCall | AlterColumnTypeCall | SetNotNullCall | DropNotNullCall | SetDefaultCall | DropDefaultCall | AddNotNullColumnDirectCall | AddNotNullColumnWithTempDefaultCall | AddPrimaryKeyCall | AddForeignKeyCall | AddUniqueCall | AddCheckConstraintCall | RenameCheckConstraintCall | DropCheckConstraintCall | CreateIndexCall | RenameIndexCall | DropIndexCall | DropConstraintCall | RawSqlCall | CreateExtensionCall | CreateSchemaCall | CreateNativeEnumTypeCall | DropNativeEnumTypeCall | AddNativeEnumValueCall | CreatePostgresRlsPolicyCall | DropPostgresRlsPolicyCall | EnableRowLevelSecurityCall | DisableRowLevelSecurityCall | RenamePostgresRlsPolicyCall | DataTransformCall;
519
532
  //#endregion
520
- export { Op$1 as A, DropIndexCall as C, DropTableCall as D, DropPostgresRlsPolicyCall as E, SetDefaultCall as F, SetNotNullCall as I, RawSqlCall as M, RenameIndexCall as N, EnableRowLevelSecurityCall as O, RenamePostgresRlsPolicyCall as P, DropDefaultCall as S, DropNotNullCall as T, DataTransformCall as _, AddNotNullColumnWithTempDefaultCall as a, DropColumnCall as b, AlterColumnTypeCall as c, CreateIndexCall as d, CreateIndexExtras as f, CreateTableCall as g, CreateSchemaCall as h, AddNativeEnumValueCall as i, PostgresOpFactoryCall as j, ForeignKeySpec as k, AlterColumnTypeOptions as l, CreatePostgresRlsPolicyCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateNativeEnumTypeCall as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DisableRowLevelSecurityCall as v, DropNativeEnumTypeCall as w, DropConstraintCall as x, DropCheckConstraintCall as y };
521
- //# sourceMappingURL=op-factory-call-DJEyoQmT-DSMQffKu.d.mts.map
533
+ export { Op$1 as A, DropIndexCall as C, DropTableCall as D, DropPostgresRlsPolicyCall as E, RenamePostgresRlsPolicyCall as F, SetDefaultCall as I, SetNotNullCall as L, RawSqlCall as M, RenameCheckConstraintCall as N, EnableRowLevelSecurityCall as O, RenameIndexCall as P, DropDefaultCall as S, DropNotNullCall as T, DataTransformCall as _, AddNotNullColumnWithTempDefaultCall as a, DropColumnCall as b, AlterColumnTypeCall as c, CreateIndexCall as d, CreateIndexExtras as f, CreateTableCall as g, CreateSchemaCall as h, AddNativeEnumValueCall as i, PostgresOpFactoryCall as j, ForeignKeySpec as k, AlterColumnTypeOptions as l, CreatePostgresRlsPolicyCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreateNativeEnumTypeCall as p, AddForeignKeyCall as r, AddUniqueCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DisableRowLevelSecurityCall as v, DropNativeEnumTypeCall as w, DropConstraintCall as x, DropCheckConstraintCall as y };
534
+ //# sourceMappingURL=op-factory-call-BAeyLFYf-BAgG1h1C.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"op-factory-call-BAeyLFYf-BAgG1h1C.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/op-factory-call-BAeyLFYf.d.mts"],"mappings":";;;;;;;;;;;KAUK,OAAO,0BAA0B;;;;;;UAM5B;WACC;WACA;WACA;aACE;aACA;aACA;;WAEF,WAAW;WACX,WAAW;;;;UAIZ;WACC;WACA,UAAU;;;;;;WAMV;WACA;;;;;;;KAON;WACM;;WAEA;;;;KAIN,KAAK,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BAAyB,yBAAyB,8BAA8B,4BAA4B,6BAA6B,8BAA8B,8BAA8B"}
@@ -0,0 +1 @@
1
+ import "./op-factory-call-BAeyLFYf-BAgG1h1C.mjs";
@@ -1,9 +1,9 @@
1
1
  import { n as postgresError } from "./errors-kYxOQjdD-D4T3rbVp.mjs";
2
2
  import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs";
3
3
  import { a as validateEnumValueLength, i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-BnBlQxyh-DaX9Nb7Z.mjs";
4
- import { C as nativeEnumValueExistsAst, D as tableExistsAst, E as rlsPolicyExistsAst, O as tableIsEmptyAst, S as nativeEnumTypeExistsAst, T as rlsEnabledAst, _ as dropIndex$1, a as columnDefaultAst, b as extensionExistsAst, c as columnTypeAst, d as createPolicy, f as createSchema, g as dropDefaultAction, h as disableRowLevelSecurity$1, i as alterTable, l as constraintExistsAst, m as createType, n as alterIndexRename, o as columnExistsAst, p as createTable, r as alterPolicyRename, s as columnNullabilityAst, t as addColumnAction, u as createIndex$1, v as dropPolicy, w as noNullValuesAst, x as indexExistsAst, y as dropType } from "./ddl-BdP4q3KY-Duef4uHw.mjs";
5
- import { n as qualifyTableName } from "./planner-sql-checks-DRc_78n8-C9nHOrvU.mjs";
6
- import { n as buildColumnTypeSql } from "./planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs";
4
+ import { C as nativeEnumValueExistsAst, D as tableExistsAst, E as rlsPolicyExistsAst, O as tableIsEmptyAst, S as nativeEnumTypeExistsAst, T as rlsEnabledAst, _ as dropIndex$1, a as columnDefaultAst, b as extensionExistsAst, c as columnTypeAst, d as createPolicy, f as createSchema, g as dropDefaultAction, h as disableRowLevelSecurity$1, i as alterTable, l as constraintExistsAst, m as createType, n as alterIndexRename, o as columnExistsAst, p as createTable, r as alterPolicyRename, s as columnNullabilityAst, t as addColumnAction, u as createIndex$1, v as dropPolicy, w as noNullValuesAst, x as indexExistsAst, y as dropType } from "./ddl-DfzxUAlg-DvJZAdQx.mjs";
5
+ import { n as qualifyTableName } from "./planner-sql-checks-DKialyGJ-BlU4hEEw.mjs";
6
+ import { n as buildColumnTypeSql } from "./planner-ddl-builders-DJrx9cJg-Ct2ly5Em.mjs";
7
7
  import { FunctionColumnDefault, LiteralColumnDefault } from "@prisma/orm-family-sql/relational-core/ast";
8
8
  import { blindCast } from "@prisma/orm-framework/utils/casts";
9
9
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
@@ -14,7 +14,7 @@ import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal
14
14
  import { errorUnfilledPlaceholder } from "@prisma/orm-framework/errors/migration";
15
15
  import { TsExpression, jsonToTsSource } from "@prisma/orm-framework/ts-render";
16
16
  import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
17
- //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-rf1FJg8l.mjs
17
+ //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-Brgoyup0.mjs
18
18
  /**
19
19
  * Maps a planner schema name to the contract-free DDL builder's optional
20
20
  * `schema` field: the unbound sentinel becomes `undefined` (the builder omits
@@ -341,6 +341,28 @@ async function addCheckConstraint(schemaName, tableName, constraintName, express
341
341
  postcheck: [step(`verify constraint "${constraintName}" exists`, present.sql, present.params)]
342
342
  };
343
343
  }
344
+ async function renameCheckConstraint(schemaName, tableName, fromName, toName, lowerer) {
345
+ const qualified = qualifyTableName(schemaName, tableName);
346
+ const from = await constraintCheckSteps(lowerer, {
347
+ constraintName: fromName,
348
+ schema: schemaName,
349
+ table: tableName
350
+ });
351
+ const to = await constraintCheckSteps(lowerer, {
352
+ constraintName: toName,
353
+ schema: schemaName,
354
+ table: tableName
355
+ });
356
+ return {
357
+ id: `checkConstraint.${schemaName}.${tableName}.${fromName}.rename`,
358
+ label: `Rename check constraint "${fromName}" to "${toName}" on "${tableName}"`,
359
+ operationClass: "widening",
360
+ target: targetDetails("checkConstraint", toName, schemaName, tableName),
361
+ precheck: [step(`ensure constraint "${fromName}" exists`, from.present.sql, from.present.params), step(`ensure constraint "${toName}" does not exist`, to.absent.sql, to.absent.params)],
362
+ execute: [step(`rename check constraint "${fromName}" to "${toName}"`, `ALTER TABLE ${qualified} RENAME CONSTRAINT ${quoteIdentifier(fromName)} TO ${quoteIdentifier(toName)}`)],
363
+ postcheck: [step(`verify constraint "${toName}" exists`, to.present.sql, to.present.params)]
364
+ };
365
+ }
344
366
  async function dropCheckConstraint(schemaName, tableName, constraintName, lowerer) {
345
367
  const qualified = qualifyTableName(schemaName, tableName);
346
368
  const { absent, present } = await constraintCheckSteps(lowerer, {
@@ -1433,6 +1455,39 @@ var DropConstraintCall = class extends PostgresOpFactoryCallNode {
1433
1455
  return [];
1434
1456
  }
1435
1457
  };
1458
+ var RenameCheckConstraintCall = class extends PostgresOpFactoryCallNode {
1459
+ factoryName = "renameCheckConstraint";
1460
+ operationClass = "widening";
1461
+ schemaName;
1462
+ tableName;
1463
+ oldConstraintName;
1464
+ newConstraintName;
1465
+ label;
1466
+ constructor(schemaName, tableName, oldConstraintName, newConstraintName) {
1467
+ super();
1468
+ this.schemaName = schemaName;
1469
+ this.tableName = tableName;
1470
+ this.oldConstraintName = oldConstraintName;
1471
+ this.newConstraintName = newConstraintName;
1472
+ this.label = `Rename check constraint "${oldConstraintName}" to "${newConstraintName}" on "${tableName}"`;
1473
+ this.freeze();
1474
+ }
1475
+ async toOp(lowerer) {
1476
+ if (lowerer === void 0) throw postgresError("MIGRATION.POSTGRES_CONTROL_STACK_MISSING", `RenameCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint "${this.oldConstraintName}" on table "${this.tableName}"). Pass the control adapter to createPostgresMigrationPlanner.`, { meta: { factory: "RenameCheckConstraintCall" } });
1477
+ return renameCheckConstraint(this.schemaName, this.tableName, this.oldConstraintName, this.newConstraintName, lowerer);
1478
+ }
1479
+ renderTypeScript() {
1480
+ const opts = [];
1481
+ if (this.schemaName !== UNBOUND_NAMESPACE_ID) opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);
1482
+ opts.push(`table: ${jsonToTsSource(this.tableName)}`);
1483
+ opts.push(`from: ${jsonToTsSource(this.oldConstraintName)}`);
1484
+ opts.push(`to: ${jsonToTsSource(this.newConstraintName)}`);
1485
+ return `this.renameCheckConstraint({ ${opts.join(", ")} })`;
1486
+ }
1487
+ importRequirements() {
1488
+ return [];
1489
+ }
1490
+ };
1436
1491
  var AddCheckConstraintCall = class extends PostgresOpFactoryCallNode {
1437
1492
  factoryName = "addCheckConstraint";
1438
1493
  operationClass = "additive";
@@ -2002,6 +2057,6 @@ var RenamePostgresRlsPolicyCall = class extends PostgresOpFactoryCallNode {
2002
2057
  }
2003
2058
  };
2004
2059
  //#endregion
2005
- export { RenamePostgresRlsPolicyCall as A, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, installExtension as F, postgresDefaultToDdlColumnDefault as I, SetNotNullCall 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, SetDefaultCall as j, RenameIndexCall 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 };
2060
+ export { RenameIndexCall as A, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, createExtension as F, installExtension as I, postgresDefaultToDdlColumnDefault as L, SetDefaultCall as M, SetNotNullCall as N, RawSqlCall as O, buildTargetDetails 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, RenamePostgresRlsPolicyCall as j, RenameCheckConstraintCall 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 };
2006
2061
 
2007
- //# sourceMappingURL=op-factory-call-rf1FJg8l-C6KLaBY1.mjs.map
2062
+ //# sourceMappingURL=op-factory-call-Brgoyup0-PVFU69JM.mjs.map