@prisma/orm-target-postgres 8.0.0-rc.18-dev.5 → 8.0.0-rc.18-dev.7

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 (94) hide show
  1. package/dist/{adapter-0nX__6wz-Cv78OA3n.mjs → adapter-DXUJlrmB-7Lk8j0kE.mjs} +3 -3
  2. package/dist/{adapter-0nX__6wz-Cv78OA3n.mjs.map → adapter-DXUJlrmB-7Lk8j0kE.mjs.map} +1 -1
  3. package/dist/{adapter-BXHPMNAg.d.mts → adapter-giV1nqJs.d.mts} +3 -3
  4. package/dist/{adapter-BXHPMNAg.d.mts.map → adapter-giV1nqJs.d.mts.map} +1 -1
  5. package/dist/adapter.d.mts +2 -2
  6. package/dist/adapter.mjs +2 -2
  7. package/dist/adapter__adapter.d.mts +1 -1
  8. package/dist/adapter__adapter.mjs +2 -2
  9. package/dist/adapter__control.d.mts +1 -1
  10. package/dist/adapter__control.mjs +3 -3
  11. package/dist/adapter__control.mjs.map +1 -1
  12. package/dist/adapter__runtime.mjs +2 -2
  13. package/dist/adapter__runtime.mjs.map +1 -1
  14. package/dist/{contract-free-DY8vDIxh.d.mts → contract-free-D-v6WIhk.d.mts} +16 -4
  15. package/dist/{contract-free-DY8vDIxh.d.mts.map → contract-free-D-v6WIhk.d.mts.map} +1 -1
  16. package/dist/{contract-free-spGyVyoh.mjs → contract-free-DX6DmaSU.mjs} +2 -2
  17. package/dist/contract-free-DX6DmaSU.mjs.map +1 -0
  18. package/dist/{control-DmhbrV5f.d.mts → control-CBG2OxfU.d.mts} +3 -3
  19. package/dist/{control-DmhbrV5f.d.mts.map → control-CBG2OxfU.d.mts.map} +1 -1
  20. package/dist/{control-CP_p1FQ3.mjs → control-DxX_0Qw4.mjs} +4 -4
  21. package/dist/{control-CP_p1FQ3.mjs.map → control-DxX_0Qw4.mjs.map} +1 -1
  22. package/dist/{control-adapter-BmGQyrYm-MHkF4xNt.mjs → control-adapter-EatqP8Vh-CYWBxnLn.mjs} +15 -7
  23. package/dist/{control-adapter-BmGQyrYm-MHkF4xNt.mjs.map → control-adapter-EatqP8Vh-CYWBxnLn.mjs.map} +1 -1
  24. package/dist/{control-policy-DXaIsgUW-Btyo9Vs8.mjs → control-policy-BlVJAbUZ-BjQYqA_a.mjs} +3 -3
  25. package/dist/{control-policy-DXaIsgUW-Btyo9Vs8.mjs.map → control-policy-BlVJAbUZ-BjQYqA_a.mjs.map} +1 -1
  26. package/dist/{ddl-BKqbtVN3-CPHiYaCY.mjs → ddl-B6lRIezE-BMI5qzD2.mjs} +21 -5
  27. package/dist/ddl-B6lRIezE-BMI5qzD2.mjs.map +1 -0
  28. package/dist/ddl-Da35uGK1.d.mts +1 -0
  29. package/dist/{descriptor-meta-B5vKqEt2-DFa431Ad.mjs → descriptor-meta-DThyh4X8-rA2bozYa.mjs} +3 -3
  30. package/dist/{descriptor-meta-B5vKqEt2-DFa431Ad.mjs.map → descriptor-meta-DThyh4X8-rA2bozYa.mjs.map} +1 -1
  31. package/dist/{diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs → diff-database-schema-Ce8vWO7g-gdU3XGHC.mjs} +3 -3
  32. package/dist/{diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs.map → diff-database-schema-Ce8vWO7g-gdU3XGHC.mjs.map} +1 -1
  33. package/dist/{indexes-BWHRVhke-vqXUnRfT.d.mts → indexes-Ccd2ehxq-BaM6od9m.d.mts} +3 -3
  34. package/dist/indexes-Ccd2ehxq-BaM6od9m.d.mts.map +1 -0
  35. package/dist/{issue-planner-BiJDKtW5.d.mts → issue-planner-C010eVt6.d.mts} +2 -2
  36. package/dist/{issue-planner-BiJDKtW5.d.mts.map → issue-planner-C010eVt6.d.mts.map} +1 -1
  37. package/dist/{migration-C9ZH26Nj.mjs → migration-CbOh59ZJ.mjs} +3 -3
  38. package/dist/{migration-C9ZH26Nj.mjs.map → migration-CbOh59ZJ.mjs.map} +1 -1
  39. package/dist/{migration-NJo7cPpB.d.mts → migration-e6FvcwS2.d.mts} +5 -5
  40. package/dist/{migration-NJo7cPpB.d.mts.map → migration-e6FvcwS2.d.mts.map} +1 -1
  41. package/dist/{nodes-Bm2a7z6e-BXTXyzZv.mjs → nodes-BYKl6zt_-BoUacQ_3.mjs} +34 -3
  42. package/dist/nodes-BYKl6zt_-BoUacQ_3.mjs.map +1 -0
  43. package/dist/{nodes-C1fPapnK-j0AK7Gcj.d.mts → nodes-h4zPlhED-nduA-ijW.d.mts} +28 -11
  44. package/dist/nodes-h4zPlhED-nduA-ijW.d.mts.map +1 -0
  45. package/dist/{op-factory-call-ltgiEZ8g-CX6WX57X.mjs → op-factory-call-Bf00O3tt-aQ8OJ00n.mjs} +21 -10
  46. package/dist/op-factory-call-Bf00O3tt-aQ8OJ00n.mjs.map +1 -0
  47. package/dist/op-factory-call-DFD-usUW.d.mts +1 -0
  48. package/dist/{op-factory-call-DkaMatJ4-D_7fWo-v.d.mts → op-factory-call-Do9gu48J-CNEnsh3K.d.mts} +4 -4
  49. package/dist/{op-factory-call-DkaMatJ4-D_7fWo-v.d.mts.map → op-factory-call-Do9gu48J-CNEnsh3K.d.mts.map} +1 -1
  50. package/dist/{planner-Xei8enE-.d.mts → planner-Bc3x3nHl.d.mts} +2 -2
  51. package/dist/{planner-Xei8enE-.d.mts.map → planner-Bc3x3nHl.d.mts.map} +1 -1
  52. package/dist/{planner-Ccn9yxL7-B6Pgoz6c.mjs → planner-BnZ7Ma0m-CuFTpofj.mjs} +7 -7
  53. package/dist/{planner-Ccn9yxL7-B6Pgoz6c.mjs.map → planner-BnZ7Ma0m-CuFTpofj.mjs.map} +1 -1
  54. package/dist/planner-produced-postgres-migration-Da0CME4J.d.mts +1 -0
  55. package/dist/{planner-produced-postgres-migration-Brgj59VY-DOOLRWyy.mjs → planner-produced-postgres-migration-UY6o1KtK-D8AyKNJX.mjs} +4 -4
  56. package/dist/{planner-produced-postgres-migration-Brgj59VY-DOOLRWyy.mjs.map → planner-produced-postgres-migration-UY6o1KtK-D8AyKNJX.mjs.map} +1 -1
  57. package/dist/{planner-produced-postgres-migration-MoopN05f-CfmsQNwj.d.mts → planner-produced-postgres-migration-qAKbwI9E-BGte8lXU.d.mts} +3 -3
  58. package/dist/planner-produced-postgres-migration-qAKbwI9E-BGte8lXU.d.mts.map +1 -0
  59. package/dist/{postgres-migration-D5OiThXV-CihIARAE.d.mts → postgres-migration-Btxi7VsD-DdEHax_e.d.mts} +3 -3
  60. package/dist/{postgres-migration-D5OiThXV-CihIARAE.d.mts.map → postgres-migration-Btxi7VsD-DdEHax_e.d.mts.map} +1 -1
  61. package/dist/{postgres-migration-CLIfS2iQ-BgnVMLRT.mjs → postgres-migration-DxPGyge8-ChvbfTP4.mjs} +5 -5
  62. package/dist/{postgres-migration-CLIfS2iQ-BgnVMLRT.mjs.map → postgres-migration-DxPGyge8-ChvbfTP4.mjs.map} +1 -1
  63. package/dist/{render-ops-Cw9B6aq6-CMzRGNUZ.mjs → render-ops-Cj_4STo9-hZVcK77c.mjs} +3 -3
  64. package/dist/{render-ops-Cw9B6aq6-CMzRGNUZ.mjs.map → render-ops-Cj_4STo9-hZVcK77c.mjs.map} +1 -1
  65. package/dist/target.d.mts +12 -12
  66. package/dist/target.mjs +13 -13
  67. package/dist/target__contract-free.d.mts +2 -2
  68. package/dist/target__contract-free.mjs +3 -3
  69. package/dist/target__control.mjs +2 -2
  70. package/dist/target__ddl.d.mts +3 -3
  71. package/dist/target__ddl.mjs +2 -2
  72. package/dist/target__diff-database-schema.mjs +1 -1
  73. package/dist/target__issue-planner.d.mts +1 -1
  74. package/dist/target__issue-planner.mjs +1 -1
  75. package/dist/target__migration.d.mts +2 -2
  76. package/dist/target__migration.mjs +3 -3
  77. package/dist/target__op-factory-call.d.mts +2 -2
  78. package/dist/target__op-factory-call.mjs +1 -1
  79. package/dist/target__planner-produced-postgres-migration.d.mts +2 -2
  80. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  81. package/dist/target__planner.d.mts +1 -1
  82. package/dist/target__planner.mjs +2 -2
  83. package/dist/target__render-ops.mjs +1 -1
  84. package/package.json +9 -9
  85. package/dist/contract-free-spGyVyoh.mjs.map +0 -1
  86. package/dist/ddl-B-WjvCal.d.mts +0 -1
  87. package/dist/ddl-BKqbtVN3-CPHiYaCY.mjs.map +0 -1
  88. package/dist/indexes-BWHRVhke-vqXUnRfT.d.mts.map +0 -1
  89. package/dist/nodes-Bm2a7z6e-BXTXyzZv.mjs.map +0 -1
  90. package/dist/nodes-C1fPapnK-j0AK7Gcj.d.mts.map +0 -1
  91. package/dist/op-factory-call-LGCmMtZM.d.mts +0 -1
  92. package/dist/op-factory-call-ltgiEZ8g-CX6WX57X.mjs.map +0 -1
  93. package/dist/planner-produced-postgres-migration-DgyIhdpw.d.mts +0 -1
  94. package/dist/planner-produced-postgres-migration-MoopN05f-CfmsQNwj.d.mts.map +0 -1
@@ -1,7 +1,7 @@
1
1
  import { t as postgresAggregateDescriptors } from "./aggregates-B6ZQFHFE.mjs";
2
2
  import { o as postgresCodecRegistry } from "./codec-registry-BWUY_QLt-CzrMkP9N.mjs";
3
- import { n as postgresAdapterCapabilities } from "./control-adapter-BmGQyrYm-MHkF4xNt.mjs";
4
- //#region ../../../3-targets/6-adapters/postgres/dist/descriptor-meta-B5vKqEt2.mjs
3
+ import { n as postgresAdapterCapabilities } from "./control-adapter-EatqP8Vh-CYWBxnLn.mjs";
4
+ //#region ../../../3-targets/6-adapters/postgres/dist/descriptor-meta-DThyh4X8.mjs
5
5
  /** Creates a type import spec for codec types */
6
6
  const codecTypeImport = (named) => ({
7
7
  package: "@internal/target-postgres/codec-types",
@@ -50,4 +50,4 @@ const postgresAdapterDescriptorMeta = {
50
50
  //#endregion
51
51
  export { postgresAdapterDescriptorMeta as t };
52
52
 
53
- //# sourceMappingURL=descriptor-meta-B5vKqEt2-DFa431Ad.mjs.map
53
+ //# sourceMappingURL=descriptor-meta-DThyh4X8-rA2bozYa.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"descriptor-meta-B5vKqEt2-DFa431Ad.mjs","names":[],"sources":["../../../../3-targets/6-adapters/postgres/dist/descriptor-meta-B5vKqEt2.mjs"],"sourcesContent":["import { n as postgresAdapterCapabilities } from \"./control-adapter-BmGQyrYm.mjs\";\nimport { postgresCodecRegistry } from \"@internal/target-postgres/codecs\";\nimport { postgresAggregateDescriptors } from \"@internal/target-postgres/aggregates\";\n//#region src/core/descriptor-meta.ts\n/** Creates a type import spec for codec types */\nconst codecTypeImport = (named) => ({\n\tpackage: \"@internal/target-postgres/codec-types\",\n\tnamed,\n\talias: named\n});\nconst postgresAdapterDescriptorMeta = {\n\tkind: \"adapter\",\n\tfamilyId: \"sql\",\n\ttargetId: \"postgres\",\n\tid: \"postgres\",\n\tversion: \"0.0.1\",\n\tcapabilities: postgresAdapterCapabilities,\n\ttypes: {\n\t\taggregateDescriptors: postgresAggregateDescriptors,\n\t\tcodecTypes: {\n\t\t\tcodecDescriptors: Array.from(postgresCodecRegistry.values()),\n\t\t\timport: {\n\t\t\t\tpackage: \"@internal/target-postgres/codec-types\",\n\t\t\t\tnamed: \"CodecTypes\",\n\t\t\t\talias: \"PgTypes\"\n\t\t\t},\n\t\t\ttypeImports: [\n\t\t\t\t{\n\t\t\t\t\tpackage: \"@internal/target-postgres/codec-types\",\n\t\t\t\t\tnamed: \"JsonValue\",\n\t\t\t\t\talias: \"JsonValue\"\n\t\t\t\t},\n\t\t\t\tcodecTypeImport(\"Char\"),\n\t\t\t\tcodecTypeImport(\"Varchar\"),\n\t\t\t\tcodecTypeImport(\"Numeric\"),\n\t\t\t\tcodecTypeImport(\"Bit\"),\n\t\t\t\tcodecTypeImport(\"VarBit\"),\n\t\t\t\tcodecTypeImport(\"Timestamp\"),\n\t\t\t\tcodecTypeImport(\"Timestamptz\"),\n\t\t\t\tcodecTypeImport(\"Time\"),\n\t\t\t\tcodecTypeImport(\"Timetz\"),\n\t\t\t\tcodecTypeImport(\"Interval\"),\n\t\t\t\tcodecTypeImport(\"TimestampString\"),\n\t\t\t\tcodecTypeImport(\"TimestamptzString\"),\n\t\t\t\tcodecTypeImport(\"TimeString\")\n\t\t\t]\n\t\t}\n\t}\n};\n//#endregion\nexport { postgresAdapterDescriptorMeta as t };\n\n//# sourceMappingURL=descriptor-meta-B5vKqEt2.mjs.map"],"mappings":";;;;;AAKA,MAAM,mBAAmB,WAAW;CACnC,SAAS;CACT;CACA,OAAO;AACR;AACA,MAAM,gCAAgC;CACrC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc;CACd,OAAO;EACN,sBAAsB;EACtB,YAAY;GACX,kBAAkB,MAAM,KAAK,sBAAsB,OAAO,CAAC;GAC3D,QAAQ;IACP,SAAS;IACT,OAAO;IACP,OAAO;GACR;GACA,aAAa;IACZ;KACC,SAAS;KACT,OAAO;KACP,OAAO;IACR;IACA,gBAAgB,MAAM;IACtB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,KAAK;IACrB,gBAAgB,QAAQ;IACxB,gBAAgB,WAAW;IAC3B,gBAAgB,aAAa;IAC7B,gBAAgB,MAAM;IACtB,gBAAgB,QAAQ;IACxB,gBAAgB,UAAU;IAC1B,gBAAgB,iBAAiB;IACjC,gBAAgB,mBAAmB;IACnC,gBAAgB,YAAY;GAC7B;EACD;CACD;AACD"}
1
+ {"version":3,"file":"descriptor-meta-DThyh4X8-rA2bozYa.mjs","names":[],"sources":["../../../../3-targets/6-adapters/postgres/dist/descriptor-meta-DThyh4X8.mjs"],"sourcesContent":["import { n as postgresAdapterCapabilities } from \"./control-adapter-EatqP8Vh.mjs\";\nimport { postgresCodecRegistry } from \"@internal/target-postgres/codecs\";\nimport { postgresAggregateDescriptors } from \"@internal/target-postgres/aggregates\";\n//#region src/core/descriptor-meta.ts\n/** Creates a type import spec for codec types */\nconst codecTypeImport = (named) => ({\n\tpackage: \"@internal/target-postgres/codec-types\",\n\tnamed,\n\talias: named\n});\nconst postgresAdapterDescriptorMeta = {\n\tkind: \"adapter\",\n\tfamilyId: \"sql\",\n\ttargetId: \"postgres\",\n\tid: \"postgres\",\n\tversion: \"0.0.1\",\n\tcapabilities: postgresAdapterCapabilities,\n\ttypes: {\n\t\taggregateDescriptors: postgresAggregateDescriptors,\n\t\tcodecTypes: {\n\t\t\tcodecDescriptors: Array.from(postgresCodecRegistry.values()),\n\t\t\timport: {\n\t\t\t\tpackage: \"@internal/target-postgres/codec-types\",\n\t\t\t\tnamed: \"CodecTypes\",\n\t\t\t\talias: \"PgTypes\"\n\t\t\t},\n\t\t\ttypeImports: [\n\t\t\t\t{\n\t\t\t\t\tpackage: \"@internal/target-postgres/codec-types\",\n\t\t\t\t\tnamed: \"JsonValue\",\n\t\t\t\t\talias: \"JsonValue\"\n\t\t\t\t},\n\t\t\t\tcodecTypeImport(\"Char\"),\n\t\t\t\tcodecTypeImport(\"Varchar\"),\n\t\t\t\tcodecTypeImport(\"Numeric\"),\n\t\t\t\tcodecTypeImport(\"Bit\"),\n\t\t\t\tcodecTypeImport(\"VarBit\"),\n\t\t\t\tcodecTypeImport(\"Timestamp\"),\n\t\t\t\tcodecTypeImport(\"Timestamptz\"),\n\t\t\t\tcodecTypeImport(\"Time\"),\n\t\t\t\tcodecTypeImport(\"Timetz\"),\n\t\t\t\tcodecTypeImport(\"Interval\"),\n\t\t\t\tcodecTypeImport(\"TimestampString\"),\n\t\t\t\tcodecTypeImport(\"TimestamptzString\"),\n\t\t\t\tcodecTypeImport(\"TimeString\")\n\t\t\t]\n\t\t}\n\t}\n};\n//#endregion\nexport { postgresAdapterDescriptorMeta as t };\n\n//# sourceMappingURL=descriptor-meta-DThyh4X8.mjs.map"],"mappings":";;;;;AAKA,MAAM,mBAAmB,WAAW;CACnC,SAAS;CACT;CACA,OAAO;AACR;AACA,MAAM,gCAAgC;CACrC,MAAM;CACN,UAAU;CACV,UAAU;CACV,IAAI;CACJ,SAAS;CACT,cAAc;CACd,OAAO;EACN,sBAAsB;EACtB,YAAY;GACX,kBAAkB,MAAM,KAAK,sBAAsB,OAAO,CAAC;GAC3D,QAAQ;IACP,SAAS;IACT,OAAO;IACP,OAAO;GACR;GACA,aAAa;IACZ;KACC,SAAS;KACT,OAAO;KACP,OAAO;IACR;IACA,gBAAgB,MAAM;IACtB,gBAAgB,SAAS;IACzB,gBAAgB,SAAS;IACzB,gBAAgB,KAAK;IACrB,gBAAgB,QAAQ;IACxB,gBAAgB,WAAW;IAC3B,gBAAgB,aAAa;IAC7B,gBAAgB,MAAM;IACtB,gBAAgB,QAAQ;IACxB,gBAAgB,UAAU;IAC1B,gBAAgB,iBAAiB;IACjC,gBAAgB,mBAAmB;IACnC,gBAAgB,YAAY;GAC7B;EACD;CACD;AACD"}
@@ -7,7 +7,7 @@ import { i as PostgresRoleSchemaNode, n as PostgresNamespaceSchemaNode, r as Pos
7
7
  import { n as postgresResolveDefault } from "./default-normalizer-Bf_Fhv4v-CugGfLAe.mjs";
8
8
  import { n as renderFullTextIndexDocument } from "./full-text-search-document-DYNz29YC-CfVTPwIL.mjs";
9
9
  import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-BvsUhPsJ-CY5uEwIr.mjs";
10
- import { d as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-DXaIsgUW-Btyo9Vs8.mjs";
10
+ import { d as resolvePostgresNodeIssueControlPolicySubject } from "./control-policy-BlVJAbUZ-BjQYqA_a.mjs";
11
11
  import { blindCast } from "@prisma/orm-framework/utils/casts";
12
12
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
13
13
  import { diffSchemas, issueOutcome } from "@prisma/orm-framework/components/control";
@@ -16,7 +16,7 @@ import { ifDefined } from "@prisma/orm-framework/utils/defined";
16
16
  import { contractNamespaceToSchemaIR, sqlTypeLookupsOf } from "@prisma/orm-family-sql/family/control";
17
17
  import { PrimaryKey, RelationalSchemaNodeKind, SqlForeignKeyIR, SqlIndexIR, SqlUniqueIR } from "@prisma/orm-family-sql/schema-ir/types";
18
18
  import { classifyDiffSubjectGranularity } from "@prisma/orm-family-sql/family/diff";
19
- //#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema-BV6Px0Gg.mjs
19
+ //#region ../../../3-targets/3-targets/postgres/dist/diff-database-schema-Ce8vWO7g.mjs
20
20
  /** The database root's fixed sentinel id (`PostgresDatabaseSchemaNode#id`). */
21
21
  function databaseStep() {
22
22
  return {
@@ -406,4 +406,4 @@ function buildPostgresPlanDiff(input) {
406
406
  //#endregion
407
407
  export { contractToPostgresDatabaseSchemaNode as n, diffPostgresSchema as r, buildPostgresPlanDiff as t };
408
408
 
409
- //# sourceMappingURL=diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs.map
409
+ //# sourceMappingURL=diff-database-schema-Ce8vWO7g-gdU3XGHC.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"diff-database-schema-BV6Px0Gg-DAC6TL3P.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-BV6Px0Gg.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-Ysxbqkzr.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-DYNz29YC.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-BvsUhPsJ.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-DXaIsgUW.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-BV6Px0Gg.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;EAC3C,WAAW,OAAO;EAClB;EACA,WAAW,OAAO;EAClB,OAAO,CAAC,GAAG,OAAO,KAAK;EACvB,OAAO,OAAO;EACd,WAAW,OAAO;EAClB,YAAY,OAAO;EACnB,WAAW,CAAC,eAAe,aAAa,OAAO,SAAS,GAAG,GAAG,OAAO,MAAM,IAAI,aAAa,CAAC;CAC9F,CAAC;AACF;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAS,qCAAqC,UAAU,SAAS;CAChE,IAAI,aAAa,MAAM,OAAO,IAAI,2BAA2B;EAC5D,YAAY,CAAC;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ACrC;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,QAAQ,iBAAiB,MAAM,mBAAmB;CACxD,MAAM,eAAe,qCAAqC,kBAAkB;EAC3E,qBAAqB;EACrB,gBAAgB,MAAM;EACtB,aAAa,MAAM;EACnB,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-Ce8vWO7g-gdU3XGHC.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/diff-database-schema-Ce8vWO7g.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-Ysxbqkzr.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-DYNz29YC.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-BvsUhPsJ.mjs\";\nimport { i as resolvePostgresNodeIssueControlPolicySubject } from \"./control-policy-BlVJAbUZ.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-Ce8vWO7g.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,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qB,KAAK,GAAG,OAAO;GACxC,QAAQ,gBAAgB,eAAe,kBAAkB,gBAAA,CAAiB,IAAI,gBAAgB;EAC/F,CAAC;CACF;AACD"}
@@ -1,8 +1,8 @@
1
- import "./nodes-C1fPapnK-j0AK7Gcj.mjs";
1
+ import "./nodes-h4zPlhED-nduA-ijW.mjs";
2
2
  import { t as PostgresPlanTargetDetails } from "./planner-target-details-HkP4RrRO-_xPQVPF0.mjs";
3
3
  import { ReferentialAction } from "@prisma/orm-family-sql/contract/types";
4
4
  import { SqlMigrationPlanOperation } from "@prisma/orm-family-sql/family/control";
5
- //#region ../../../3-targets/3-targets/postgres/dist/indexes-BWHRVhke.d.mts
5
+ //#region ../../../3-targets/3-targets/postgres/dist/indexes-Ccd2ehxq.d.mts
6
6
  //#region src/core/migrations/operations/shared.d.ts
7
7
  type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;
8
8
  /**
@@ -46,4 +46,4 @@ interface CreateIndexExtras {
46
46
  }
47
47
  //#endregion
48
48
  export { RenamableConstraintKind as a, Op as i, CreateIndexExtras as n, ForeignKeySpec as r, AlterColumnTypeClass as t };
49
- //# sourceMappingURL=indexes-BWHRVhke-vqXUnRfT.d.mts.map
49
+ //# sourceMappingURL=indexes-Ccd2ehxq-BaM6od9m.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"indexes-Ccd2ehxq-BaM6od9m.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/indexes-Ccd2ehxq.d.mts"],"mappings":";;;;;;KAOK,KAAK,0BAA0B;;;;;;UAM1B;WACC;WACA;WACA;aACE;aACA;aACA;;WAEF,WAAW;WACX,WAAW;;;;;;;;KAQjB;;;KAGA;;;UAGK;WACC;WACA,UAAU;;;;;;WAMV;WACA"}
@@ -1,4 +1,4 @@
1
- import { O as PostgresOpFactoryCall } from "./op-factory-call-DkaMatJ4-D_7fWo-v.mjs";
1
+ import { O as PostgresOpFactoryCall } from "./op-factory-call-Do9gu48J-CNEnsh3K.mjs";
2
2
  import { DataType } from "@prisma/orm-framework/components/codec";
3
3
  import { SqlTypeLookups } from "@prisma/orm-family-sql/contract/data-type";
4
4
  import { SqlStorage, StorageTypeInstance } from "@prisma/orm-family-sql/contract/types";
@@ -114,4 +114,4 @@ interface IssuePlannerOptions {
114
114
  declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
115
115
  //#endregion
116
116
  export { planIssues as n, coalesceSubtreeIssues as t };
117
- //# sourceMappingURL=issue-planner-BiJDKtW5.d.mts.map
117
+ //# sourceMappingURL=issue-planner-C010eVt6.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"issue-planner-BiJDKtW5.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAoBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;WACtC,QAAQ;WACR,QAAQ;WACR,qBAAqB,cAAc;;WAEnC,kBAAkB;;WAElB,oBAAoB;;;;;;;;;KAS1B,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;;WAEpC,mBAAmB;WACnB,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
1
+ {"version":3,"file":"issue-planner-C010eVt6.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/issue-planner.d.mts"],"mappings":";;;;;;;;;;;;;;;;;;;;;UAoBU;WACC,YAAY,SAAS;WACrB,cAAc,SAAS;WACvB;WACA,YAAY,oBAAoB;;WAEhC,OAAO;WACP,cAAc,SAAS,eAAe;WACtC,QAAQ;WACR,QAAQ;WACR,qBAAqB,cAAc;;WAEnC,kBAAkB;;WAElB,oBAAoB;;;;;;;;;KAS1B,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;;WAEpC,mBAAmB;WACnB,sBAAsB;;;;;;;;;iBAShB,WAAW,SAAS,sBAAsB,OAAO,4BAA4B"}
@@ -1,4 +1,4 @@
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";
1
+ import { checkExpression as checkExpression$1, 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
2
  import { sql } from "@prisma/orm-family-sql/contract/sql-expression";
3
3
  import { placeholder } from "@prisma/orm-framework/errors/migration";
4
4
  import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
@@ -17,6 +17,6 @@ function rawSql(op) {
17
17
  return op;
18
18
  }
19
19
  //#endregion
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
+ export { foreignKey as a, primaryKey as c, unique as d, fn$1 as i, rawSql as l, checkExpression$1 as n, lit$1 as o, col$1 as r, placeholder as s, MigrationCLI as t, sql as u };
21
21
 
22
- //# sourceMappingURL=migration-C9ZH26Nj.mjs.map
22
+ //# sourceMappingURL=migration-CbOh59ZJ.mjs.map
@@ -1 +1 @@
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-ltgiEZ8g.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-CLIfS2iQ.mjs\";\nimport { t as dataTransform } from \"./data-transform-CtHnNYhF.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
+ {"version":3,"file":"migration-CbOh59ZJ.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.mjs"],"sourcesContent":["import { V as createExtension } from \"./op-factory-call-Bf00O3tt.mjs\";\nimport { t as PostgresMigration } from \"./postgres-migration-DxPGyge8.mjs\";\nimport { t as dataTransform } from \"./data-transform-CtHnNYhF.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,7 @@
1
1
  import "./data-transform-nGy9rz87-CEOXAj91.mjs";
2
- import { i as Op } from "./indexes-BWHRVhke-vqXUnRfT.mjs";
3
- import "./postgres-migration-D5OiThXV-CihIARAE.mjs";
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";
2
+ import { i as Op } from "./indexes-Ccd2ehxq-BaM6od9m.mjs";
3
+ import "./postgres-migration-Btxi7VsD-DdEHax_e.mjs";
4
+ import { checkExpression as checkExpression$1, 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 { sql } from "@prisma/orm-family-sql/contract/sql-expression";
6
6
  import { placeholder } from "@prisma/orm-framework/errors/migration";
7
7
  import { MigrationCLI } from "@prisma/orm-toolchain/cli/migration-cli";
@@ -22,5 +22,5 @@ declare function createExtension(extensionName: string): Op;
22
22
  */
23
23
  declare function rawSql(op: Op): Op;
24
24
  //#endregion
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-NJo7cPpB.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$1 as n, foreignKey as o, col$1 as r, lit$1 as s, MigrationCLI as t, rawSql as u };
26
+ //# sourceMappingURL=migration-e6FvcwS2.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"migration-NJo7cPpB.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;;iBASiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,KAAK"}
1
+ {"version":3,"file":"migration-e6FvcwS2.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/migration.d.mts"],"mappings":";;;;;;;;;iBASiB,gBAAgB,wBAAwB;;;;;;;;;;;;;iBAaxC,OAAO,IAAI,KAAK"}
@@ -1,5 +1,5 @@
1
1
  import { DdlNode } from "@prisma/orm-family-sql/relational-core/ast";
2
- //#region ../../../3-targets/3-targets/postgres/dist/nodes-Bm2a7z6e.mjs
2
+ //#region ../../../3-targets/3-targets/postgres/dist/nodes-BYKl6zt_.mjs
3
3
  var AlterTableAction = class {};
4
4
  var AddColumnAction = class extends AlterTableAction {
5
5
  kind = "add-column";
@@ -25,6 +25,37 @@ var DropDefaultAction = class extends AlterTableAction {
25
25
  return visitor.dropDefault(this);
26
26
  }
27
27
  };
28
+ var AddConstraintAction = class extends AlterTableAction {
29
+ kind = "add-constraint";
30
+ constraint;
31
+ constructor(constraint) {
32
+ super();
33
+ this.constraint = constraint;
34
+ Object.freeze(this);
35
+ }
36
+ accept(visitor) {
37
+ return visitor.addConstraint(this);
38
+ }
39
+ };
40
+ /**
41
+ * `ALTER COLUMN "<columnName>" TYPE <type> USING <using>`. `type` is written as given. Without `using`, the conversion is `"<columnName>"::<type>`.
42
+ */
43
+ var AlterColumnTypeAction = class extends AlterTableAction {
44
+ kind = "alter-column-type";
45
+ columnName;
46
+ type;
47
+ using;
48
+ constructor(options) {
49
+ super();
50
+ this.columnName = options.columnName;
51
+ this.type = options.type;
52
+ this.using = options.using;
53
+ Object.freeze(this);
54
+ }
55
+ accept(visitor) {
56
+ return visitor.alterColumnType(this);
57
+ }
58
+ };
28
59
  var PostgresDdlNode = class extends DdlNode {};
29
60
  function freezeDdlColumns(columns) {
30
61
  return Object.freeze([...columns]);
@@ -247,6 +278,6 @@ var PostgresDisableRowLevelSecurity = class extends PostgresDdlNode {
247
278
  }
248
279
  };
249
280
  //#endregion
250
- export { PostgresAlterTable as a, PostgresCreateSchema as c, PostgresDdlNode as d, PostgresDisableRowLevelSecurity as f, PostgresDropType as h, PostgresAlterPolicyRename as i, PostgresCreateTable as l, PostgresDropPolicy as m, DropDefaultAction as n, PostgresCreateIndex as o, PostgresDropIndex as p, PostgresAlterIndexRename as r, PostgresCreatePolicy as s, AddColumnAction as t, PostgresCreateType as u };
281
+ export { PostgresDropType as _, PostgresAlterIndexRename as a, PostgresCreateIndex as c, PostgresCreateTable as d, PostgresCreateType as f, PostgresDropPolicy as g, PostgresDropIndex as h, DropDefaultAction as i, PostgresCreatePolicy as l, PostgresDisableRowLevelSecurity as m, AddConstraintAction as n, PostgresAlterPolicyRename as o, PostgresDdlNode as p, AlterColumnTypeAction as r, PostgresAlterTable as s, AddColumnAction as t, PostgresCreateSchema as u };
251
282
 
252
- //# sourceMappingURL=nodes-Bm2a7z6e-BXTXyzZv.mjs.map
283
+ //# sourceMappingURL=nodes-BYKl6zt_-BoUacQ_3.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes-BYKl6zt_-BoUacQ_3.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/nodes-BYKl6zt_.mjs"],"sourcesContent":["import { DdlNode } from \"@internal/sql-relational-core/ast\";\n//#region src/core/ddl/nodes.ts\nvar AlterTableAction = class {};\nvar AddColumnAction = class extends AlterTableAction {\n\tkind = \"add-column\";\n\tcolumn;\n\tconstructor(column) {\n\t\tsuper();\n\t\tthis.column = column;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.addColumn(this);\n\t}\n};\nvar DropDefaultAction = class extends AlterTableAction {\n\tkind = \"drop-default\";\n\tcolumnName;\n\tconstructor(columnName) {\n\t\tsuper();\n\t\tthis.columnName = columnName;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropDefault(this);\n\t}\n};\nvar AddConstraintAction = class extends AlterTableAction {\n\tkind = \"add-constraint\";\n\tconstraint;\n\tconstructor(constraint) {\n\t\tsuper();\n\t\tthis.constraint = constraint;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.addConstraint(this);\n\t}\n};\n/**\n* `ALTER COLUMN \"<columnName>\" TYPE <type> USING <using>`. `type` is written as given. Without `using`, the conversion is `\"<columnName>\"::<type>`.\n*/\nvar AlterColumnTypeAction = class extends AlterTableAction {\n\tkind = \"alter-column-type\";\n\tcolumnName;\n\ttype;\n\tusing;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.columnName = options.columnName;\n\t\tthis.type = options.type;\n\t\tthis.using = options.using;\n\t\tObject.freeze(this);\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterColumnType(this);\n\t}\n};\nvar PostgresDdlNode = class extends DdlNode {};\nfunction freezeDdlColumns(columns) {\n\treturn Object.freeze([...columns]);\n}\nfunction freezeConstraints(constraints) {\n\treturn constraints ? Object.freeze([...constraints]) : void 0;\n}\nvar PostgresCreateTable = class extends PostgresDdlNode {\n\tkind = \"create-table\";\n\ttable;\n\tschema;\n\tifNotExists;\n\tcolumns;\n\tconstraints;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.table = options.table;\n\t\tthis.schema = options.schema;\n\t\tthis.ifNotExists = options.ifNotExists;\n\t\tthis.columns = freezeDdlColumns(options.columns);\n\t\tthis.constraints = freezeConstraints(options.constraints);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createTable(this);\n\t}\n};\nvar PostgresCreateSchema = class extends PostgresDdlNode {\n\tkind = \"create-schema\";\n\tschema;\n\tifNotExists;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.ifNotExists = options.ifNotExists;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createSchema(this);\n\t}\n};\nvar PostgresCreateType = class extends PostgresDdlNode {\n\tkind = \"create-type\";\n\tschema;\n\tname;\n\tvalues;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.values = Object.freeze([...options.values]);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createType(this);\n\t}\n};\nvar PostgresDropType = class extends PostgresDdlNode {\n\tkind = \"drop-type\";\n\tschema;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropType(this);\n\t}\n};\nvar PostgresAlterTable = class extends PostgresDdlNode {\n\tkind = \"alter-table\";\n\ttable;\n\tschema;\n\tactions;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.table = options.table;\n\t\tthis.schema = options.schema;\n\t\tthis.actions = Object.freeze([...options.actions]);\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterTable(this);\n\t}\n};\nvar PostgresCreatePolicy = class extends PostgresDdlNode {\n\tkind = \"create-policy\";\n\tschema;\n\ttable;\n\tname;\n\tpermissive;\n\toperation;\n\troles;\n\tusing;\n\twithCheck;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.permissive = options.permissive;\n\t\tthis.operation = options.operation;\n\t\tthis.roles = Object.freeze([...options.roles]);\n\t\tthis.using = options.using;\n\t\tthis.withCheck = options.withCheck;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createPolicy(this);\n\t}\n};\nvar PostgresDropPolicy = class extends PostgresDdlNode {\n\tkind = \"drop-policy\";\n\tschema;\n\ttable;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropPolicy(this);\n\t}\n};\nvar PostgresAlterPolicyRename = class extends PostgresDdlNode {\n\tkind = \"alter-policy-rename\";\n\tschema;\n\ttable;\n\tname;\n\tnewName;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.newName = options.newName;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterPolicyRename(this);\n\t}\n};\nvar PostgresCreateIndex = class extends PostgresDdlNode {\n\tkind = \"create-index\";\n\t/** Absent ⇔ unqualified (the unbound namespace — `search_path` decides). */\n\tschema;\n\ttable;\n\tname;\n\tunique;\n\telements;\n\ttype;\n\toptions;\n\t/** Partial-index predicate (WHERE body, without the keyword). Never quoted or escaped. */\n\twhere;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.name = options.name;\n\t\tthis.unique = options.unique;\n\t\tthis.elements = \"columns\" in options.elements ? { columns: Object.freeze([...options.elements.columns]) } : { expression: options.elements.expression };\n\t\tthis.type = options.type;\n\t\tthis.options = options.options;\n\t\tthis.where = options.where;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.createIndex(this);\n\t}\n};\nvar PostgresDropIndex = class extends PostgresDdlNode {\n\tkind = \"drop-index\";\n\t/** Absent ⇔ unqualified (the unbound namespace). */\n\tschema;\n\tname;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.name = options.name;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.dropIndex(this);\n\t}\n};\nvar PostgresAlterIndexRename = class extends PostgresDdlNode {\n\tkind = \"alter-index-rename\";\n\t/** Absent ⇔ unqualified (the unbound namespace). */\n\tschema;\n\tfrom;\n\tto;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.from = options.from;\n\t\tthis.to = options.to;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.alterIndexRename(this);\n\t}\n};\nvar PostgresDisableRowLevelSecurity = class extends PostgresDdlNode {\n\tkind = \"disable-row-level-security\";\n\tschema;\n\ttable;\n\tconstructor(options) {\n\t\tsuper();\n\t\tthis.schema = options.schema;\n\t\tthis.table = options.table;\n\t\tthis.freeze();\n\t}\n\taccept(visitor) {\n\t\treturn visitor.disableRowLevelSecurity(this);\n\t}\n};\n//#endregion\nexport { PostgresDropType as _, PostgresAlterIndexRename as a, PostgresCreateIndex as c, PostgresCreateTable as d, PostgresCreateType as f, PostgresDropPolicy as g, PostgresDropIndex as h, DropDefaultAction as i, PostgresCreatePolicy as l, PostgresDisableRowLevelSecurity as m, AddConstraintAction as n, PostgresAlterPolicyRename as o, PostgresDdlNode as p, AlterColumnTypeAction as r, PostgresAlterTable as s, AddColumnAction as t, PostgresCreateSchema as u };\n\n//# sourceMappingURL=nodes-BYKl6zt_.mjs.map"],"mappings":";;AAEA,IAAI,mBAAmB,MAAM,CAAC;AAC9B,IAAI,kBAAkB,cAAc,iBAAiB;CACpD,OAAO;CACP;CACA,YAAY,QAAQ;EACnB,MA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B,KAAK,OAAO;CACb;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,YAAY,IAAI;CAChC;AACD;AACA,IAAI,oBAAoB,cAAc,gBAAgB;CACrD,OAAO;;CAEP;CACA;CACA,YAAY,SAAS;EACpB,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;EACpB,KAAK,OAAO;CACb;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,UAAU,IAAI;CAC9B;AACD;AACA,IAAI,2BAA2B,cAAc,gBAAgB;CAC5D,OAAO;;CAEP;CACA;CACA;CACA,YAAY,SAAS;EACpB,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,OAAO,QAAQ;EACpB,KAAK,KAAK,QAAQ;EAClB,KAAK,OAAO;CACb;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,iBAAiB,IAAI;CACrC;AACD;AACA,IAAI,kCAAkC,cAAc,gBAAgB;CACnE,OAAO;CACP;CACA;CACA,YAAY,SAAS;EACpB,MAAM;EACN,KAAK,SAAS,QAAQ;EACtB,KAAK,QAAQ,QAAQ;EACrB,KAAK,OAAO;CACb;CACA,OAAO,SAAS;EACf,OAAO,QAAQ,wBAAwB,IAAI;CAC5C;AACD"}
@@ -1,10 +1,12 @@
1
1
  import { r as RlsPolicyOperation } from "./canonicalize-CQlxSR4D-MnrT5gtW.mjs";
2
2
  import { DdlColumn, DdlNode, DdlTableConstraint, OpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
3
- //#region ../../../3-targets/3-targets/postgres/dist/nodes-C1fPapnK.d.mts
3
+ //#region ../../../3-targets/3-targets/postgres/dist/nodes-h4zPlhED.d.mts
4
4
  //#region src/core/ddl/nodes.d.ts
5
5
  interface AlterTableActionVisitor<R> {
6
6
  addColumn(action: AddColumnAction): R;
7
7
  dropDefault(action: DropDefaultAction): R;
8
+ addConstraint(action: AddConstraintAction): R;
9
+ alterColumnType(action: AlterColumnTypeAction): R;
8
10
  }
9
11
  declare abstract class AlterTableAction {
10
12
  abstract readonly kind: string;
@@ -22,16 +24,31 @@ declare class DropDefaultAction extends AlterTableAction {
22
24
  constructor(columnName: string);
23
25
  accept<R>(visitor: AlterTableActionVisitor<R>): R;
24
26
  }
27
+ declare class AddConstraintAction extends AlterTableAction {
28
+ readonly kind: "add-constraint";
29
+ readonly constraint: DdlTableConstraint;
30
+ constructor(constraint: DdlTableConstraint);
31
+ accept<R>(visitor: AlterTableActionVisitor<R>): R;
32
+ }
33
+ /**
34
+ * `ALTER COLUMN "<columnName>" TYPE <type> USING <using>`. `type` is written as given. Without `using`, the conversion is `"<columnName>"::<type>`.
35
+ */
36
+ declare class AlterColumnTypeAction extends AlterTableAction {
37
+ readonly kind: "alter-column-type";
38
+ readonly columnName: string;
39
+ readonly type: string;
40
+ readonly using: OpaqueSql | undefined;
41
+ constructor(options: {
42
+ readonly columnName: string;
43
+ readonly type: string;
44
+ readonly using: OpaqueSql | undefined;
45
+ });
46
+ accept<R>(visitor: AlterTableActionVisitor<R>): R;
47
+ }
25
48
  /**
26
- * The set of ALTER TABLE subactions currently expressible as typed DDL.
27
- *
28
- * The remaining actions — SetDefault, SetNotNull, DropNotNull,
29
- * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`
30
- * and join this union as they are converted to typed DDL. Until then it is
31
- * intentionally partial: only the ALTER subactions used by the
32
- * already-converted ops (AddColumn, DropDefault) appear here.
49
+ * The ALTER TABLE subactions expressible as typed DDL. Other ALTER TABLE statements, such as the primary key, unique and foreign key `ADD CONSTRAINT` in `operations/constraints.ts` and the remaining column actions in `operations/columns.ts`, are built as template strings.
33
50
  */
34
- type AnyAlterTableAction = AddColumnAction | DropDefaultAction;
51
+ type AnyAlterTableAction = AddColumnAction | DropDefaultAction | AddConstraintAction | AlterColumnTypeAction;
35
52
  interface PostgresDdlVisitor<R> {
36
53
  createTable(node: PostgresCreateTable): R;
37
54
  createSchema(node: PostgresCreateSchema): R;
@@ -233,5 +250,5 @@ declare class PostgresDisableRowLevelSecurity extends PostgresDdlNode {
233
250
  }
234
251
  type AnyPostgresDdlNode = PostgresCreateTable | PostgresCreateSchema | PostgresCreateType | PostgresDropType | PostgresAlterTable | PostgresCreatePolicy | PostgresDropPolicy | PostgresAlterPolicyRename | PostgresCreateIndex | PostgresDropIndex | PostgresAlterIndexRename | PostgresDisableRowLevelSecurity;
235
252
  //#endregion
236
- export { PostgresDdlVisitor as _, CreateIndexElements as a, PostgresDropPolicy as b, PostgresAlterIndexRename as c, PostgresCreateIndex as d, PostgresCreatePolicy as f, PostgresDdlNode as g, PostgresCreateType as h, AnyPostgresDdlNode as i, PostgresAlterPolicyRename as l, PostgresCreateTable as m, AlterTableActionVisitor as n, DdlIndexElements as o, PostgresCreateSchema as p, AnyAlterTableAction as r, DropDefaultAction as s, AddColumnAction as t, PostgresAlterTable as u, PostgresDisableRowLevelSecurity as v, PostgresDropType as x, PostgresDropIndex as y };
237
- //# sourceMappingURL=nodes-C1fPapnK-j0AK7Gcj.d.mts.map
253
+ export { PostgresDropType as C, PostgresDropPolicy as S, PostgresCreateType as _, AnyAlterTableAction as a, PostgresDisableRowLevelSecurity as b, DdlIndexElements as c, PostgresAlterPolicyRename as d, PostgresAlterTable as f, PostgresCreateTable as g, PostgresCreateSchema as h, AlterTableActionVisitor as i, DropDefaultAction as l, PostgresCreatePolicy as m, AddConstraintAction as n, AnyPostgresDdlNode as o, PostgresCreateIndex as p, AlterColumnTypeAction as r, CreateIndexElements as s, AddColumnAction as t, PostgresAlterIndexRename as u, PostgresDdlNode as v, PostgresDropIndex as x, PostgresDdlVisitor as y };
254
+ //# sourceMappingURL=nodes-h4zPlhED-nduA-ijW.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nodes-h4zPlhED-nduA-ijW.d.mts","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/nodes-h4zPlhED.d.mts"],"mappings":";;;;UAGU,wBAAwB;EAChC,UAAU,QAAQ,kBAAkB;EACpC,YAAY,QAAQ,oBAAoB;E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,mBAAmB,KAAK;;KAExC,qBAAqB,sBAAsB,uBAAuB,qBAAqB,mBAAmB,qBAAqB,uBAAuB,qBAAqB,4BAA4B,sBAAsB,oBAAoB,2BAA2B"}
@@ -1,23 +1,23 @@
1
1
  import { s as postgresError } from "./errors-DYyzTYzE-39CV_aMo.mjs";
2
2
  import { i as quoteIdentifier, n as escapeLiteral, o as quoteQualifiedName, s as validateEnumValueLength, t as POSTGRES_QUOTING } from "./sql-utils-Df-nf6eM-Ov1KgjWm.mjs";
3
3
  import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs";
4
- import { A as tableIsEmptyAst, C as nativeEnumTypeExistsAst, D as rlsPolicyExistsAst, E as rlsEnabledAst, O as sequenceNameAvailableAst, S as indexExistsAst, T as noNullValuesAst, _ as dropDefaultAction, a as columnDefaultAst, b as dropType, c as columnNullabilityAst, d as createIndex$1, f as createPolicy, g as disableRowLevelSecurity$1, h as createType, i as alterTable, k as tableExistsAst, l as columnTypeAst, m as createTable, n as alterIndexRename, o as columnDefaultSequenceAst, p as createSchema, r as alterPolicyRename, s as columnExistsAst, t as addColumnAction, u as constraintExistsAst, v as dropIndex$1, w as nativeEnumValueExistsAst, x as extensionExistsAst, y as dropPolicy } from "./ddl-BKqbtVN3-CPHiYaCY.mjs";
4
+ import { A as sequenceNameAvailableAst, C as extensionExistsAst, D as noNullValuesAst, E as nativeEnumValueExistsAst, M as tableIsEmptyAst, O as rlsEnabledAst, S as dropType, T as nativeEnumTypeExistsAst, _ as createType, a as alterPolicyRename, b as dropIndex$1, c as columnDefaultSequenceAst, d as columnTypeAst, f as constraintExistsAst, g as createTable, h as createSchema, i as alterIndexRename, j as tableExistsAst, k as rlsPolicyExistsAst, l as columnExistsAst, m as createPolicy, n as addConstraintAction, o as alterTable, p as createIndex$1, r as alterColumnTypeAction, s as columnDefaultAst, t as addColumnAction, u as columnNullabilityAst, v as disableRowLevelSecurity$1, w as indexExistsAst, x as dropPolicy, y as dropDefaultAction } from "./ddl-B6lRIezE-BMI5qzD2.mjs";
5
5
  import { t as autoincrementWidth } from "./autoincrement-widths-DbyXRo5B-BUVCYb_V.mjs";
6
6
  import { t as postgresObjectName } from "./postgres-object-name-FPikIvOw-BNs44hTu.mjs";
7
7
  import { r as qualifyTableName, t as alterTypeCheckText } from "./planner-sql-checks-CX37qDix-Gkq38UQQ.mjs";
8
8
  import { t as buildTargetDetails } from "./planner-target-details-CUEF0s90-COTks5yz.mjs";
9
- import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql, renderOpaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
9
+ import { DdlColumn, FunctionColumnDefault, LiteralColumnDefault, opaqueSql } from "@prisma/orm-family-sql/relational-core/ast";
10
10
  import { blindCast } from "@prisma/orm-framework/utils/casts";
11
11
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
12
12
  import { namingOf } from "@prisma/orm-family-sql/schema-ir/naming";
13
13
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
14
- import { col } from "@prisma/orm-family-sql/relational-core/contract-free";
14
+ import { checkExpression, col } from "@prisma/orm-family-sql/relational-core/contract-free";
15
15
  import { checkSqlDefaultText, checkSqlExpressionText, convertedColumnMeta, createSqlTextSources, isUnfilledSlot, requiredColumnMeta, slotSource, sqlOfSlot } from "@prisma/orm-family-sql/family/control";
16
16
  import { InternalError, assertNever } from "@prisma/orm-framework/utils/internal-error";
17
17
  import { unfilledPlaceholderOperation } from "@prisma/orm-framework/errors/migration";
18
18
  import { TsExpression, jsonToTsSource, tsObjectSource } from "@prisma/orm-framework/ts-render";
19
19
  import { REFERENTIAL_ACTION_SQL } from "@prisma/orm-family-sql/contract/referential-action-sql";
20
- //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-ltgiEZ8g.mjs
20
+ //#region ../../../3-targets/3-targets/postgres/dist/op-factory-call-Bf00O3tt.mjs
21
21
  /**
22
22
  * Maps a planner schema name to the contract-free DDL builder's optional
23
23
  * `schema` field: the unbound sentinel becomes `undefined` (the builder omits
@@ -106,8 +106,6 @@ async function renameColumn(schemaName, tableName, fromName, toName, lowerer) {
106
106
  * `checkType` is the type `format_type` prints for it, which the postcheck compares.
107
107
  */
108
108
  async function alterColumnType(schemaName, tableName, columnName, options, lowerer, operationClass = "destructive") {
109
- const qualified = qualifyTableName(schemaName, tableName);
110
- const usingClause = options.using ? ` USING ${renderOpaqueSql(opaqueSql(options.using))}` : ` USING ${quoteIdentifier(columnName)}::${options.type}`;
111
109
  const { present } = await columnExistsSteps(lowerer, {
112
110
  schema: schemaName,
113
111
  table: tableName,
@@ -119,6 +117,15 @@ async function alterColumnType(schemaName, tableName, columnName, options, lower
119
117
  column: columnName,
120
118
  expectedType: options.checkType
121
119
  }));
120
+ const alterType = await lowerer.lowerToExecuteRequest(alterTable({
121
+ ...ifDefined("schema", boundSchema(schemaName)),
122
+ table: tableName,
123
+ actions: [alterColumnTypeAction({
124
+ columnName,
125
+ type: options.type,
126
+ ...ifDefined("using", options.using)
127
+ })]
128
+ }));
122
129
  return {
123
130
  id: `alterType.${tableName}.${columnName}`,
124
131
  label: `Alter type of "${tableName}"."${columnName}" to ${options.type}`,
@@ -126,7 +133,7 @@ async function alterColumnType(schemaName, tableName, columnName, options, lower
126
133
  target: targetDetails("column", columnName, schemaName, tableName),
127
134
  precheck: [step(`ensure column "${columnName}" exists`, present.sql, present.params)],
128
135
  execute: [{
129
- ...step(`alter type of "${columnName}"`, `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} TYPE ${options.type}${usingClause}`),
136
+ ...step(`alter type of "${columnName}"`, alterType.sql),
130
137
  ...options.using !== void 0 ? { meta: convertedColumnMeta(tableName, columnName, "conversion") } : operationClass === "destructive" ? { meta: convertedColumnMeta(tableName, columnName, "cast") } : {}
131
138
  }],
132
139
  postcheck: [step(`verify column "${columnName}" has type "${options.checkType}"`, typeCheck.sql, typeCheck.params)],
@@ -430,19 +437,23 @@ async function addForeignKey(schemaName, tableName, fk, lowerer) {
430
437
  };
431
438
  }
432
439
  async function addCheckConstraint(schemaName, tableName, constraintName, expression, lowerer) {
433
- const qualified = qualifyTableName(schemaName, tableName);
434
440
  const { absent, present } = await constraintCheckSteps(lowerer, {
435
441
  constraintName,
436
442
  schema: schemaName,
437
443
  table: tableName
438
444
  });
445
+ const addCheck = await lowerer.lowerToExecuteRequest(alterTable({
446
+ ...ifDefined("schema", boundSchema(schemaName)),
447
+ table: tableName,
448
+ actions: [addConstraintAction(checkExpression(constraintName, expression))]
449
+ }));
439
450
  return {
440
451
  id: `checkConstraint.${tableName}.${constraintName}`,
441
452
  label: `Add check constraint "${constraintName}" on "${tableName}"`,
442
453
  operationClass: "additive",
443
454
  target: targetDetails("checkConstraint", constraintName, schemaName, tableName),
444
455
  precheck: [step(`ensure constraint "${constraintName}" does not exist`, absent.sql, absent.params)],
445
- execute: [step(`add check constraint "${constraintName}"`, `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${renderOpaqueSql(opaqueSql(expression))})`)],
456
+ execute: [step(`add check constraint "${constraintName}"`, addCheck.sql)],
446
457
  postcheck: [step(`verify constraint "${constraintName}" exists`, present.sql, present.params)]
447
458
  };
448
459
  }
@@ -2419,4 +2430,4 @@ function columnNameOfCall(call) {
2419
2430
  //#endregion
2420
2431
  export { RenameConstraintCall as A, isPostgresOpFactoryCall as B, DropNativeEnumTypeCall as C, EnableRowLevelSecurityCall as D, DropTableCall as E, SetNotNullCall as F, renameTableStatement as H, alterColumnTypeCallText 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 _, AddNativeEnumValueCall as a, DropConstraintCall as b, AddUniqueCall as c, CreateIndexCall as d, CreateNativeEnumTypeCall as f, DataTransformCall as g, CreateTableCall as h, AddForeignKeyCall as i, RenameIndexCall as j, RenameColumnCall as k, AlterColumnTypeCall as l, CreateSchemaCall as m, AddColumnCall as n, AddPrimaryKeyCall as o, CreatePostgresRlsPolicyCall as p, AddColumnWithTemporaryDefaultCall as r, AddRequiredColumnToEmptyTableCall as s, AddCheckConstraintCall as t, CreateExtensionCall as u, DropCheckConstraintCall as v, DropNotNullCall as w, DropDefaultCall as x, DropColumnCall as y, installExtension as z };
2421
2432
 
2422
- //# sourceMappingURL=op-factory-call-ltgiEZ8g-CX6WX57X.mjs.map
2433
+ //# sourceMappingURL=op-factory-call-Bf00O3tt-aQ8OJ00n.mjs.map