@prisma/orm-target-postgres 0.17.0-dev.1 → 0.17.0-dev.11

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 (70) hide show
  1. package/dist/{adapter-DhqcO3YO-jzwDVcCv.mjs → adapter-BwjBEeND-B7-Hx3r9.mjs} +10 -4
  2. package/dist/adapter-BwjBEeND-B7-Hx3r9.mjs.map +1 -0
  3. package/dist/adapter.d.mts +2 -1
  4. package/dist/adapter.mjs +4 -3
  5. package/dist/adapter__adapter.mjs +1 -1
  6. package/dist/adapter__control.mjs +2 -2
  7. package/dist/adapter__control.mjs.map +1 -1
  8. package/dist/adapter__runtime.mjs +4 -4
  9. package/dist/adapter__runtime.mjs.map +1 -1
  10. package/dist/adapter__sql-renderer.d.mts +2 -0
  11. package/dist/adapter__sql-renderer.mjs +2 -0
  12. package/dist/aggregates-CgqNfj2O.d.mts +10 -0
  13. package/dist/aggregates-CgqNfj2O.d.mts.map +1 -0
  14. package/dist/aggregates-ftUgi-eC.mjs +102 -0
  15. package/dist/aggregates-ftUgi-eC.mjs.map +1 -0
  16. package/dist/{codecs-CBl0nD44-CaWPc1bd.mjs → codecs-CBl0nD44-CjInu_aV.mjs} +2 -2
  17. package/dist/{codecs-CBl0nD44-CaWPc1bd.mjs.map → codecs-CBl0nD44-CjInu_aV.mjs.map} +1 -1
  18. package/dist/{codecs-CHIVTNZs.mjs → codecs-rujsdlZR.mjs} +2 -2
  19. package/dist/{codecs-CHIVTNZs.mjs.map → codecs-rujsdlZR.mjs.map} +1 -1
  20. package/dist/{control-DRMWptiJ.mjs → control-BzDnaGim.mjs} +5 -5
  21. package/dist/{control-DRMWptiJ.mjs.map → control-BzDnaGim.mjs.map} +1 -1
  22. package/dist/{control-adapter-B9t0g7Pf-HrCxlM65.mjs → control-adapter-CipVam9p-B-E2SF8_.mjs} +9 -578
  23. package/dist/control-adapter-CipVam9p-B-E2SF8_.mjs.map +1 -0
  24. package/dist/{control-policy-Cl3RRSPg-CT3QGpR3.mjs → control-policy-Cl3RRSPg-BUi6pcI-.mjs} +3 -3
  25. package/dist/{control-policy-Cl3RRSPg-CT3QGpR3.mjs.map → control-policy-Cl3RRSPg-BUi6pcI-.mjs.map} +1 -1
  26. package/dist/{descriptor-meta-2IlVC6_d-DnV00Qd_.mjs → descriptor-meta--MCrvIgj-DFsLFDj1.mjs} +6 -4
  27. package/dist/descriptor-meta--MCrvIgj-DFsLFDj1.mjs.map +1 -0
  28. package/dist/{descriptor-meta-DnHabAS3-C53XXPQw.mjs → descriptor-meta-DnHabAS3-BiTguA3K.mjs} +2 -2
  29. package/dist/{descriptor-meta-DnHabAS3-C53XXPQw.mjs.map → descriptor-meta-DnHabAS3-BiTguA3K.mjs.map} +1 -1
  30. package/dist/{diff-database-schema-BfRs2vrG-D2o4KII0.mjs → diff-database-schema-BfRs2vrG-DInOv5LW.mjs} +2 -2
  31. package/dist/{diff-database-schema-BfRs2vrG-D2o4KII0.mjs.map → diff-database-schema-BfRs2vrG-DInOv5LW.mjs.map} +1 -1
  32. package/dist/driver.d.mts +1 -1
  33. package/dist/driver__runtime.d.mts +1 -1
  34. package/dist/driver__runtime.mjs +107 -70
  35. package/dist/driver__runtime.mjs.map +1 -1
  36. package/dist/{op-factory-call-DifL68KT-Bo6pxs-R.mjs → op-factory-call-DifL68KT-CNFEDNsf.mjs} +2 -2
  37. package/dist/{op-factory-call-DifL68KT-Bo6pxs-R.mjs.map → op-factory-call-DifL68KT-CNFEDNsf.mjs.map} +1 -1
  38. package/dist/{planner-Bmje9ii8-B99fEsNM.mjs → planner-Bmje9ii8-DdjXZxyD.mjs} +5 -5
  39. package/dist/{planner-Bmje9ii8-B99fEsNM.mjs.map → planner-Bmje9ii8-DdjXZxyD.mjs.map} +1 -1
  40. package/dist/{planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs → planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs} +2 -2
  41. package/dist/{planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs.map → planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs.map} +1 -1
  42. package/dist/{planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs → planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs} +2 -2
  43. package/dist/{planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs.map → planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs.map} +1 -1
  44. package/dist/{postgres-migration-CJshdIZn-DYYjgdD0.mjs → postgres-migration-CJshdIZn-CT6Cxd4x.mjs} +2 -2
  45. package/dist/{postgres-migration-CJshdIZn-DYYjgdD0.mjs.map → postgres-migration-CJshdIZn-CT6Cxd4x.mjs.map} +1 -1
  46. package/dist/{runtime-CDewySU9.d.mts → runtime-lHBKgjB9.d.mts} +3 -2
  47. package/dist/runtime-lHBKgjB9.d.mts.map +1 -0
  48. package/dist/sql-renderer-CZE98PJj-Bx5D-Txz.mjs +579 -0
  49. package/dist/sql-renderer-CZE98PJj-Bx5D-Txz.mjs.map +1 -0
  50. package/dist/sql-renderer-Cyls5Xy4.d.mts +19 -0
  51. package/dist/sql-renderer-Cyls5Xy4.d.mts.map +1 -0
  52. package/dist/target.d.mts +2 -1
  53. package/dist/target.mjs +13 -12
  54. package/dist/target__aggregates.d.mts +2 -0
  55. package/dist/target__aggregates.mjs +2 -0
  56. package/dist/target__codecs.mjs +2 -2
  57. package/dist/target__control.mjs +1 -1
  58. package/dist/target__diff-database-schema.mjs +1 -1
  59. package/dist/target__issue-planner.mjs +1 -1
  60. package/dist/target__migration.mjs +2 -2
  61. package/dist/target__op-factory-call.mjs +1 -1
  62. package/dist/target__pack.mjs +1 -1
  63. package/dist/target__planner-ddl-builders.mjs +1 -1
  64. package/dist/target__planner-produced-postgres-migration.mjs +1 -1
  65. package/dist/target__planner.mjs +2 -2
  66. package/package.json +11 -9
  67. package/dist/adapter-DhqcO3YO-jzwDVcCv.mjs.map +0 -1
  68. package/dist/control-adapter-B9t0g7Pf-HrCxlM65.mjs.map +0 -1
  69. package/dist/descriptor-meta-2IlVC6_d-DnV00Qd_.mjs.map +0 -1
  70. package/dist/runtime-CDewySU9.d.mts.map +0 -1
@@ -2,10 +2,10 @@ import { t as DEFAULT_NAMESPACE_ID } from "./namespace-ids-xtp_ZY86-Cpp8PTxD.mjs
2
2
  import { d as isPostgresSchema, i as PostgresRlsPolicy } from "./postgres-schema-KSzLDONj-CsXGoY8b.mjs";
3
3
  import { n as PostgresNamespaceSchemaNode, r as PostgresPolicySchemaNode, t as PostgresDatabaseSchemaNode } from "./postgres-role-schema-node-B8Z5i5D--PObwlU2Z.mjs";
4
4
  import { t as resolveDdlSchemaForNamespaceStorage } from "./resolve-ddl-schema-CxqlLW47-0GiHRziS.mjs";
5
- import { A as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, k as RenameIndexCall, p as CreatePostgresRlsPolicyCall } from "./op-factory-call-DifL68KT-Bo6pxs-R.mjs";
6
- import { a as planIssues, c as renderPostgresSuppression, d as resolvePostgresNodeIssueControlPolicySubject, f as resolvePostgresNodeIssueCreationFactoryName, i as issueSchemaName, l as resolveNamespaceIdForDdlSchema, n as conflictForDisallowedCall, o as postgresNodeStorageCoordinate, r as issueNode, s as postgresPlannerStrategies, t as coalesceSubtreeIssues, u as resolvePostgresCallControlPolicySubject } from "./control-policy-Cl3RRSPg-CT3QGpR3.mjs";
7
- import { t as buildPostgresPlanDiff } from "./diff-database-schema-BfRs2vrG-D2o4KII0.mjs";
8
- import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs";
5
+ import { A as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, k as RenameIndexCall, p as CreatePostgresRlsPolicyCall } from "./op-factory-call-DifL68KT-CNFEDNsf.mjs";
6
+ import { a as planIssues, c as renderPostgresSuppression, d as resolvePostgresNodeIssueControlPolicySubject, f as resolvePostgresNodeIssueCreationFactoryName, i as issueSchemaName, l as resolveNamespaceIdForDdlSchema, n as conflictForDisallowedCall, o as postgresNodeStorageCoordinate, r as issueNode, s as postgresPlannerStrategies, t as coalesceSubtreeIssues, u as resolvePostgresCallControlPolicySubject } from "./control-policy-Cl3RRSPg-BUi6pcI-.mjs";
7
+ import { t as buildPostgresPlanDiff } from "./diff-database-schema-BfRs2vrG-DInOv5LW.mjs";
8
+ import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs";
9
9
  import { blindCast } from "@prisma/orm-framework/utils/casts";
10
10
  import { UNBOUND_NAMESPACE_ID } from "@prisma/orm-framework/components/ir";
11
11
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -585,4 +585,4 @@ function policyNodeToContractPolicy(node) {
585
585
  //#endregion
586
586
  export { createPostgresMigrationPlanner as t };
587
587
 
588
- //# sourceMappingURL=planner-Bmje9ii8-B99fEsNM.mjs.map
588
+ //# sourceMappingURL=planner-Bmje9ii8-DdjXZxyD.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-Bmje9ii8-B99fEsNM.mjs","names":["#lowerer"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-Bmje9ii8.mjs"],"sourcesContent":["import { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { _ as PostgresRlsPolicy, r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { t as buildPostgresPlanDiff } from \"./diff-database-schema-BfRs2vrG.mjs\";\nimport { a as resolvePostgresNodeIssueCreationFactoryName, c as issueNode, d as postgresPlannerStrategies, f as postgresNodeStorageCoordinate, i as resolvePostgresNodeIssueControlPolicySubject, l as issueSchemaName, n as resolveNamespaceIdForDdlSchema, o as coalesceSubtreeIssues, r as resolvePostgresCallControlPolicySubject, s as conflictForDisallowedCall, t as renderPostgresSuppression, u as planIssues } from \"./control-policy-Cl3RRSPg.mjs\";\nimport { A as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, k as RenameIndexCall, p as CreatePostgresRlsPolicyCall } from \"./op-factory-call-DifL68KT.mjs\";\nimport { t as TypeScriptRenderablePostgresMigration } from \"./planner-produced-postgres-migration-Cicg2sXg.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { controlPolicyForCall, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { SqlIndexIR } from \"@internal/sql-schema-ir/types\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\n//#region src/core/migrations/verify-postgres-namespaces.ts\n/**\n* Resolves the live-database schema name for a given namespace\n* coordinate. Mirrors `resolveDdlSchemaForNamespace` in\n* `planner-strategies.ts` so the verifier's projection and the\n* planner's projection always agree — Postgres-aware namespaces (the\n* production path) dispatch to `ddlSchemaName(storage)`, and bare\n* object payloads (used by some tests) fall back to the coordinate\n* itself.\n*/\nfunction resolveDdlSchemaName(storage, namespaceId) {\n\tconst namespace = storage.namespaces[namespaceId];\n\tif (isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);\n\treturn namespaceId;\n}\n/**\n* Reads the introspected list of schema names from the database-root schema\n* node. `existingSchemas` is database-level, so it lives on the\n* `PostgresDatabaseSchemaNode` root — not on the per-schema namespace nodes.\n*\n* Defaults to the always-present `public` schema when the node is not the\n* database root — a fresh Postgres database always carries `public` (unless an\n* operator dropped it manually), so any verifier path that runs without an\n* enriched introspection still suppresses the redundant `CREATE SCHEMA\n* \"public\"`.\n*\n* Production introspection (`PostgresControlAdapter.introspect`) is the\n* authoritative source: it queries `pg_namespace` and sets `existingSchemas`\n* on the returned root. Tests that want to assert against a richer initial\n* state construct a `PostgresDatabaseSchemaNode` explicitly.\n*/\nfunction existingSchemasFromSchema(schema) {\n\tif (PostgresDatabaseSchemaNode.is(schema)) return schema.existingSchemas;\n\treturn [DEFAULT_NAMESPACE_ID];\n}\n/**\n* Emits a `postgres-namespace` `not-found` diff issue for every\n* contract-declared Postgres namespace whose live container does not yet\n* exist. The planner prepends these (node-typed, synthesized) to the\n* relational diff issues so a multi-schema plan emits `CREATE SCHEMA`\n* before the tables that need it — a planner-only concern (verify already\n* rejects via the `not-found` table issues a missing schema already\n* produces), so this is not part of the shared diff.\n*\n* A namespace's live container is the schema returned by its\n* polymorphic `ddlSchemaName(storage)` method — named schemas resolve\n* to their own id; the unbound singleton returns `UNBOUND_NAMESPACE_ID`\n* and is skipped explicitly (late-bound namespaces have no fixed DDL\n* schema). Issues are emitted only when the resolved name is a real,\n* creatable schema (not the unbound sentinel) and is missing from the\n* introspected list. `public` is suppressed implicitly because the\n* introspection (or its sensible default) always carries it.\n*\n* Each emitted issue's path is `['database', ddlName]` — an ancestor of\n* every table path under that schema, so it must never be run through\n* `coalesceSubtreeIssues` alongside the table diff (it would swallow the\n* table-level `not-found` issues that drive `CREATE TABLE`); the planner\n* adds these AFTER coalescing the relational issues, and they are not\n* subject to sibling-space ownership scoping (mirrors the retired\n* coordinate walk, which prepended namespace issues after that filter).\n*/\nfunction verifyPostgresNamespacePresence(input) {\n\tconst { contract, schema } = input;\n\tconst existing = new Set(existingSchemasFromSchema(schema));\n\tconst issues = [];\n\tconst namespaceIds = Object.keys(contract.storage.namespaces).sort();\n\tfor (const namespaceId of namespaceIds) {\n\t\tif (namespaceId === UNBOUND_NAMESPACE_ID) continue;\n\t\tconst ddlName = resolveDdlSchemaName(contract.storage, namespaceId);\n\t\tif (ddlName === UNBOUND_NAMESPACE_ID) continue;\n\t\tif (existing.has(ddlName)) continue;\n\t\tconst namespace = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlName,\n\t\t\ttables: {}\n\t\t});\n\t\tissues.push({\n\t\t\tpath: [\"database\", ddlName],\n\t\t\texpected: namespace\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/core/migrations/planner.ts\nfunction createPostgresMigrationPlanner(lowerer) {\n\treturn new PostgresMigrationPlanner(lowerer);\n}\n/**\n* Postgres migration planner — a thin wrapper over `planIssues`.\n*\n* `plan()` diffs the target contract against the live schema via the one\n* differ (`buildPostgresPlanDiff`, producing node-typed `SchemaDiffIssue[]`)\n* and delegates to `planIssues` with the unified `postgresPlannerStrategies`\n* list: NOT-NULL backfill, type-change, nullable-tightening, codec-hook\n* storage types, component-declared dependency installs, and\n* shared-temp-default / empty-table-guarded NOT-NULL add-column. The same\n* strategy list runs for `migration plan`, `db update`, and `db init`;\n* behavior diverges purely on `policy.allowedOperationClasses` (the\n* data-safe strategies short-circuit when `'data'` is excluded). The issue\n* planner applies operation-class policy gates and emits a single\n* `PostgresOpFactoryCall[]` that drives both the runtime-ops view (via\n* `renderOps`) and the `renderTypeScript()` authoring surface. RLS policy\n* drift (the structural half of the same one-differ tree) is handled\n* separately via `planPostgresSchemaDiff`.\n*/\nvar PostgresMigrationPlanner = class {\n\t#lowerer;\n\tconstructor(lowerer) {\n\t\tthis.#lowerer = lowerer;\n\t}\n\tplan(options) {\n\t\treturn this.planSql(options);\n\t}\n\temptyMigration(context, spaceId) {\n\t\treturn new TypeScriptRenderablePostgresMigration([], {\n\t\t\tfrom: context.fromHash,\n\t\t\tto: context.toHash\n\t\t}, spaceId, context.snapshotsImportPath, this.#lowerer);\n\t}\n\tplanSql(options) {\n\t\tconst schemaName = options.schemaName ?? Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;\n\t\tconst policyResult = this.ensureAdditivePolicy(options.policy);\n\t\tif (policyResult) return policyResult;\n\t\tPostgresDatabaseSchemaNode.assert(options.schema);\n\t\tconst { issues: rawIssues } = buildPostgresPlanDiff({\n\t\t\tcontract: options.contract,\n\t\t\tactualSchema: options.schema,\n\t\t\tframeworkComponents: options.frameworkComponents\n\t\t});\n\t\tconst policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue));\n\t\tconst relationalDiffIssues = rawIssues.filter((issue) => !isPolicyDiffIssue(issue));\n\t\tconst strict = options.policy.allowedOperationClasses.includes(\"widening\") || options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst owned = retainUnownedExtras(coalesceSubtreeIssues(relationalDiffIssues), options.ownership, options.contract);\n\t\tconst gated = strict ? owned : owned.filter((issue) => issueOutcome(issue) !== \"not-expected\");\n\t\tconst schemaIssues = [...verifyPostgresNamespacePresence({\n\t\t\tcontract: options.contract,\n\t\t\tschema: options.schema\n\t\t}), ...gated];\n\t\tconst indexRenames = this.pairIndexRenames(options, schemaIssues);\n\t\tconst plannableIssues = indexRenames.consumed.size === 0 ? schemaIssues : schemaIssues.filter((issue) => !indexRenames.consumed.has(issue));\n\t\tconst codecHooks = extractCodecControlHooks(options.frameworkComponents);\n\t\tconst storageTypes = options.contract.storage.types ?? {};\n\t\tconst relationalSchema = relationalNamespaceNode(options.schema, schemaName);\n\t\tconst issuePartition = partitionIssuesByControlPolicy({\n\t\t\tissues: plannableIssues,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n\t\t\tresolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName\n\t\t});\n\t\tconst result = planIssues({\n\t\t\tissues: issuePartition.plannable,\n\t\t\ttoContract: options.contract,\n\t\t\tfromContract: options.fromContract,\n\t\t\tschemaName,\n\t\t\tcodecHooks,\n\t\t\tstorageTypes,\n\t\t\t...ifDefined(\"schema\", relationalSchema),\n\t\t\tpolicy: options.policy,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\tstrategies: postgresPlannerStrategies\n\t\t});\n\t\tconst schemaDiff = this.planPostgresSchemaDiff(options, policyDiffIssues);\n\t\tif (!result.ok || schemaDiff.conflicts.length > 0) return plannerFailure([...result.ok ? [] : result.failure, ...schemaDiff.conflicts]);\n\t\tconst indexRenamePartition = partitionCallsByControlPolicy({\n\t\t\tcalls: indexRenames.calls,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst schemaDiffPartition = partitionCallsByControlPolicy({\n\t\t\tcalls: schemaDiff.calls,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst fieldEventPartition = partitionCallsByControlPolicy({\n\t\t\tcalls: blindCast(planFieldEventOperations({\n\t\t\t\tpriorContract: options.fromContract,\n\t\t\t\tnewContract: options.contract,\n\t\t\t\tcodecHooks\n\t\t\t})),\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst calls = [\n\t\t\t...result.value.calls,\n\t\t\t...indexRenamePartition.kept,\n\t\t\t...schemaDiffPartition.kept,\n\t\t\t...fieldEventPartition.kept\n\t\t];\n\t\tconst seenWarnings = /* @__PURE__ */ new Set();\n\t\tconst warnings = [\n\t\t\t...issuePartition.suppressions,\n\t\t\t...indexRenamePartition.suppressions,\n\t\t\t...schemaDiff.suppressions,\n\t\t\t...schemaDiffPartition.suppressions,\n\t\t\t...fieldEventPartition.suppressions\n\t\t].map((record) => renderPostgresSuppression(record, options.contract)).filter((warning) => {\n\t\t\tconst key = JSON.stringify(warning);\n\t\t\tif (seenWarnings.has(key)) return false;\n\t\t\tseenWarnings.add(key);\n\t\t\treturn true;\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tkind: \"success\",\n\t\t\tplan: new TypeScriptRenderablePostgresMigration(calls, {\n\t\t\t\tfrom: options.fromContract?.storage.storageHash ?? null,\n\t\t\t\tto: options.contract.storage.storageHash\n\t\t\t}, options.spaceId, options.snapshotsImportPath, this.#lowerer),\n\t\t\t...warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}\n\t\t});\n\t}\n\t/**\n\t* Rename post-pass for indexes, per `(schema, table)`, widening-only,\n\t* deterministic by sorted names — the same structure as the policy pass\n\t* below (which stays untouched: policies pair by hash only).\n\t*\n\t* Hash pairing (prefix-only renames): extras whose live names parse as\n\t* wire names, grouped by `(schema, table, hash)`; missing nodes iterated\n\t* in sorted-name order consume the sorted-name-first candidate.\n\t*\n\t* Content pairing (exact→wire convergence), after hash pairing has\n\t* consumed its matches: the remaining wire-named-missing nodes\n\t* (`prefix` defined) against the remaining extras of any name shape,\n\t* paired iff content-equal (columns ordered-strict both-defined-or-\n\t* both-undefined, `unique`/`type` strict, `options` loose, bodies\n\t* byte-equal).\n\t*\n\t* Leftovers proceed as create/drop exactly as before; without the\n\t* widening allowance the pass is skipped and pairing degrades to the\n\t* additive half, like the policy pass.\n\t*/\n\tpairIndexRenames(options, issues) {\n\t\tconst consumed = /* @__PURE__ */ new Set();\n\t\tconst calls = [];\n\t\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t\tconst missing = [];\n\t\tconst extra = [];\n\t\tfor (const issue of issues) {\n\t\t\tconst node = issueNode(issue);\n\t\t\tif (node === void 0 || !SqlIndexIR.is(node)) continue;\n\t\t\tconst ddlSchema = issue.path[1];\n\t\t\tconst tableName = issue.path[2];\n\t\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\t\tissue,\n\t\t\t\tnode,\n\t\t\t\tddlSchema,\n\t\t\t\ttableName\n\t\t\t});\n\t\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\t\tissue,\n\t\t\t\tnode,\n\t\t\t\tddlSchema,\n\t\t\t\ttableName\n\t\t\t});\n\t\t}\n\t\tif (missing.length === 0 || extra.length === 0) return {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\t\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\t\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\t\tfinding.ddlSchema,\n\t\t\tfinding.tableName,\n\t\t\thash\n\t\t]);\n\t\tconst rename = (missingFinding, candidate) => {\n\t\t\tconsumed.add(missingFinding.issue);\n\t\t\tconsumed.add(candidate.issue);\n\t\t\tcalls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));\n\t\t};\n\t\tconst sortedMissing = [...missing].sort(byName);\n\t\tconst extrasByHash = /* @__PURE__ */ new Map();\n\t\tfor (const finding of extra) {\n\t\t\tconst parsed = parseWireName(finding.node.name);\n\t\t\tif (parsed === void 0) continue;\n\t\t\tconst key = pairingKey(finding, parsed.hash);\n\t\t\tconst group = extrasByHash.get(key) ?? [];\n\t\t\tgroup.push(finding);\n\t\t\textrasByHash.set(key, group);\n\t\t}\n\t\tfor (const group of extrasByHash.values()) group.sort(byName);\n\t\tfor (const missingFinding of sortedMissing) {\n\t\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\t\tif (parsed === void 0) continue;\n\t\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\t\tif (candidate === void 0) continue;\n\t\t\trename(missingFinding, candidate);\n\t\t}\n\t\tconst sortedExtras = [...extra].sort(byName);\n\t\tfor (const missingFinding of sortedMissing) {\n\t\t\tif (consumed.has(missingFinding.issue)) continue;\n\t\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\t\tconst candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {\n\t\t\t\tcolumnPresence: \"matching\",\n\t\t\t\tbodies: \"verbatim\"\n\t\t\t}));\n\t\t\tif (candidate === void 0) continue;\n\t\t\trename(missingFinding, candidate);\n\t\t}\n\t\treturn {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t}\n\t/**\n\t* Maps the RLS policy findings of the one combined tree diff\n\t* (`buildPostgresPlanDiff`, already ownership-filtered) into\n\t* `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops — a\n\t* `not-equal` finding (an exact-named policy whose content drifted)\n\t* becomes drop + create, or a disallowed-call conflict when the policy\n\t* forbids the destructive drop. It\n\t* does not re-diff — it consumes exactly the policy-node subset of the\n\t* shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE\n\t* ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`\n\t* attribute diff on the relational side.\n\t*\n\t* Rename post-pass (the index pass's structure): hash pairing pairs a\n\t* `not-found` and a `not-expected` policy on the SAME table whose\n\t* wire-name content hashes match but prefixes differ (prefix-only rename);\n\t* content pairing then pairs remaining wire-named-missing policies against remaining\n\t* extras of any name shape by verbatim content (the node-owned `contentEquals` —\n\t* exact→wire adoption). Multi-candidate groups pair deterministically\n\t* by sorted name; leftovers proceed as create/drop; an exact-named\n\t* missing policy never content-pairs.\n\t*\n\t* The pairing runs only when the policy allows `widening` (rename's\n\t* class). Without it (db-init's additive-only set), pairing degrades\n\t* deliberately to the additive half: the new name is CREATEd and the old\n\t* policy survives live until a widening/destructive-allowed plan runs —\n\t* emitting an ungated widening rename would only fail at the runner's\n\t* class re-enforcement.\n\t*/\n\tplanPostgresSchemaDiff(options, filteredDiffIssues) {\n\t\tconst allowsDestructive = options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst allowsWidening = options.policy.allowedOperationClasses.includes(\"widening\");\n\t\tconst missing = [];\n\t\tconst extra = [];\n\t\tconst changed = [];\n\t\tfor (const issue of filteredDiffIssues) if (issueOutcome(issue) === \"not-equal\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tchanged.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-found\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tmissing.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-expected\") {\n\t\t\tconst actual = issue.actual;\n\t\t\tPostgresPolicySchemaNode.assert(actual);\n\t\t\textra.push({\n\t\t\t\tnode: actual,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, actual.namespaceId)\n\t\t\t});\n\t\t}\n\t\tconst calls = [];\n\t\tconst conflicts = [];\n\t\tconst suppressions = [];\n\t\tconst renamedExtras = /* @__PURE__ */ new Set();\n\t\tconst renamedMissing = /* @__PURE__ */ new Set();\n\t\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\t\tfinding.schemaForTable,\n\t\t\tfinding.node.tableName,\n\t\t\thash\n\t\t]);\n\t\tif (allowsWidening) {\n\t\t\tconst extrasByGroup = /* @__PURE__ */ new Map();\n\t\t\tfor (const finding of extra) {\n\t\t\t\tconst parsed = parseWireName(finding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst key = pairingKey(finding, parsed.hash);\n\t\t\t\tconst group = extrasByGroup.get(key) ?? [];\n\t\t\t\tgroup.push(finding);\n\t\t\t\textrasByGroup.set(key, group);\n\t\t\t}\n\t\t\tfor (const group of extrasByGroup.values()) group.sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tconst sortedMissing = [...missing].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst candidate = extrasByGroup.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t\tconst sortedExtras = [...extra].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tif (renamedMissing.has(missingFinding)) continue;\n\t\t\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\t\t\tconst candidate = sortedExtras.find((extraFinding) => !renamedExtras.has(extraFinding) && extraFinding.schemaForTable === missingFinding.schemaForTable && extraFinding.node.tableName === missingFinding.node.tableName && missingFinding.node.contentEquals(extraFinding.node));\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t}\n\t\tfor (const finding of changed) {\n\t\t\tconst replacement = {\n\t\t\t\tdrop: new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name),\n\t\t\t\tcreate: new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node))\n\t\t\t};\n\t\t\tconst graded = gradePolicyReplacement(replacement, options.contract, options.policy.allowedOperationClasses);\n\t\t\tif (graded.disposition === \"suppress\") {\n\t\t\t\tsuppressions.push(graded.record);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (graded.disposition === \"conflict\") {\n\t\t\t\tconflicts.push(graded.conflict);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcalls.push(replacement.drop);\n\t\t\tcalls.push(replacement.create);\n\t\t}\n\t\tfor (const finding of missing) {\n\t\t\tif (renamedMissing.has(finding)) continue;\n\t\t\tcalls.push(new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node)));\n\t\t}\n\t\tif (allowsDestructive) for (const finding of extra) {\n\t\t\tif (renamedExtras.has(finding)) continue;\n\t\t\tcalls.push(new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name));\n\t\t}\n\t\treturn {\n\t\t\tcalls,\n\t\t\tconflicts,\n\t\t\tsuppressions\n\t\t};\n\t}\n\tensureAdditivePolicy(policy) {\n\t\tif (!policy.allowedOperationClasses.includes(\"additive\")) return plannerFailure([{\n\t\t\tkind: \"unsupportedOperation\",\n\t\t\tsummary: \"Migration planner requires additive operations be allowed\",\n\t\t\twhy: \"The planner requires the \\\"additive\\\" operation class to be allowed in the policy.\"\n\t\t}]);\n\t\treturn null;\n\t}\n};\n/**\n* A diff issue whose node is an RLS policy — the structural half of the one\n* combined tree diff, routed to `planPostgresSchemaDiff` instead of\n* `planIssues`.\n*/\nfunction isPolicyDiffIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && PostgresPolicySchemaNode.is(node);\n}\n/**\n* Drops a `not-expected` issue when it is a whole extra storage entity (a table\n* or a native enum) that some space in the composition owns. Each such node\n* yields its own storage coordinate (see {@link postgresNodeStorageCoordinate}),\n* so `declaresEntity` answers over the whole composition on one uniform\n* coordinate: a positive answer means a sibling owns this entity here — leave\n* it; a negative answer means a genuine orphan — drop it. A node with no storage\n* coordinate (a namespace, or a deeper column/constraint drift on an owned\n* table) is this space's own and is always kept. No oracle ⇒ keep everything.\n*/\nfunction retainUnownedExtras(issues, ownership, contract) {\n\tif (ownership === void 0) return issues;\n\treturn issues.filter((issue) => {\n\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0) return true;\n\t\tconst coordinate = postgresNodeStorageCoordinate(node);\n\t\tif (coordinate === void 0) return true;\n\t\tconst ddlSchemaName = issueSchemaName(issue);\n\t\tif (ddlSchemaName === void 0) return true;\n\t\tconst namespaceId = resolveNamespaceIdForDdlSchema(contract, ddlSchemaName);\n\t\treturn !ownership.declaresEntity({\n\t\t\tnamespaceId,\n\t\t\t...coordinate\n\t\t});\n\t});\n}\n/**\n* Returns the one namespace node the relational strategy layer probes for\n* live-table existence and reads codec-hook context off — the namespace\n* matching the planner's resolved schema name, or the first namespace when\n* none matches. `undefined` when the tree has no namespaces, so the strategy\n* context uses its empty-schema default.\n*\n* The relational strategies key tables by bare name, so they can only probe one\n* namespace at a time; probing across every namespace at once is future work.\n*\n* Returns the real `PostgresNamespaceSchemaNode` reference rather than a\n* projection: `storageTypePlanCallStrategy` hands this same value to codec\n* `planTypeOperations` hooks as `schema`, and hooks read the Postgres-specific\n* `nativeEnums` field off it (via `PostgresNamespaceSchemaNode.is`) to decide\n* whether a native enum type already exists — a projection that only copies\n* `tables` would silently drop that signal. `StrategyContext.schema`'s\n* declared type (`SqlSchemaIR`, shared with SQLite's flat shape) doesn't\n* capture this, so the return is `blindCast` the same way `namespaceSchemaNodes`\n* in the family's relational walk already treats a namespace node as a\n* structurally-`SqlSchemaIR`-shaped value.\n*/\nfunction relationalNamespaceNode(schema, schemaName) {\n\tconst namespaceNodes = Object.values(schema.namespaces);\n\tconst namespaceNode = namespaceNodes.find((node) => node.schemaName === schemaName) ?? namespaceNodes[0];\n\tif (namespaceNode === void 0) return void 0;\n\treturn blindCast(namespaceNode);\n}\n/**\n* Grades a {@link PolicyReplacement} as one unit against the table's\n* control policy, BEFORE the pair becomes calls or a conflict. This runs\n* ahead of `partitionCallsByControlPolicy`, which later re-grades the\n* surviving calls per-call — a no-op here, since only managed units\n* survive this grading.\n*\n* A replacement is deliberately STRICTER than the shared\n* `callAllowedUnderControlPolicy` rule: `tolerated` permits whole-object\n* creation, but a replacement's create is the second half of a repair of\n* an existing object, not a new object — so ANY non-managed control\n* (external, observed, tolerated) suppresses the whole unit. Drift on an\n* object the plan does not manage is reported, never repaired; the\n* suppression subject names the drifted policy (`rlsPolicy`) so the\n* report says which policy drifted, matching the conflict path's\n* `location.rlsPolicy`.\n*/\nfunction gradePolicyReplacement(replacement, contract, allowedOperationClasses) {\n\tconst subject = resolvePostgresCallControlPolicySubject(replacement.drop, contract);\n\tconst controlPolicy = controlPolicyForCall(subject, contract.defaultControlPolicy);\n\tif (controlPolicy !== \"managed\") return {\n\t\tdisposition: \"suppress\",\n\t\trecord: {\n\t\t\tsubject: subject === void 0 ? void 0 : {\n\t\t\t\t...subject,\n\t\t\t\trlsPolicy: replacement.drop.policyName\n\t\t\t},\n\t\t\tpolicy: controlPolicy,\n\t\t\tfactoryName: void 0,\n\t\t\tcreatesNewObject: false\n\t\t}\n\t};\n\tif (!allowedOperationClasses.includes(\"destructive\")) return {\n\t\tdisposition: \"conflict\",\n\t\tconflict: conflictForDisallowedCall(replacement.drop, allowedOperationClasses)\n\t};\n\treturn { disposition: \"plan\" };\n}\n/**\n* Rebuilds the `PostgresRlsPolicy` contract entity `CreatePostgresRlsPolicyCall`\n* carries (its `renderTypeScript`/`createRlsPolicy` paths serialize the whole\n* entity, `namespaceId` included). This reconstructs rather than looking the\n* original up in the contract on purpose: the diff node's `namespaceId` is the\n* *resolved DDL schema* (set when the expected tree was built), which is the\n* value the emitted op must carry; the contract-stored entity holds the raw,\n* pre-resolution coordinate, so a lookup would change the migration output.\n*/\nfunction policyNodeToContractPolicy(node) {\n\treturn new PostgresRlsPolicy({\n\t\tnaming: namingOf(node.name, node.prefix),\n\t\ttableName: node.tableName,\n\t\tnamespaceId: node.namespaceId,\n\t\toperation: node.operation,\n\t\troles: [...node.roles],\n\t\tusing: node.using,\n\t\twithCheck: node.withCheck,\n\t\tpermissive: node.permissive\n\t});\n}\n//#endregion\nexport { createPostgresMigrationPlanner as t };\n\n//# sourceMappingURL=planner-Bmje9ii8.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,qBAAqB,SAAS,aAAa;CACnD,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,iBAAiB,SAAS,GAAG,OAAO,UAAU,cAAc,OAAO;CACvE,OAAO;AACR;;;;;;;;;;;;;;;;;AAiBA,SAAS,0BAA0B,QAAQ;CAC1C,IAAI,2BAA2B,GAAG,MAAM,GAAG,OAAO,OAAO;CACzD,OAAO,CAAC,oBAAoB;AAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2BA,SAAS,gCAAgC,OAAO;CAC/C,MAAM,EAAE,UAAU,WAAW;CAC7B,MAAM,WAAW,IAAI,IAAI,0BAA0B,MAAM,CAAC;CAC1D,MAAM,SAAS,CAAC;CAChB,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,CAAC,CAAC,KAAK;CACnE,KAAK,MAAM,eAAe,cAAc;EACvC,IAAI,gBAAgB,sBAAsB;EAC1C,MAAM,UAAU,qBAAqB,SAAS,SAAS,WAAW;EAClE,IAAI,YAAY,sBAAsB;EACtC,IAAI,SAAS,IAAI,OAAO,GAAG;EAC3B,MAAM,YAAY,IAAI,4BAA4B;GACjD,YAAY;GACZ,QAAQ,CAAC;EACV,CAAC;EACD,OAAO,KAAK;GACX,MAAM,CAAC,YAAY,OAAO;G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1
+ {"version":3,"file":"planner-Bmje9ii8-DdjXZxyD.mjs","names":["#lowerer"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-Bmje9ii8.mjs"],"sourcesContent":["import { t as DEFAULT_NAMESPACE_ID } from \"./namespace-ids-xtp_ZY86.mjs\";\nimport { _ as PostgresRlsPolicy, r as isPostgresSchema } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { i as PostgresDatabaseSchemaNode, n as PostgresPolicySchemaNode, r as PostgresNamespaceSchemaNode } from \"./postgres-role-schema-node-B8Z5i5D-.mjs\";\nimport { t as resolveDdlSchemaForNamespaceStorage } from \"./resolve-ddl-schema-CxqlLW47.mjs\";\nimport { t as buildPostgresPlanDiff } from \"./diff-database-schema-BfRs2vrG.mjs\";\nimport { a as resolvePostgresNodeIssueCreationFactoryName, c as issueNode, d as postgresPlannerStrategies, f as postgresNodeStorageCoordinate, i as resolvePostgresNodeIssueControlPolicySubject, l as issueSchemaName, n as resolveNamespaceIdForDdlSchema, o as coalesceSubtreeIssues, r as resolvePostgresCallControlPolicySubject, s as conflictForDisallowedCall, t as renderPostgresSuppression, u as planIssues } from \"./control-policy-Cl3RRSPg.mjs\";\nimport { A as RenamePostgresRlsPolicyCall, T as DropPostgresRlsPolicyCall, k as RenameIndexCall, p as CreatePostgresRlsPolicyCall } from \"./op-factory-call-DifL68KT.mjs\";\nimport { t as TypeScriptRenderablePostgresMigration } from \"./planner-produced-postgres-migration-Cicg2sXg.mjs\";\nimport { blindCast } from \"@internal/utils/casts\";\nimport { UNBOUND_NAMESPACE_ID } from \"@internal/framework-components/ir\";\nimport { controlPolicyForCall, extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure } from \"@internal/family-sql/control\";\nimport { ifDefined } from \"@internal/utils/defined\";\nimport { namingOf, parseWireName } from \"@internal/sql-schema-ir/naming\";\nimport { SqlIndexIR } from \"@internal/sql-schema-ir/types\";\nimport { issueOutcome } from \"@internal/framework-components/control\";\n//#region src/core/migrations/verify-postgres-namespaces.ts\n/**\n* Resolves the live-database schema name for a given namespace\n* coordinate. Mirrors `resolveDdlSchemaForNamespace` in\n* `planner-strategies.ts` so the verifier's projection and the\n* planner's projection always agree — Postgres-aware namespaces (the\n* production path) dispatch to `ddlSchemaName(storage)`, and bare\n* object payloads (used by some tests) fall back to the coordinate\n* itself.\n*/\nfunction resolveDdlSchemaName(storage, namespaceId) {\n\tconst namespace = storage.namespaces[namespaceId];\n\tif (isPostgresSchema(namespace)) return namespace.ddlSchemaName(storage);\n\treturn namespaceId;\n}\n/**\n* Reads the introspected list of schema names from the database-root schema\n* node. `existingSchemas` is database-level, so it lives on the\n* `PostgresDatabaseSchemaNode` root — not on the per-schema namespace nodes.\n*\n* Defaults to the always-present `public` schema when the node is not the\n* database root — a fresh Postgres database always carries `public` (unless an\n* operator dropped it manually), so any verifier path that runs without an\n* enriched introspection still suppresses the redundant `CREATE SCHEMA\n* \"public\"`.\n*\n* Production introspection (`PostgresControlAdapter.introspect`) is the\n* authoritative source: it queries `pg_namespace` and sets `existingSchemas`\n* on the returned root. Tests that want to assert against a richer initial\n* state construct a `PostgresDatabaseSchemaNode` explicitly.\n*/\nfunction existingSchemasFromSchema(schema) {\n\tif (PostgresDatabaseSchemaNode.is(schema)) return schema.existingSchemas;\n\treturn [DEFAULT_NAMESPACE_ID];\n}\n/**\n* Emits a `postgres-namespace` `not-found` diff issue for every\n* contract-declared Postgres namespace whose live container does not yet\n* exist. The planner prepends these (node-typed, synthesized) to the\n* relational diff issues so a multi-schema plan emits `CREATE SCHEMA`\n* before the tables that need it — a planner-only concern (verify already\n* rejects via the `not-found` table issues a missing schema already\n* produces), so this is not part of the shared diff.\n*\n* A namespace's live container is the schema returned by its\n* polymorphic `ddlSchemaName(storage)` method — named schemas resolve\n* to their own id; the unbound singleton returns `UNBOUND_NAMESPACE_ID`\n* and is skipped explicitly (late-bound namespaces have no fixed DDL\n* schema). Issues are emitted only when the resolved name is a real,\n* creatable schema (not the unbound sentinel) and is missing from the\n* introspected list. `public` is suppressed implicitly because the\n* introspection (or its sensible default) always carries it.\n*\n* Each emitted issue's path is `['database', ddlName]` — an ancestor of\n* every table path under that schema, so it must never be run through\n* `coalesceSubtreeIssues` alongside the table diff (it would swallow the\n* table-level `not-found` issues that drive `CREATE TABLE`); the planner\n* adds these AFTER coalescing the relational issues, and they are not\n* subject to sibling-space ownership scoping (mirrors the retired\n* coordinate walk, which prepended namespace issues after that filter).\n*/\nfunction verifyPostgresNamespacePresence(input) {\n\tconst { contract, schema } = input;\n\tconst existing = new Set(existingSchemasFromSchema(schema));\n\tconst issues = [];\n\tconst namespaceIds = Object.keys(contract.storage.namespaces).sort();\n\tfor (const namespaceId of namespaceIds) {\n\t\tif (namespaceId === UNBOUND_NAMESPACE_ID) continue;\n\t\tconst ddlName = resolveDdlSchemaName(contract.storage, namespaceId);\n\t\tif (ddlName === UNBOUND_NAMESPACE_ID) continue;\n\t\tif (existing.has(ddlName)) continue;\n\t\tconst namespace = new PostgresNamespaceSchemaNode({\n\t\t\tschemaName: ddlName,\n\t\t\ttables: {}\n\t\t});\n\t\tissues.push({\n\t\t\tpath: [\"database\", ddlName],\n\t\t\texpected: namespace\n\t\t});\n\t}\n\treturn issues;\n}\n//#endregion\n//#region src/core/migrations/planner.ts\nfunction createPostgresMigrationPlanner(lowerer) {\n\treturn new PostgresMigrationPlanner(lowerer);\n}\n/**\n* Postgres migration planner — a thin wrapper over `planIssues`.\n*\n* `plan()` diffs the target contract against the live schema via the one\n* differ (`buildPostgresPlanDiff`, producing node-typed `SchemaDiffIssue[]`)\n* and delegates to `planIssues` with the unified `postgresPlannerStrategies`\n* list: NOT-NULL backfill, type-change, nullable-tightening, codec-hook\n* storage types, component-declared dependency installs, and\n* shared-temp-default / empty-table-guarded NOT-NULL add-column. The same\n* strategy list runs for `migration plan`, `db update`, and `db init`;\n* behavior diverges purely on `policy.allowedOperationClasses` (the\n* data-safe strategies short-circuit when `'data'` is excluded). The issue\n* planner applies operation-class policy gates and emits a single\n* `PostgresOpFactoryCall[]` that drives both the runtime-ops view (via\n* `renderOps`) and the `renderTypeScript()` authoring surface. RLS policy\n* drift (the structural half of the same one-differ tree) is handled\n* separately via `planPostgresSchemaDiff`.\n*/\nvar PostgresMigrationPlanner = class {\n\t#lowerer;\n\tconstructor(lowerer) {\n\t\tthis.#lowerer = lowerer;\n\t}\n\tplan(options) {\n\t\treturn this.planSql(options);\n\t}\n\temptyMigration(context, spaceId) {\n\t\treturn new TypeScriptRenderablePostgresMigration([], {\n\t\t\tfrom: context.fromHash,\n\t\t\tto: context.toHash\n\t\t}, spaceId, context.snapshotsImportPath, this.#lowerer);\n\t}\n\tplanSql(options) {\n\t\tconst schemaName = options.schemaName ?? Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ?? UNBOUND_NAMESPACE_ID;\n\t\tconst policyResult = this.ensureAdditivePolicy(options.policy);\n\t\tif (policyResult) return policyResult;\n\t\tPostgresDatabaseSchemaNode.assert(options.schema);\n\t\tconst { issues: rawIssues } = buildPostgresPlanDiff({\n\t\t\tcontract: options.contract,\n\t\t\tactualSchema: options.schema,\n\t\t\tframeworkComponents: options.frameworkComponents\n\t\t});\n\t\tconst policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue));\n\t\tconst relationalDiffIssues = rawIssues.filter((issue) => !isPolicyDiffIssue(issue));\n\t\tconst strict = options.policy.allowedOperationClasses.includes(\"widening\") || options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst owned = retainUnownedExtras(coalesceSubtreeIssues(relationalDiffIssues), options.ownership, options.contract);\n\t\tconst gated = strict ? owned : owned.filter((issue) => issueOutcome(issue) !== \"not-expected\");\n\t\tconst schemaIssues = [...verifyPostgresNamespacePresence({\n\t\t\tcontract: options.contract,\n\t\t\tschema: options.schema\n\t\t}), ...gated];\n\t\tconst indexRenames = this.pairIndexRenames(options, schemaIssues);\n\t\tconst plannableIssues = indexRenames.consumed.size === 0 ? schemaIssues : schemaIssues.filter((issue) => !indexRenames.consumed.has(issue));\n\t\tconst codecHooks = extractCodecControlHooks(options.frameworkComponents);\n\t\tconst storageTypes = options.contract.storage.types ?? {};\n\t\tconst relationalSchema = relationalNamespaceNode(options.schema, schemaName);\n\t\tconst issuePartition = partitionIssuesByControlPolicy({\n\t\t\tissues: plannableIssues,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (issue) => resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n\t\t\tresolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName\n\t\t});\n\t\tconst result = planIssues({\n\t\t\tissues: issuePartition.plannable,\n\t\t\ttoContract: options.contract,\n\t\t\tfromContract: options.fromContract,\n\t\t\tschemaName,\n\t\t\tcodecHooks,\n\t\t\tstorageTypes,\n\t\t\t...ifDefined(\"schema\", relationalSchema),\n\t\t\tpolicy: options.policy,\n\t\t\tframeworkComponents: options.frameworkComponents,\n\t\t\tstrategies: postgresPlannerStrategies\n\t\t});\n\t\tconst schemaDiff = this.planPostgresSchemaDiff(options, policyDiffIssues);\n\t\tif (!result.ok || schemaDiff.conflicts.length > 0) return plannerFailure([...result.ok ? [] : result.failure, ...schemaDiff.conflicts]);\n\t\tconst indexRenamePartition = partitionCallsByControlPolicy({\n\t\t\tcalls: indexRenames.calls,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst schemaDiffPartition = partitionCallsByControlPolicy({\n\t\t\tcalls: schemaDiff.calls,\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst fieldEventPartition = partitionCallsByControlPolicy({\n\t\t\tcalls: blindCast(planFieldEventOperations({\n\t\t\t\tpriorContract: options.fromContract,\n\t\t\t\tnewContract: options.contract,\n\t\t\t\tcodecHooks\n\t\t\t})),\n\t\t\tcontract: options.contract,\n\t\t\tresolveControlPolicySubject: (call) => resolvePostgresCallControlPolicySubject(call, options.contract),\n\t\t\tresolveFactoryName: (call) => call.factoryName\n\t\t});\n\t\tconst calls = [\n\t\t\t...result.value.calls,\n\t\t\t...indexRenamePartition.kept,\n\t\t\t...schemaDiffPartition.kept,\n\t\t\t...fieldEventPartition.kept\n\t\t];\n\t\tconst seenWarnings = /* @__PURE__ */ new Set();\n\t\tconst warnings = [\n\t\t\t...issuePartition.suppressions,\n\t\t\t...indexRenamePartition.suppressions,\n\t\t\t...schemaDiff.suppressions,\n\t\t\t...schemaDiffPartition.suppressions,\n\t\t\t...fieldEventPartition.suppressions\n\t\t].map((record) => renderPostgresSuppression(record, options.contract)).filter((warning) => {\n\t\t\tconst key = JSON.stringify(warning);\n\t\t\tif (seenWarnings.has(key)) return false;\n\t\t\tseenWarnings.add(key);\n\t\t\treturn true;\n\t\t});\n\t\treturn Object.freeze({\n\t\t\tkind: \"success\",\n\t\t\tplan: new TypeScriptRenderablePostgresMigration(calls, {\n\t\t\t\tfrom: options.fromContract?.storage.storageHash ?? null,\n\t\t\t\tto: options.contract.storage.storageHash\n\t\t\t}, options.spaceId, options.snapshotsImportPath, this.#lowerer),\n\t\t\t...warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}\n\t\t});\n\t}\n\t/**\n\t* Rename post-pass for indexes, per `(schema, table)`, widening-only,\n\t* deterministic by sorted names — the same structure as the policy pass\n\t* below (which stays untouched: policies pair by hash only).\n\t*\n\t* Hash pairing (prefix-only renames): extras whose live names parse as\n\t* wire names, grouped by `(schema, table, hash)`; missing nodes iterated\n\t* in sorted-name order consume the sorted-name-first candidate.\n\t*\n\t* Content pairing (exact→wire convergence), after hash pairing has\n\t* consumed its matches: the remaining wire-named-missing nodes\n\t* (`prefix` defined) against the remaining extras of any name shape,\n\t* paired iff content-equal (columns ordered-strict both-defined-or-\n\t* both-undefined, `unique`/`type` strict, `options` loose, bodies\n\t* byte-equal).\n\t*\n\t* Leftovers proceed as create/drop exactly as before; without the\n\t* widening allowance the pass is skipped and pairing degrades to the\n\t* additive half, like the policy pass.\n\t*/\n\tpairIndexRenames(options, issues) {\n\t\tconst consumed = /* @__PURE__ */ new Set();\n\t\tconst calls = [];\n\t\tif (!options.policy.allowedOperationClasses.includes(\"widening\")) return {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t\tconst missing = [];\n\t\tconst extra = [];\n\t\tfor (const issue of issues) {\n\t\t\tconst node = issueNode(issue);\n\t\t\tif (node === void 0 || !SqlIndexIR.is(node)) continue;\n\t\t\tconst ddlSchema = issue.path[1];\n\t\t\tconst tableName = issue.path[2];\n\t\t\tif (ddlSchema === void 0 || tableName === void 0) continue;\n\t\t\tif (issueOutcome(issue) === \"not-found\") missing.push({\n\t\t\t\tissue,\n\t\t\t\tnode,\n\t\t\t\tddlSchema,\n\t\t\t\ttableName\n\t\t\t});\n\t\t\telse if (issueOutcome(issue) === \"not-expected\") extra.push({\n\t\t\t\tissue,\n\t\t\t\tnode,\n\t\t\t\tddlSchema,\n\t\t\t\ttableName\n\t\t\t});\n\t\t}\n\t\tif (missing.length === 0 || extra.length === 0) return {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t\tconst byName = (a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0;\n\t\tconst emissionSchema = (ddlSchema) => resolveNamespaceIdForDdlSchema(options.contract, ddlSchema) === UNBOUND_NAMESPACE_ID ? UNBOUND_NAMESPACE_ID : ddlSchema;\n\t\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\t\tfinding.ddlSchema,\n\t\t\tfinding.tableName,\n\t\t\thash\n\t\t]);\n\t\tconst rename = (missingFinding, candidate) => {\n\t\t\tconsumed.add(missingFinding.issue);\n\t\t\tconsumed.add(candidate.issue);\n\t\t\tcalls.push(new RenameIndexCall(emissionSchema(missingFinding.ddlSchema), missingFinding.tableName, candidate.node.name, missingFinding.node.name));\n\t\t};\n\t\tconst sortedMissing = [...missing].sort(byName);\n\t\tconst extrasByHash = /* @__PURE__ */ new Map();\n\t\tfor (const finding of extra) {\n\t\t\tconst parsed = parseWireName(finding.node.name);\n\t\t\tif (parsed === void 0) continue;\n\t\t\tconst key = pairingKey(finding, parsed.hash);\n\t\t\tconst group = extrasByHash.get(key) ?? [];\n\t\t\tgroup.push(finding);\n\t\t\textrasByHash.set(key, group);\n\t\t}\n\t\tfor (const group of extrasByHash.values()) group.sort(byName);\n\t\tfor (const missingFinding of sortedMissing) {\n\t\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\t\tif (parsed === void 0) continue;\n\t\t\tconst candidate = extrasByHash.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\t\tif (candidate === void 0) continue;\n\t\t\trename(missingFinding, candidate);\n\t\t}\n\t\tconst sortedExtras = [...extra].sort(byName);\n\t\tfor (const missingFinding of sortedMissing) {\n\t\t\tif (consumed.has(missingFinding.issue)) continue;\n\t\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\t\tconst candidate = sortedExtras.find((extraFinding) => !consumed.has(extraFinding.issue) && extraFinding.ddlSchema === missingFinding.ddlSchema && extraFinding.tableName === missingFinding.tableName && missingFinding.node.contentEquals(extraFinding.node, {\n\t\t\t\tcolumnPresence: \"matching\",\n\t\t\t\tbodies: \"verbatim\"\n\t\t\t}));\n\t\t\tif (candidate === void 0) continue;\n\t\t\trename(missingFinding, candidate);\n\t\t}\n\t\treturn {\n\t\t\tcalls,\n\t\t\tconsumed\n\t\t};\n\t}\n\t/**\n\t* Maps the RLS policy findings of the one combined tree diff\n\t* (`buildPostgresPlanDiff`, already ownership-filtered) into\n\t* `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops — a\n\t* `not-equal` finding (an exact-named policy whose content drifted)\n\t* becomes drop + create, or a disallowed-call conflict when the policy\n\t* forbids the destructive drop. It\n\t* does not re-diff — it consumes exactly the policy-node subset of the\n\t* shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE\n\t* ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`\n\t* attribute diff on the relational side.\n\t*\n\t* Rename post-pass (the index pass's structure): hash pairing pairs a\n\t* `not-found` and a `not-expected` policy on the SAME table whose\n\t* wire-name content hashes match but prefixes differ (prefix-only rename);\n\t* content pairing then pairs remaining wire-named-missing policies against remaining\n\t* extras of any name shape by verbatim content (the node-owned `contentEquals` —\n\t* exact→wire adoption). Multi-candidate groups pair deterministically\n\t* by sorted name; leftovers proceed as create/drop; an exact-named\n\t* missing policy never content-pairs.\n\t*\n\t* The pairing runs only when the policy allows `widening` (rename's\n\t* class). Without it (db-init's additive-only set), pairing degrades\n\t* deliberately to the additive half: the new name is CREATEd and the old\n\t* policy survives live until a widening/destructive-allowed plan runs —\n\t* emitting an ungated widening rename would only fail at the runner's\n\t* class re-enforcement.\n\t*/\n\tplanPostgresSchemaDiff(options, filteredDiffIssues) {\n\t\tconst allowsDestructive = options.policy.allowedOperationClasses.includes(\"destructive\");\n\t\tconst allowsWidening = options.policy.allowedOperationClasses.includes(\"widening\");\n\t\tconst missing = [];\n\t\tconst extra = [];\n\t\tconst changed = [];\n\t\tfor (const issue of filteredDiffIssues) if (issueOutcome(issue) === \"not-equal\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tchanged.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-found\") {\n\t\t\tconst expected = issue.expected;\n\t\t\tPostgresPolicySchemaNode.assert(expected);\n\t\t\tmissing.push({\n\t\t\t\tnode: expected,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, expected.namespaceId)\n\t\t\t});\n\t\t} else if (issueOutcome(issue) === \"not-expected\") {\n\t\t\tconst actual = issue.actual;\n\t\t\tPostgresPolicySchemaNode.assert(actual);\n\t\t\textra.push({\n\t\t\t\tnode: actual,\n\t\t\t\tschemaForTable: resolveDdlSchemaForNamespaceStorage(options.contract.storage, actual.namespaceId)\n\t\t\t});\n\t\t}\n\t\tconst calls = [];\n\t\tconst conflicts = [];\n\t\tconst suppressions = [];\n\t\tconst renamedExtras = /* @__PURE__ */ new Set();\n\t\tconst renamedMissing = /* @__PURE__ */ new Set();\n\t\tconst pairingKey = (finding, hash) => JSON.stringify([\n\t\t\tfinding.schemaForTable,\n\t\t\tfinding.node.tableName,\n\t\t\thash\n\t\t]);\n\t\tif (allowsWidening) {\n\t\t\tconst extrasByGroup = /* @__PURE__ */ new Map();\n\t\t\tfor (const finding of extra) {\n\t\t\t\tconst parsed = parseWireName(finding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst key = pairingKey(finding, parsed.hash);\n\t\t\t\tconst group = extrasByGroup.get(key) ?? [];\n\t\t\t\tgroup.push(finding);\n\t\t\t\textrasByGroup.set(key, group);\n\t\t\t}\n\t\t\tfor (const group of extrasByGroup.values()) group.sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tconst sortedMissing = [...missing].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tconst parsed = parseWireName(missingFinding.node.name);\n\t\t\t\tif (parsed === void 0) continue;\n\t\t\t\tconst candidate = extrasByGroup.get(pairingKey(missingFinding, parsed.hash))?.shift();\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t\tconst sortedExtras = [...extra].sort((a, b) => a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0);\n\t\t\tfor (const missingFinding of sortedMissing) {\n\t\t\t\tif (renamedMissing.has(missingFinding)) continue;\n\t\t\t\tif (missingFinding.node.prefix === void 0) continue;\n\t\t\t\tconst candidate = sortedExtras.find((extraFinding) => !renamedExtras.has(extraFinding) && extraFinding.schemaForTable === missingFinding.schemaForTable && extraFinding.node.tableName === missingFinding.node.tableName && missingFinding.node.contentEquals(extraFinding.node));\n\t\t\t\tif (candidate === void 0) continue;\n\t\t\t\trenamedExtras.add(candidate);\n\t\t\t\trenamedMissing.add(missingFinding);\n\t\t\t\tcalls.push(new RenamePostgresRlsPolicyCall(missingFinding.schemaForTable, missingFinding.node.tableName, candidate.node.name, missingFinding.node.name));\n\t\t\t}\n\t\t}\n\t\tfor (const finding of changed) {\n\t\t\tconst replacement = {\n\t\t\t\tdrop: new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name),\n\t\t\t\tcreate: new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node))\n\t\t\t};\n\t\t\tconst graded = gradePolicyReplacement(replacement, options.contract, options.policy.allowedOperationClasses);\n\t\t\tif (graded.disposition === \"suppress\") {\n\t\t\t\tsuppressions.push(graded.record);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tif (graded.disposition === \"conflict\") {\n\t\t\t\tconflicts.push(graded.conflict);\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tcalls.push(replacement.drop);\n\t\t\tcalls.push(replacement.create);\n\t\t}\n\t\tfor (const finding of missing) {\n\t\t\tif (renamedMissing.has(finding)) continue;\n\t\t\tcalls.push(new CreatePostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, policyNodeToContractPolicy(finding.node)));\n\t\t}\n\t\tif (allowsDestructive) for (const finding of extra) {\n\t\t\tif (renamedExtras.has(finding)) continue;\n\t\t\tcalls.push(new DropPostgresRlsPolicyCall(finding.schemaForTable, finding.node.tableName, finding.node.name));\n\t\t}\n\t\treturn {\n\t\t\tcalls,\n\t\t\tconflicts,\n\t\t\tsuppressions\n\t\t};\n\t}\n\tensureAdditivePolicy(policy) {\n\t\tif (!policy.allowedOperationClasses.includes(\"additive\")) return plannerFailure([{\n\t\t\tkind: \"unsupportedOperation\",\n\t\t\tsummary: \"Migration planner requires additive operations be allowed\",\n\t\t\twhy: \"The planner requires the \\\"additive\\\" operation class to be allowed in the policy.\"\n\t\t}]);\n\t\treturn null;\n\t}\n};\n/**\n* A diff issue whose node is an RLS policy — the structural half of the one\n* combined tree diff, routed to `planPostgresSchemaDiff` instead of\n* `planIssues`.\n*/\nfunction isPolicyDiffIssue(issue) {\n\tconst node = issue.expected ?? issue.actual;\n\treturn node !== void 0 && PostgresPolicySchemaNode.is(node);\n}\n/**\n* Drops a `not-expected` issue when it is a whole extra storage entity (a table\n* or a native enum) that some space in the composition owns. Each such node\n* yields its own storage coordinate (see {@link postgresNodeStorageCoordinate}),\n* so `declaresEntity` answers over the whole composition on one uniform\n* coordinate: a positive answer means a sibling owns this entity here — leave\n* it; a negative answer means a genuine orphan — drop it. A node with no storage\n* coordinate (a namespace, or a deeper column/constraint drift on an owned\n* table) is this space's own and is always kept. No oracle ⇒ keep everything.\n*/\nfunction retainUnownedExtras(issues, ownership, contract) {\n\tif (ownership === void 0) return issues;\n\treturn issues.filter((issue) => {\n\t\tif (issueOutcome(issue) !== \"not-expected\") return true;\n\t\tconst node = issueNode(issue);\n\t\tif (node === void 0) return true;\n\t\tconst coordinate = postgresNodeStorageCoordinate(node);\n\t\tif (coordinate === void 0) return true;\n\t\tconst ddlSchemaName = issueSchemaName(issue);\n\t\tif (ddlSchemaName === void 0) return true;\n\t\tconst namespaceId = resolveNamespaceIdForDdlSchema(contract, ddlSchemaName);\n\t\treturn !ownership.declaresEntity({\n\t\t\tnamespaceId,\n\t\t\t...coordinate\n\t\t});\n\t});\n}\n/**\n* Returns the one namespace node the relational strategy layer probes for\n* live-table existence and reads codec-hook context off — the namespace\n* matching the planner's resolved schema name, or the first namespace when\n* none matches. `undefined` when the tree has no namespaces, so the strategy\n* context uses its empty-schema default.\n*\n* The relational strategies key tables by bare name, so they can only probe one\n* namespace at a time; probing across every namespace at once is future work.\n*\n* Returns the real `PostgresNamespaceSchemaNode` reference rather than a\n* projection: `storageTypePlanCallStrategy` hands this same value to codec\n* `planTypeOperations` hooks as `schema`, and hooks read the Postgres-specific\n* `nativeEnums` field off it (via `PostgresNamespaceSchemaNode.is`) to decide\n* whether a native enum type already exists — a projection that only copies\n* `tables` would silently drop that signal. `StrategyContext.schema`'s\n* declared type (`SqlSchemaIR`, shared with SQLite's flat shape) doesn't\n* capture this, so the return is `blindCast` the same way `namespaceSchemaNodes`\n* in the family's relational walk already treats a namespace node as a\n* structurally-`SqlSchemaIR`-shaped value.\n*/\nfunction relationalNamespaceNode(schema, schemaName) {\n\tconst namespaceNodes = Object.values(schema.namespaces);\n\tconst namespaceNode = namespaceNodes.find((node) => node.schemaName === schemaName) ?? namespaceNodes[0];\n\tif (namespaceNode === void 0) return void 0;\n\treturn blindCast(namespaceNode);\n}\n/**\n* Grades a {@link PolicyReplacement} as one unit against the table's\n* control policy, BEFORE the pair becomes calls or a conflict. This runs\n* ahead of `partitionCallsByControlPolicy`, which later re-grades the\n* surviving calls per-call — a no-op here, since only managed units\n* survive this grading.\n*\n* A replacement is deliberately STRICTER than the shared\n* `callAllowedUnderControlPolicy` rule: `tolerated` permits whole-object\n* creation, but a replacement's create is the second half of a repair of\n* an existing object, not a new object — so ANY non-managed control\n* (external, observed, tolerated) suppresses the whole unit. Drift on an\n* object the plan does not manage is reported, never repaired; the\n* suppression subject names the drifted policy (`rlsPolicy`) so the\n* report says which policy drifted, matching the conflict path's\n* `location.rlsPolicy`.\n*/\nfunction gradePolicyReplacement(replacement, contract, allowedOperationClasses) {\n\tconst subject = resolvePostgresCallControlPolicySubject(replacement.drop, contract);\n\tconst controlPolicy = controlPolicyForCall(subject, contract.defaultControlPolicy);\n\tif (controlPolicy !== \"managed\") return {\n\t\tdisposition: \"suppress\",\n\t\trecord: {\n\t\t\tsubject: subject === void 0 ? void 0 : {\n\t\t\t\t...subject,\n\t\t\t\trlsPolicy: replacement.drop.policyName\n\t\t\t},\n\t\t\tpolicy: controlPolicy,\n\t\t\tfactoryName: void 0,\n\t\t\tcreatesNewObject: false\n\t\t}\n\t};\n\tif (!allowedOperationClasses.includes(\"destructive\")) return {\n\t\tdisposition: \"conflict\",\n\t\tconflict: conflictForDisallowedCall(replacement.drop, allowedOperationClasses)\n\t};\n\treturn { disposition: \"plan\" };\n}\n/**\n* Rebuilds the `PostgresRlsPolicy` contract entity `CreatePostgresRlsPolicyCall`\n* carries (its `renderTypeScript`/`createRlsPolicy` paths serialize the whole\n* entity, `namespaceId` included). This reconstructs rather than looking the\n* original up in the contract on purpose: the diff node's `namespaceId` is the\n* *resolved DDL schema* (set when the expected tree was built), which is the\n* value the emitted op must carry; the contract-stored entity holds the raw,\n* pre-resolution coordinate, so a lookup would change the migration output.\n*/\nfunction policyNodeToContractPolicy(node) {\n\treturn new PostgresRlsPolicy({\n\t\tnaming: namingOf(node.name, node.prefix),\n\t\ttableName: node.tableName,\n\t\tnamespaceId: node.namespaceId,\n\t\toperation: node.operation,\n\t\troles: [...node.roles],\n\t\tusing: node.using,\n\t\twithCheck: node.withCheck,\n\t\tpermissive: node.permissive\n\t});\n}\n//#endregion\nexport { createPostgresMigrationPlanner as t };\n\n//# sourceMappingURL=planner-Bmje9ii8.mjs.map"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,SAAS,qBAAqB,SAAS,aAAa;CACnD,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,iBAAiB,SAAS,GAAG,OAAO,UAAU,cAAc,OAAO;CACvE,OAAO;AACR;;;;;;;;;;;;;;;;;AAiBA,SAAS,0BAA0B,QAAQ;CAC1C,IAAI,2BAA2B,GAAG,MAAM,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vC,aAAa;EACb,QAAQ;GACP,SAAS,YAAY,KAAK,IAAI,KAAK,IAAI;IACtC,GAAG;IACH,WAAW,YAAY,KAAK;GAC7B;GACA,QAAQ;GACR,aAAa,KAAK;GAClB,kBAAkB;EACnB;CACD;CACA,IAAI,CAAC,wBAAwB,SAAS,aAAa,GAAG,OAAO;EAC5D,aAAa;EACb,UAAU,0BAA0B,YAAY,MAAM,uBAAuB;CAC9E;CACA,OAAO,EAAE,aAAa,OAAO;AAC9B;;;;;;;;;;AAUA,SAAS,2BAA2B,MAAM;CACzC,OAAO,IAAI,kBAAkB;EAC5B,QAAQ,SAAS,KAAK,MAAM,KAAK,MAAM;EACvC,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,OAAO,CAAC,GAAG,KAAK,KAAK;EACrB,OAAO,KAAK;EACZ,WAAW,KAAK;EAChB,YAAY,KAAK;CAClB,CAAC;AACF"}
@@ -1,5 +1,5 @@
1
1
  import { n as postgresError } from "./errors-kYxOQjdD-D4T3rbVp.mjs";
2
- import { n as isPgEnumParams } from "./codecs-CBl0nD44-CaWPc1bd.mjs";
2
+ import { n as isPgEnumParams } from "./codecs-CBl0nD44-CjInu_aV.mjs";
3
3
  import { i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from "./sql-utils-BnBlQxyh-DaX9Nb7Z.mjs";
4
4
  import { t as resolveColumnTypeMetadata } from "./planner-type-resolution-Bt2f_q-F-C4T6YTae.mjs";
5
5
  import { ifDefined } from "@prisma/orm-framework/utils/defined";
@@ -99,4 +99,4 @@ function renderArrayLiteralDefault(elements) {
99
99
  //#endregion
100
100
  export { buildColumnTypeSql as n, renderDefaultLiteral as r, buildColumnDefaultSql as t };
101
101
 
102
- //# sourceMappingURL=planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs.map
102
+ //# sourceMappingURL=planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-ddl-builders-CbfICQfm-CxYiLrhX.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-ddl-builders-CbfICQfm.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as isPgEnumParams } from \"./codecs-CBl0nD44.mjs\";\nimport { i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from \"./sql-utils-BnBlQxyh.mjs\";\nimport { t as resolveColumnTypeMetadata } from \"./planner-type-resolution-Bt2f_q-F.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/migrations/planner-ddl-builders.ts\n/**\n* Pattern for safe PostgreSQL type names.\n* Allows letters, digits, underscores, spaces (for \"double precision\", \"character varying\"),\n* and trailing [] for array types.\n*/\nconst SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*(\\[\\])?$/;\nfunction assertSafeNativeType(nativeType) {\n\tif (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) throw postgresError(\"CONTRACT.NATIVE_TYPE_INVALID\", `Unsafe native type name in contract: \"${nativeType}\". Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*(\\\\[\\\\])?\\$/`, { meta: { nativeType } });\n}\n/**\n* Sanity check against accidental SQL injection from malformed contract files.\n* Rejects semicolons, SQL comment tokens, and dollar-quoting.\n* Not a comprehensive security boundary — the contract is developer-authored.\n*/\nfunction assertSafeDefaultExpression(expression) {\n\tif (expression.includes(\";\") || /--|\\/\\*|\\$\\$|\\bSELECT\\b/i.test(expression)) throw postgresError(\"CONTRACT.DEFAULT_INVALID\", `Unsafe default expression in contract: \"${expression}\". Default expressions must not contain semicolons, SQL comment tokens, dollar-quoting, or subqueries.`, { meta: { expression } });\n}\n/**\n* Renders the SQL type for a column in DDL context.\n*\n* @param allowPseudoTypes - When true (default), autoincrement integer columns\n* produce SERIAL/BIGSERIAL/SMALLSERIAL pseudo-types. Set to false for contexts\n* like ALTER COLUMN TYPE where pseudo-types are invalid.\n*/\nfunction buildColumnTypeSql(column, codecHooks, storageTypes = {}, allowPseudoTypes = true) {\n\tconst resolved = resolveColumnTypeMetadata(column, storageTypes);\n\tif (allowPseudoTypes) {\n\t\tconst columnDefault = column.default;\n\t\tif (columnDefault?.kind === \"function\" && columnDefault.expression === \"autoincrement()\") {\n\t\t\tif (resolved.nativeType === \"int4\" || resolved.nativeType === \"integer\") return \"SERIAL\";\n\t\t\tif (resolved.nativeType === \"int8\" || resolved.nativeType === \"bigint\") return \"BIGSERIAL\";\n\t\t\tif (resolved.nativeType === \"int2\" || resolved.nativeType === \"smallint\") return \"SMALLSERIAL\";\n\t\t}\n\t}\n\tif (isPgEnumParams(resolved.typeParams)) {\n\t\tconst quoted = quoteQualifiedName(resolved.nativeType);\n\t\treturn column.many ? `${quoted}[]` : quoted;\n\t}\n\tconst expanded = expandParameterizedTypeSql(resolved, codecHooks);\n\tif (expanded !== null) return column.many ? `${expanded}[]` : expanded;\n\tif (column.typeRef) {\n\t\tconst base = quoteQualifiedName(resolved.nativeType);\n\t\treturn column.many ? `${base}[]` : base;\n\t}\n\tassertSafeNativeType(resolved.nativeType);\n\treturn column.many ? `${resolved.nativeType}[]` : resolved.nativeType;\n}\nfunction expandParameterizedTypeSql(column, codecHooks) {\n\tif (!column.typeParams || Object.keys(column.typeParams).length === 0) return null;\n\tif (!column.codecId) throw postgresError(\"CONTRACT.CODEC_DESCRIPTOR_MISSING\", `Column declares typeParams for nativeType \"${column.nativeType}\" but has no codecId. Ensure the column is associated with a codec.`, { meta: { nativeType: column.nativeType } });\n\tconst hooks = codecHooks.get(column.codecId);\n\tif (!hooks?.expandNativeType) {\n\t\tif (hooks?.planTypeOperations) return null;\n\t\tthrow postgresError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Column declares typeParams for nativeType \"${column.nativeType}\" but no expandNativeType hook is registered for codecId \"${column.codecId}\". Ensure the extension providing this codec is included in extensions.`, { meta: {\n\t\t\tcodecId: column.codecId,\n\t\t\tnativeType: column.nativeType\n\t\t} });\n\t}\n\tconst expanded = hooks.expandNativeType({\n\t\tnativeType: column.nativeType,\n\t\tcodecId: column.codecId,\n\t\t...ifDefined(\"typeParams\", column.typeParams)\n\t});\n\treturn expanded !== column.nativeType ? expanded : null;\n}\n/** Autoincrement columns use SERIAL types, so this returns empty for them. */\nfunction buildColumnDefaultSql(columnDefault, column) {\n\tif (!columnDefault) return \"\";\n\tswitch (columnDefault.kind) {\n\t\tcase \"literal\": return `DEFAULT ${renderDefaultLiteral(columnDefault.value, column)}`;\n\t\tcase \"function\":\n\t\t\tif (columnDefault.expression === \"autoincrement()\") return \"\";\n\t\t\tassertSafeDefaultExpression(columnDefault.expression);\n\t\t\treturn `DEFAULT (${columnDefault.expression})`;\n\t\tcase \"sequence\": return `DEFAULT nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`;\n\t}\n}\nfunction renderDefaultLiteral(value, column) {\n\tconst isJsonColumn = column?.nativeType === \"json\" || column?.nativeType === \"jsonb\";\n\tif (column?.many && Array.isArray(value)) return renderArrayLiteralDefault(value);\n\tif (value instanceof Date) return `'${escapeLiteral(value.toISOString())}'`;\n\tif (typeof value === \"string\") return `'${escapeLiteral(value)}'`;\n\tif (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n\tif (value === null) return \"NULL\";\n\tconst json = JSON.stringify(value);\n\tif (isJsonColumn) return `'${escapeLiteral(json)}'::${column.nativeType}`;\n\treturn `'${escapeLiteral(json)}'`;\n}\nfunction renderArrayLiteralDefault(elements) {\n\tif (elements.length === 0) return \"'{}'\";\n\treturn `ARRAY[${elements.map((el) => renderDefaultLiteral(el)).join(\", \")}]`;\n}\n//#endregion\nexport { buildColumnTypeSql as n, renderDefaultLiteral as r, buildColumnDefaultSql as t };\n\n//# sourceMappingURL=planner-ddl-builders-CbfICQfm.mjs.map"],"mappings":";;;;;;;;;;;AAWA,MAAM,2BAA2B;AACjC,SAAS,qBAAqB,YAAY;CACzC,IAAI,CAAC,yBAAyB,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U,MAAM,OAAO;CAC3B,MAAM,OAAO,KAAK,UAAU,KAAK;CACjC,IAAI,cAAc,OAAO,IAAI,cAAc,IAAI,EAAE,KAAK,OAAO;CAC7D,OAAO,IAAI,cAAc,IAAI,EAAE;AAChC;AACA,SAAS,0BAA0B,UAAU;CAC5C,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OAAO,SAAS,SAAS,KAAK,OAAO,qBAAqB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AAC3E"}
1
+ {"version":3,"file":"planner-ddl-builders-CbfICQfm-CGjwaNy7.mjs","names":[],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-ddl-builders-CbfICQfm.mjs"],"sourcesContent":["import { n as postgresError } from \"./errors-kYxOQjdD.mjs\";\nimport { n as isPgEnumParams } from \"./codecs-CBl0nD44.mjs\";\nimport { i as quoteQualifiedName, r as quoteIdentifier, t as escapeLiteral } from \"./sql-utils-BnBlQxyh.mjs\";\nimport { t as resolveColumnTypeMetadata } from \"./planner-type-resolution-Bt2f_q-F.mjs\";\nimport { ifDefined } from \"@internal/utils/defined\";\n//#region src/core/migrations/planner-ddl-builders.ts\n/**\n* Pattern for safe PostgreSQL type names.\n* Allows letters, digits, underscores, spaces (for \"double precision\", \"character varying\"),\n* and trailing [] for array types.\n*/\nconst SAFE_NATIVE_TYPE_PATTERN = /^[a-zA-Z][a-zA-Z0-9_ ]*(\\[\\])?$/;\nfunction assertSafeNativeType(nativeType) {\n\tif (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) throw postgresError(\"CONTRACT.NATIVE_TYPE_INVALID\", `Unsafe native type name in contract: \"${nativeType}\". Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*(\\\\[\\\\])?\\$/`, { meta: { nativeType } });\n}\n/**\n* Sanity check against accidental SQL injection from malformed contract files.\n* Rejects semicolons, SQL comment tokens, and dollar-quoting.\n* Not a comprehensive security boundary — the contract is developer-authored.\n*/\nfunction assertSafeDefaultExpression(expression) {\n\tif (expression.includes(\";\") || /--|\\/\\*|\\$\\$|\\bSELECT\\b/i.test(expression)) throw postgresError(\"CONTRACT.DEFAULT_INVALID\", `Unsafe default expression in contract: \"${expression}\". Default expressions must not contain semicolons, SQL comment tokens, dollar-quoting, or subqueries.`, { meta: { expression } });\n}\n/**\n* Renders the SQL type for a column in DDL context.\n*\n* @param allowPseudoTypes - When true (default), autoincrement integer columns\n* produce SERIAL/BIGSERIAL/SMALLSERIAL pseudo-types. Set to false for contexts\n* like ALTER COLUMN TYPE where pseudo-types are invalid.\n*/\nfunction buildColumnTypeSql(column, codecHooks, storageTypes = {}, allowPseudoTypes = true) {\n\tconst resolved = resolveColumnTypeMetadata(column, storageTypes);\n\tif (allowPseudoTypes) {\n\t\tconst columnDefault = column.default;\n\t\tif (columnDefault?.kind === \"function\" && columnDefault.expression === \"autoincrement()\") {\n\t\t\tif (resolved.nativeType === \"int4\" || resolved.nativeType === \"integer\") return \"SERIAL\";\n\t\t\tif (resolved.nativeType === \"int8\" || resolved.nativeType === \"bigint\") return \"BIGSERIAL\";\n\t\t\tif (resolved.nativeType === \"int2\" || resolved.nativeType === \"smallint\") return \"SMALLSERIAL\";\n\t\t}\n\t}\n\tif (isPgEnumParams(resolved.typeParams)) {\n\t\tconst quoted = quoteQualifiedName(resolved.nativeType);\n\t\treturn column.many ? `${quoted}[]` : quoted;\n\t}\n\tconst expanded = expandParameterizedTypeSql(resolved, codecHooks);\n\tif (expanded !== null) return column.many ? `${expanded}[]` : expanded;\n\tif (column.typeRef) {\n\t\tconst base = quoteQualifiedName(resolved.nativeType);\n\t\treturn column.many ? `${base}[]` : base;\n\t}\n\tassertSafeNativeType(resolved.nativeType);\n\treturn column.many ? `${resolved.nativeType}[]` : resolved.nativeType;\n}\nfunction expandParameterizedTypeSql(column, codecHooks) {\n\tif (!column.typeParams || Object.keys(column.typeParams).length === 0) return null;\n\tif (!column.codecId) throw postgresError(\"CONTRACT.CODEC_DESCRIPTOR_MISSING\", `Column declares typeParams for nativeType \"${column.nativeType}\" but has no codecId. Ensure the column is associated with a codec.`, { meta: { nativeType: column.nativeType } });\n\tconst hooks = codecHooks.get(column.codecId);\n\tif (!hooks?.expandNativeType) {\n\t\tif (hooks?.planTypeOperations) return null;\n\t\tthrow postgresError(\"CONTRACT.PACK_CONTRIBUTION_INVALID\", `Column declares typeParams for nativeType \"${column.nativeType}\" but no expandNativeType hook is registered for codecId \"${column.codecId}\". Ensure the extension providing this codec is included in extensions.`, { meta: {\n\t\t\tcodecId: column.codecId,\n\t\t\tnativeType: column.nativeType\n\t\t} });\n\t}\n\tconst expanded = hooks.expandNativeType({\n\t\tnativeType: column.nativeType,\n\t\tcodecId: column.codecId,\n\t\t...ifDefined(\"typeParams\", column.typeParams)\n\t});\n\treturn expanded !== column.nativeType ? expanded : null;\n}\n/** Autoincrement columns use SERIAL types, so this returns empty for them. */\nfunction buildColumnDefaultSql(columnDefault, column) {\n\tif (!columnDefault) return \"\";\n\tswitch (columnDefault.kind) {\n\t\tcase \"literal\": return `DEFAULT ${renderDefaultLiteral(columnDefault.value, column)}`;\n\t\tcase \"function\":\n\t\t\tif (columnDefault.expression === \"autoincrement()\") return \"\";\n\t\t\tassertSafeDefaultExpression(columnDefault.expression);\n\t\t\treturn `DEFAULT (${columnDefault.expression})`;\n\t\tcase \"sequence\": return `DEFAULT nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`;\n\t}\n}\nfunction renderDefaultLiteral(value, column) {\n\tconst isJsonColumn = column?.nativeType === \"json\" || column?.nativeType === \"jsonb\";\n\tif (column?.many && Array.isArray(value)) return renderArrayLiteralDefault(value);\n\tif (value instanceof Date) return `'${escapeLiteral(value.toISOString())}'`;\n\tif (typeof value === \"string\") return `'${escapeLiteral(value)}'`;\n\tif (typeof value === \"number\" || typeof value === \"boolean\") return String(value);\n\tif (value === null) return \"NULL\";\n\tconst json = JSON.stringify(value);\n\tif (isJsonColumn) return `'${escapeLiteral(json)}'::${column.nativeType}`;\n\treturn `'${escapeLiteral(json)}'`;\n}\nfunction renderArrayLiteralDefault(elements) {\n\tif (elements.length === 0) return \"'{}'\";\n\treturn `ARRAY[${elements.map((el) => renderDefaultLiteral(el)).join(\", \")}]`;\n}\n//#endregion\nexport { buildColumnTypeSql as n, renderDefaultLiteral as r, buildColumnDefaultSql as t };\n\n//# sourceMappingURL=planner-ddl-builders-CbfICQfm.mjs.map"],"mappings":";;;;;;;;;;;AAWA,MAAM,2BAA2B;AACjC,SAAS,qBAAqB,YAAY;CACzC,IAAI,CAAC,yBAAyB,KAAK,UAAU,GAAG,MAAM,cAAc,gCAAgC,yCAAyC,WAAW,uEAAuE,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACxP;;;;;;AAMA,SAAS,4BAA4B,YAAY;CAChD,IAAI,WAAW,SAAS,GAAG,KAAK,2BAA2B,KAAK,UAAU,GAAG,MAAM,cAAc,4BAA4B,2CAA2C,WAAW,yGAAyG,EAAE,MAAM,EAAE,WAAW,EAAE,CAAC;AACrT;;;;;;;;AAQA,SAAS,mBAAmB,QAAQ,YAAY,eAAe,CAAC,GAAG,mBAAmB,MAAM;CAC3F,MAAM,WAAW,0BAA0B,QAAQ,YAAY;CAC/D,IAAI,kBAAkB;EACrB,MAAM,gBAAgB,OAAO;EAC7B,IAAI,eAAe,SAAS,cAAc,cAAc,eAAe,mBAAmB;GACzF,IAAI,SAAS,eAAe,UAAU,SAAS,eAAe,WAAW,OAAO;GAChF,IAAI,SAAS,eAAe,UAAU,SAAS,eAAe,UAAU,OAAO;GAC/E,IAAI,SAAS,eAAe,UAAU,SAAS,eAAe,YAAY,OAAO;EAClF;CACD;CACA,IAAI,eAAe,SAAS,UAAU,GAAG;EACxC,MAAM,SAAS,mBAAmB,SAAS,UAAU;EACrD,OAAO,OAAO,OAAO,GAAG,OAAO,MAAM;CACtC;CACA,MAAM,WAAW,2BAA2B,UAAU,UAAU;CAChE,IAAI,aAAa,MAAM,OAAO,OAAO,OAAO,GAAG,SAAS,M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QAAQ;CAC5C,MAAM,eAAe,QAAQ,eAAe,UAAU,QAAQ,eAAe;CAC7E,IAAI,QAAQ,QAAQ,MAAM,QAAQ,KAAK,GAAG,OAAO,0BAA0B,KAAK;CAChF,IAAI,iBAAiB,MAAM,OAAO,IAAI,cAAc,MAAM,YAAY,CAAC,EAAE;CACzE,IAAI,OAAO,UAAU,UAAU,OAAO,IAAI,cAAc,KAAK,EAAE;CAC/D,IAAI,OAAO,UAAU,YAAY,OAAO,UAAU,WAAW,OAAO,OAAO,KAAK;CAChF,IAAI,UAAU,MAAM,OAAO;CAC3B,MAAM,OAAO,KAAK,UAAU,KAAK;CACjC,IAAI,cAAc,OAAO,IAAI,cAAc,IAAI,EAAE,KAAK,OAAO;CAC7D,OAAO,IAAI,cAAc,IAAI,EAAE;AAChC;AACA,SAAS,0BAA0B,UAAU;CAC5C,IAAI,SAAS,WAAW,GAAG,OAAO;CAClC,OAAO,SAAS,SAAS,KAAK,OAAO,qBAAqB,EAAE,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE;AAC3E"}
@@ -1,4 +1,4 @@
1
- import { t as PostgresMigration } from "./postgres-migration-CJshdIZn-DYYjgdD0.mjs";
1
+ import { t as PostgresMigration } from "./postgres-migration-CJshdIZn-CT6Cxd4x.mjs";
2
2
  import { t as renderOps } from "./render-ops-DxzTxSsv-Bz85uUHk.mjs";
3
3
  import { t as renderCallsToTypeScript } from "./render-typescript-Cw3lFO28-Cx0lXWmv.mjs";
4
4
  //#region ../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-Cicg2sXg.mjs
@@ -44,4 +44,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
44
44
  //#endregion
45
45
  export { TypeScriptRenderablePostgresMigration as t };
46
46
 
47
- //# sourceMappingURL=planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs.map
47
+ //# sourceMappingURL=planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"planner-produced-postgres-migration-Cicg2sXg-Ck9iDxGI.mjs","names":["#calls","#meta","#spaceId","#snapshotsImportPath","#lowerer","#operationsCache"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-Cicg2sXg.mjs"],"sourcesContent":["import { t as PostgresMigration } from \"./postgres-migration-CJshdIZn.mjs\";\nimport { t as renderOps } from \"./render-ops-DxzTxSsv.mjs\";\nimport { t as renderCallsToTypeScript } from \"./render-typescript-Cw3lFO28.mjs\";\n//#region src/core/migrations/planner-produced-postgres-migration.ts\nvar TypeScriptRenderablePostgresMigration = class extends PostgresMigration {\n\t#calls;\n\t#meta;\n\t#spaceId;\n\t#snapshotsImportPath;\n\t#lowerer;\n\t#operationsCache;\n\tconstructor(calls, meta, spaceId, snapshotsImportPath, lowerer) {\n\t\tsuper();\n\t\tthis.#calls = calls;\n\t\tthis.#meta = meta;\n\t\tthis.#spaceId = spaceId;\n\t\tthis.#snapshotsImportPath = snapshotsImportPath;\n\t\tthis.#lowerer = lowerer;\n\t}\n\tget operations() {\n\t\tthis.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n\t\treturn this.#operationsCache;\n\t}\n\tdescribe() {\n\t\treturn this.#meta;\n\t}\n\t/**\n\t* Contract space this planner-produced plan applies to. Threaded\n\t* from the planner options so the runner keys the marker row by\n\t* the right space when executing the plan.\n\t*/\n\tget spaceId() {\n\t\treturn this.#spaceId;\n\t}\n\trenderTypeScript(resolveImportSpecifier) {\n\t\treturn renderCallsToTypeScript(this.#calls, {\n\t\t\tfrom: this.#meta.from,\n\t\t\tto: this.#meta.to,\n\t\t\tsnapshotsImportPath: this.#snapshotsImportPath,\n\t\t\tresolveImportSpecifier\n\t\t});\n\t}\n};\n//#endregion\nexport { TypeScriptRenderablePostgresMigration as t };\n\n//# sourceMappingURL=planner-produced-postgres-migration-Cicg2sXg.mjs.map"],"mappings":";;;;AAIA,IAAI,wCAAwC,cAAc,kBAAkB;CAC3E;CACA;CACA;CACA;CACA;CACA;CACA,YAAY,OAAO,MAAM,SAAS,qBAAqB,SAAS;EAC/D,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,uBAAuB;EAC5B,KAAKC,WAAW;CACjB;CACA,IAAI,aAAa;EAChB,KAAKC,qBAAqB,UAAU,KAAKL,QAAQ,KAAKI,QAAQ;EAC9D,OAAO,KAAKC;CACb;CACA,WAAW;EACV,OAAO,KAAKJ;CACb;;;;;;CAMA,IAAI,UAAU;EACb,OAAO,KAAKC;CACb;CACA,iBAAiB,wBAAwB;EACxC,OAAO,wBAAwB,KAAKF,QAAQ;GAC3C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,qBAAqB,KAAKE;GAC1B;EACD,CAAC;CACF;AACD"}
1
+ {"version":3,"file":"planner-produced-postgres-migration-Cicg2sXg-CZI7mdz9.mjs","names":["#calls","#meta","#spaceId","#snapshotsImportPath","#lowerer","#operationsCache"],"sources":["../../../../3-targets/3-targets/postgres/dist/planner-produced-postgres-migration-Cicg2sXg.mjs"],"sourcesContent":["import { t as PostgresMigration } from \"./postgres-migration-CJshdIZn.mjs\";\nimport { t as renderOps } from \"./render-ops-DxzTxSsv.mjs\";\nimport { t as renderCallsToTypeScript } from \"./render-typescript-Cw3lFO28.mjs\";\n//#region src/core/migrations/planner-produced-postgres-migration.ts\nvar TypeScriptRenderablePostgresMigration = class extends PostgresMigration {\n\t#calls;\n\t#meta;\n\t#spaceId;\n\t#snapshotsImportPath;\n\t#lowerer;\n\t#operationsCache;\n\tconstructor(calls, meta, spaceId, snapshotsImportPath, lowerer) {\n\t\tsuper();\n\t\tthis.#calls = calls;\n\t\tthis.#meta = meta;\n\t\tthis.#spaceId = spaceId;\n\t\tthis.#snapshotsImportPath = snapshotsImportPath;\n\t\tthis.#lowerer = lowerer;\n\t}\n\tget operations() {\n\t\tthis.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n\t\treturn this.#operationsCache;\n\t}\n\tdescribe() {\n\t\treturn this.#meta;\n\t}\n\t/**\n\t* Contract space this planner-produced plan applies to. Threaded\n\t* from the planner options so the runner keys the marker row by\n\t* the right space when executing the plan.\n\t*/\n\tget spaceId() {\n\t\treturn this.#spaceId;\n\t}\n\trenderTypeScript(resolveImportSpecifier) {\n\t\treturn renderCallsToTypeScript(this.#calls, {\n\t\t\tfrom: this.#meta.from,\n\t\t\tto: this.#meta.to,\n\t\t\tsnapshotsImportPath: this.#snapshotsImportPath,\n\t\t\tresolveImportSpecifier\n\t\t});\n\t}\n};\n//#endregion\nexport { TypeScriptRenderablePostgresMigration as t };\n\n//# sourceMappingURL=planner-produced-postgres-migration-Cicg2sXg.mjs.map"],"mappings":";;;;AAIA,IAAI,wCAAwC,cAAc,kBAAkB;CAC3E;CACA;CACA;CACA;CACA;CACA;CACA,YAAY,OAAO,MAAM,SAAS,qBAAqB,SAAS;EAC/D,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,uBAAuB;EAC5B,KAAKC,WAAW;CACjB;CACA,IAAI,aAAa;EAChB,KAAKC,qBAAqB,UAAU,KAAKL,QAAQ,KAAKI,QAAQ;EAC9D,OAAO,KAAKC;CACb;CACA,WAAW;EACV,OAAO,KAAKJ;CACb;;;;;;CAMA,IAAI,UAAU;EACb,OAAO,KAAKC;CACb;CACA,iBAAiB,wBAAwB;EACxC,OAAO,wBAAwB,KAAKF,QAAQ;GAC3C,MAAM,KAAKC,MAAM;GACjB,IAAI,KAAKA,MAAM;GACf,qBAAqB,KAAKE;GAC1B;EACD,CAAC;CACF;AACD"}
@@ -1,6 +1,6 @@
1
1
  import { t as errorPostgresMigrationStackMissing } from "./errors-kYxOQjdD-D4T3rbVp.mjs";
2
2
  import { i as PostgresRlsPolicy } from "./postgres-schema-KSzLDONj-CsXGoY8b.mjs";
3
- import { A as RenamePostgresRlsPolicyCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as installExtension, M as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetDefaultCall, k as RenameIndexCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-DifL68KT-Bo6pxs-R.mjs";
3
+ import { A as RenamePostgresRlsPolicyCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, F as installExtension, M as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetDefaultCall, k as RenameIndexCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from "./op-factory-call-DifL68KT-CNFEDNsf.mjs";
4
4
  import { n as PostgresContractView } from "./postgres-contract-view-FdLX7dV9-Cat1VKV9.mjs";
5
5
  import { t as dataTransform } from "./data-transform-ChZzy2dP-CxVCat_8.mjs";
6
6
  import { Migration } from "@prisma/orm-family-sql/family/migration";
@@ -198,4 +198,4 @@ var PostgresMigration = class extends Migration {
198
198
  //#endregion
199
199
  export { PostgresMigration as t };
200
200
 
201
- //# sourceMappingURL=postgres-migration-CJshdIZn-DYYjgdD0.mjs.map
201
+ //# sourceMappingURL=postgres-migration-CJshdIZn-CT6Cxd4x.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"postgres-migration-CJshdIZn-DYYjgdD0.mjs","names":["#endView","#startView"],"sources":["../../../../3-targets/3-targets/postgres/dist/postgres-migration-CJshdIZn.mjs"],"sourcesContent":["import { t as errorPostgresMigrationStackMissing } from \"./errors-kYxOQjdD.mjs\";\nimport { _ as PostgresRlsPolicy } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { A as RenamePostgresRlsPolicyCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, I as installExtension, M as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetDefaultCall, k as RenameIndexCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from \"./op-factory-call-DifL68KT.mjs\";\nimport { t as PostgresContractView } from \"./postgres-contract-view-FdLX7dV9.mjs\";\nimport { t as dataTransform } from \"./data-transform-ChZzy2dP.mjs\";\nimport { Migration } from \"@internal/family-sql/migration\";\nimport { MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/migrations/postgres-migration.ts\n/**\n* Target-owned base class for Postgres migrations.\n*\n* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n* abstract `targetId` to the Postgres target-id string literal, so both\n* user-authored migrations and renderer-generated scaffolds (the output of\n* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n* redeclaring target-local identity.\n*\n* Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer\n* emits `extends Migration` against a facade re-export of this class\n* from `@internal/postgres/migration`, keeping the authoring surface\n* target-scoped rather than family-scoped.\n*\n* The constructor materializes a single Postgres `SqlControlAdapter` from\n* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n* instance method forwards to the free `dataTransform` factory with that\n* stored adapter, so user migrations can write `this.dataTransform(...)`\n* without threading the adapter through every call.\n*\n* Every method requires an explicit `schema`. Postgres migrations name their\n* schema deliberately — there is no default and no `search_path`-relative\n* option. A migration that left the schema unspecified would resolve against\n* whatever `search_path` the connection happened to carry, and that ambiguity\n* is an antipattern in a migration. (The unbound/unspecified namespace concept\n* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n*/\nvar PostgresMigration = class extends Migration {\n\ttargetId = \"postgres\";\n\t/**\n\t* Materialized Postgres control adapter, created once per migration\n\t* instance from the injected stack. `undefined` only when the migration\n\t* was instantiated without a stack (test fixtures); `controlAdapterFor`\n\t* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n\t*/\n\tcontrolAdapter;\n\t#endView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\tconstructor(stack) {\n\t\tsuper(stack);\n\t\tthis.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;\n\t}\n\t/**\n\t* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n\t* `operation` when the migration was constructed without a `ControlStack`.\n\t* Single home for the null-check that every DDL/DML method shares.\n\t*/\n\tcontrolAdapterFor(operation) {\n\t\tif (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);\n\t\treturn this.controlAdapter;\n\t}\n\t/**\n\t* The typed, schema-qualified Postgres view over this migration's end-state\n\t* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n\t* if no `endContractJson` was provided.\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed Postgres view over this migration's start-state contract, or\n\t* `null` for a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n\t/**\n\t* Instance-method wrapper around the free `dataTransform` factory that\n\t* supplies the stored control adapter. Authors call this from inside\n\t* `get operations()`; the adapter argument is hidden from the call site.\n\t*/\n\tdataTransform(contract, name, options) {\n\t\treturn dataTransform(contract, name, options, this.controlAdapterFor(\"dataTransform\"));\n\t}\n\t/**\n\t* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateTable(options) {\n\t\treturn new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor(\"createTable\"));\n\t}\n\t/**\n\t* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateSchema(options) {\n\t\treturn new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor(\"createSchema\"));\n\t}\n\t/**\n\t* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n\t* native enum. Builds a typed DDL node and lowers it through the stored\n\t* control adapter (members render in declaration order). Throws if no adapter\n\t* is present.\n\t*/\n\tcreateNativeEnumType(options) {\n\t\treturn new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor(\"createNativeEnumType\"));\n\t}\n\t/**\n\t* Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n\t* through the stored control adapter. Throws if no adapter is present.\n\t*/\n\tdropNativeEnumType(options) {\n\t\treturn new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor(\"dropNativeEnumType\"));\n\t}\n\t/**\n\t* Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n\t* member to a managed native enum, lowered through the stored control\n\t* adapter. Throws if no adapter is present. Every appended value is its\n\t* own operation — call this once per value to append more than one.\n\t*/\n\taddNativeEnumValue(options) {\n\t\treturn new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor(\"addNativeEnumValue\"));\n\t}\n\taddColumn(options) {\n\t\treturn new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"addColumn\"));\n\t}\n\taddPrimaryKey(options) {\n\t\treturn new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addPrimaryKey\"));\n\t}\n\taddUnique(options) {\n\t\treturn new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addUnique\"));\n\t}\n\taddForeignKey(options) {\n\t\treturn new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor(\"addForeignKey\"));\n\t}\n\taddCheckConstraint(options) {\n\t\treturn new AddCheckConstraintCall(options.schema, options.table, options.constraint, options.column, options.values).toOp(this.controlAdapterFor(\"addCheckConstraint\"));\n\t}\n\tdropCheckConstraint(options) {\n\t\treturn new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor(\"dropCheckConstraint\"));\n\t}\n\tdropConstraint(options) {\n\t\treturn new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? \"unique\").toOp(this.controlAdapterFor(\"dropConstraint\"));\n\t}\n\tdropTable(options) {\n\t\treturn new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor(\"dropTable\"));\n\t}\n\tdropColumn(options) {\n\t\treturn new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropColumn\"));\n\t}\n\talterColumnType(options) {\n\t\treturn new AlterColumnTypeCall(options.schema, options.table, options.column, options.options).toOp(this.controlAdapterFor(\"alterColumnType\"));\n\t}\n\tsetNotNull(options) {\n\t\treturn new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"setNotNull\"));\n\t}\n\tdropNotNull(options) {\n\t\treturn new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropNotNull\"));\n\t}\n\tsetDefault(options) {\n\t\treturn new SetDefaultCall(options.schema, options.table, options.column, options.defaultSql, options.operationClass).toOp(this.controlAdapterFor(\"setDefault\"));\n\t}\n\tdropDefault(options) {\n\t\treturn new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropDefault\"));\n\t}\n\tcreateIndex(options) {\n\t\treturn new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: options.expression }, options.extras).toOp(this.controlAdapterFor(\"createIndex\"));\n\t}\n\trenameIndex(options) {\n\t\treturn new RenameIndexCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameIndex\"));\n\t}\n\tdropIndex(options) {\n\t\treturn new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor(\"dropIndex\"));\n\t}\n\tinstallExtension(options) {\n\t\treturn installExtension(options, this.controlAdapterFor(\"installExtension\"));\n\t}\n\tenableRowLevelSecurity(options) {\n\t\treturn new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"enableRowLevelSecurity\"));\n\t}\n\tdisableRowLevelSecurity(options) {\n\t\treturn new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"disableRowLevelSecurity\"));\n\t}\n\tcreateRlsPolicy(options) {\n\t\treturn new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({\n\t\t\t...options.policy,\n\t\t\tusing: options.policy.using,\n\t\t\twithCheck: options.policy.withCheck\n\t\t})).toOp(this.controlAdapterFor(\"createRlsPolicy\"));\n\t}\n\tdropRlsPolicy(options) {\n\t\treturn new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor(\"dropRlsPolicy\"));\n\t}\n\trenameRlsPolicy(options) {\n\t\treturn new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapter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s","names":["#endView","#startView"],"sources":["../../../../3-targets/3-targets/postgres/dist/postgres-migration-CJshdIZn.mjs"],"sourcesContent":["import { t as errorPostgresMigrationStackMissing } from \"./errors-kYxOQjdD.mjs\";\nimport { _ as PostgresRlsPolicy } from \"./postgres-schema-KSzLDONj.mjs\";\nimport { A as RenamePostgresRlsPolicyCall, C as DropNativeEnumTypeCall, D as EnableRowLevelSecurityCall, E as DropTableCall, I as installExtension, M as SetNotNullCall, S as DropIndexCall, T as DropPostgresRlsPolicyCall, _ as DisableRowLevelSecurityCall, b as DropConstraintCall, c as AddUniqueCall, d as CreateIndexCall, f as CreateNativeEnumTypeCall, h as CreateTableCall, i as AddNativeEnumValueCall, j as SetDefaultCall, k as RenameIndexCall, l as AlterColumnTypeCall, m as CreateSchemaCall, n as AddColumnCall, p as CreatePostgresRlsPolicyCall, r as AddForeignKeyCall, s as AddPrimaryKeyCall, t as AddCheckConstraintCall, v as DropCheckConstraintCall, w as DropNotNullCall, x as DropDefaultCall, y as DropColumnCall } from \"./op-factory-call-DifL68KT.mjs\";\nimport { t as PostgresContractView } from \"./postgres-contract-view-FdLX7dV9.mjs\";\nimport { t as dataTransform } from \"./data-transform-ChZzy2dP.mjs\";\nimport { Migration } from \"@internal/family-sql/migration\";\nimport { MigrationContractViews } from \"@internal/migration-tools/migration\";\n//#region src/core/migrations/postgres-migration.ts\n/**\n* Target-owned base class for Postgres migrations.\n*\n* Fixes the `SqlMigration` generic to `PostgresPlanTargetDetails` and the\n* abstract `targetId` to the Postgres target-id string literal, so both\n* user-authored migrations and renderer-generated scaffolds (the output of\n* `renderCallsToTypeScript`) can extend `PostgresMigration` directly without\n* redeclaring target-local identity.\n*\n* Mirrors `MongoMigration` in `@internal/family-mongo`: the renderer\n* emits `extends Migration` against a facade re-export of this class\n* from `@internal/postgres/migration`, keeping the authoring surface\n* target-scoped rather than family-scoped.\n*\n* The constructor materializes a single Postgres `SqlControlAdapter` from\n* `stack.adapter.create(stack)` and stores it; the protected `dataTransform`\n* instance method forwards to the free `dataTransform` factory with that\n* stored adapter, so user migrations can write `this.dataTransform(...)`\n* without threading the adapter through every call.\n*\n* Every method requires an explicit `schema`. Postgres migrations name their\n* schema deliberately — there is no default and no `search_path`-relative\n* option. A migration that left the schema unspecified would resolve against\n* whatever `search_path` the connection happened to carry, and that ambiguity\n* is an antipattern in a migration. (The unbound/unspecified namespace concept\n* remains for SQLite, which has no schemas, and for Mongo's connection `db`.)\n*/\nvar PostgresMigration = class extends Migration {\n\ttargetId = \"postgres\";\n\t/**\n\t* Materialized Postgres control adapter, created once per migration\n\t* instance from the injected stack. `undefined` only when the migration\n\t* was instantiated without a stack (test fixtures); `controlAdapterFor`\n\t* throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n\t*/\n\tcontrolAdapter;\n\t#endView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\t#startView = new MigrationContractViews(this, \"PostgresMigration\", (json) => PostgresContractView.fromJson(json));\n\tconstructor(stack) {\n\t\tsuper(stack);\n\t\tthis.controlAdapter = stack?.adapter ? stack.adapter.create(stack) : void 0;\n\t}\n\t/**\n\t* Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n\t* `operation` when the migration was constructed without a `ControlStack`.\n\t* Single home for the null-check that every DDL/DML method shares.\n\t*/\n\tcontrolAdapterFor(operation) {\n\t\tif (!this.controlAdapter) throw errorPostgresMigrationStackMissing(operation);\n\t\treturn this.controlAdapter;\n\t}\n\t/**\n\t* The typed, schema-qualified Postgres view over this migration's end-state\n\t* contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n\t* if no `endContractJson` was provided.\n\t*/\n\tget endContract() {\n\t\treturn this.#endView.endContract;\n\t}\n\t/**\n\t* The typed Postgres view over this migration's start-state contract, or\n\t* `null` for a baseline migration (no `startContractJson`).\n\t*/\n\tget startContract() {\n\t\treturn this.#startView.startContract;\n\t}\n\t/**\n\t* Instance-method wrapper around the free `dataTransform` factory that\n\t* supplies the stored control adapter. Authors call this from inside\n\t* `get operations()`; the adapter argument is hidden from the call site.\n\t*/\n\tdataTransform(contract, name, options) {\n\t\treturn dataTransform(contract, name, options, this.controlAdapterFor(\"dataTransform\"));\n\t}\n\t/**\n\t* Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateTable(options) {\n\t\treturn new CreateTableCall(options.schema, options.table, options.columns, options.constraints).toOp(this.controlAdapterFor(\"createTable\"));\n\t}\n\t/**\n\t* Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n\t* the supplied options and lowers it through the stored control adapter.\n\t* Throws if no adapter is present (i.e. migration instantiated without a stack).\n\t*/\n\tcreateSchema(options) {\n\t\treturn new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor(\"createSchema\"));\n\t}\n\t/**\n\t* Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n\t* native enum. Builds a typed DDL node and lowers it through the stored\n\t* control adapter (members render in declaration order). Throws if no adapter\n\t* is present.\n\t*/\n\tcreateNativeEnumType(options) {\n\t\treturn new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(this.controlAdapterFor(\"createNativeEnumType\"));\n\t}\n\t/**\n\t* Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n\t* through the stored control adapter. Throws if no adapter is present.\n\t*/\n\tdropNativeEnumType(options) {\n\t\treturn new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(this.controlAdapterFor(\"dropNativeEnumType\"));\n\t}\n\t/**\n\t* Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n\t* member to a managed native enum, lowered through the stored control\n\t* adapter. Throws if no adapter is present. Every appended value is its\n\t* own operation — call this once per value to append more than one.\n\t*/\n\taddNativeEnumValue(options) {\n\t\treturn new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(this.controlAdapterFor(\"addNativeEnumValue\"));\n\t}\n\taddColumn(options) {\n\t\treturn new AddColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"addColumn\"));\n\t}\n\taddPrimaryKey(options) {\n\t\treturn new AddPrimaryKeyCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addPrimaryKey\"));\n\t}\n\taddUnique(options) {\n\t\treturn new AddUniqueCall(options.schema, options.table, options.constraint, options.columns).toOp(this.controlAdapterFor(\"addUnique\"));\n\t}\n\taddForeignKey(options) {\n\t\treturn new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(this.controlAdapterFor(\"addForeignKey\"));\n\t}\n\taddCheckConstraint(options) {\n\t\treturn new AddCheckConstraintCall(options.schema, options.table, options.constraint, options.column, options.values).toOp(this.controlAdapterFor(\"addCheckConstraint\"));\n\t}\n\tdropCheckConstraint(options) {\n\t\treturn new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(this.controlAdapterFor(\"dropCheckConstraint\"));\n\t}\n\tdropConstraint(options) {\n\t\treturn new DropConstraintCall(options.schema, options.table, options.constraint, options.kind ?? \"unique\").toOp(this.controlAdapterFor(\"dropConstraint\"));\n\t}\n\tdropTable(options) {\n\t\treturn new DropTableCall(options.schema, options.table).toOp(this.controlAdapterFor(\"dropTable\"));\n\t}\n\tdropColumn(options) {\n\t\treturn new DropColumnCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropColumn\"));\n\t}\n\talterColumnType(options) {\n\t\treturn new AlterColumnTypeCall(options.schema, options.table, options.column, options.options).toOp(this.controlAdapterFor(\"alterColumnType\"));\n\t}\n\tsetNotNull(options) {\n\t\treturn new SetNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"setNotNull\"));\n\t}\n\tdropNotNull(options) {\n\t\treturn new DropNotNullCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropNotNull\"));\n\t}\n\tsetDefault(options) {\n\t\treturn new SetDefaultCall(options.schema, options.table, options.column, options.defaultSql, options.operationClass).toOp(this.controlAdapterFor(\"setDefault\"));\n\t}\n\tdropDefault(options) {\n\t\treturn new DropDefaultCall(options.schema, options.table, options.column).toOp(this.controlAdapterFor(\"dropDefault\"));\n\t}\n\tcreateIndex(options) {\n\t\treturn new CreateIndexCall(options.schema, options.table, options.index, options.columns !== void 0 ? { columns: options.columns } : { expression: options.expression }, options.extras).toOp(this.controlAdapterFor(\"createIndex\"));\n\t}\n\trenameIndex(options) {\n\t\treturn new RenameIndexCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameIndex\"));\n\t}\n\tdropIndex(options) {\n\t\treturn new DropIndexCall(options.schema, options.table, options.index).toOp(this.controlAdapterFor(\"dropIndex\"));\n\t}\n\tinstallExtension(options) {\n\t\treturn installExtension(options, this.controlAdapterFor(\"installExtension\"));\n\t}\n\tenableRowLevelSecurity(options) {\n\t\treturn new EnableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"enableRowLevelSecurity\"));\n\t}\n\tdisableRowLevelSecurity(options) {\n\t\treturn new DisableRowLevelSecurityCall(options.schema, options.table).toOp(this.controlAdapterFor(\"disableRowLevelSecurity\"));\n\t}\n\tcreateRlsPolicy(options) {\n\t\treturn new CreatePostgresRlsPolicyCall(options.schema, options.table, new PostgresRlsPolicy({\n\t\t\t...options.policy,\n\t\t\tusing: options.policy.using,\n\t\t\twithCheck: options.policy.withCheck\n\t\t})).toOp(this.controlAdapterFor(\"createRlsPolicy\"));\n\t}\n\tdropRlsPolicy(options) {\n\t\treturn new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(this.controlAdapterFor(\"dropRlsPolicy\"));\n\t}\n\trenameRlsPolicy(options) {\n\t\treturn new RenamePostgresRlsPolicyCall(options.schema, options.table, options.from, options.to).toOp(this.controlAdapterFor(\"renameRlsPolicy\"));\n\t}\n};\n//#endregion\nexport { PostgresMigration as t };\n\n//# sourceMappingURL=postgres-migration-CJshdI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AAQ,QAAQ,OAAO,QAAQ,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,KAAK,kBAAkB,aAAa,CAAC;CAC/H;CACA,UAAU,SAAS;EAClB,OAAO,IAAI,cAAc,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,kBAAkB,WAAW,CAAC;CAChH;CACA,iBAAiB,SAAS;EACzB,OAAO,iBAAiB,SAAS,KAAK,kBAAkB,kBAAkB,CAAC;CAC5E;CACA,uBAAuB,SAAS;EAC/B,OAAO,IAAI,2BAA2B,QAAQ,QAAQ,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,kBAAkB,wBAAwB,CAAC;CAC3H;CACA,wBAAwB,SAAS;EAChC,OAAO,IAAI,4BAA4B,QAAQ,QAAQ,QAAQ,KAAK,CAAC,CAAC,KAAK,KAAK,kBAAkB,yBAAyB,CAAC;CAC7H;CACA,gBAAgB,SAAS;EACxB,OAAO,IAAI,4BAA4B,QAAQ,QAAQ,QAAQ,OAAO,IAAI,kBAAkB;GAC3F,GAAG,QAAQ;GACX,OAAO,QAAQ,OAAO;GACtB,WAAW,QAAQ,OAAO;EAC3B,CAAC,CAAC,CAAC,CAAC,KAAK,KAAK,kBAAkB,iBAAiB,CAAC;CACnD;CACA,cAAc,SAAS;EACtB,OAAO,IAAI,0BAA0B,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,CAAC,CAAC,KAAK,KAAK,kBAAkB,eAAe,CAAC;CACjI;CACA,gBAAgB,SAAS;EACxB,OAAO,IAAI,4BAA4B,QAAQ,QAAQ,QAAQ,OAAO,QAAQ,MAAM,QAAQ,EAAE,CAAC,CAAC,KAAK,KAAK,kBAAkB,iBAAiB,CAAC;CAC/I;AACD"}
@@ -38,7 +38,8 @@ interface PostgresDriverOptions {
38
38
  };
39
39
  readonly cursor?: PostgresCursorOptions | undefined;
40
40
  /**
41
- * Use server-side prepared statements for `executePrepared`. Default
41
+ * Use server-side prepared statements for `query()` requests with a
42
+ * prepared-statement handle. Default
42
43
  * `true`. Set `false` when running behind a transaction-mode pooler that
43
44
  * does not support session-scoped prepared statements (e.g. PgBouncer
44
45
  * transaction mode).
@@ -52,4 +53,4 @@ type PostgresRuntimeDriver = RuntimeDriverInstance<'sql', 'postgres'> & SqlDrive
52
53
  declare const postgresRuntimeDriverDescriptor: RuntimeDriverDescriptor<'sql', 'postgres', PostgresDriverCreateOptions, PostgresRuntimeDriver>;
53
54
  //#endregion
54
55
  export { postgresRuntimeDriverDescriptor as a, QueryResult$1 as i, PostgresDriverCreateOptions as n, PostgresRuntimeDriver as r, PostgresBinding as t };
55
- //# sourceMappingURL=runtime-CDewySU9.d.mts.map
56
+ //# sourceMappingURL=runtime-lHBKgjB9.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtime-lHBKgjB9.d.mts","names":[],"sources":["../../../../3-targets/7-drivers/postgres/dist/runtime.d.mts"],"mappings":";;;;;KAIK,cAAY,UAAU,iBAAiB,kBAAkB,YAAc;;;;;;;;;;;;;KAavE;WACM;WACA;;WAEA;WACA,MAAM;;WAEN;WACA,QAAQ;;UAET;WACC;WACA;;UAED;WACC;IACP,QAAQ;;IAER,MAAM;;WAEC,SAAS;;;;;;;;WAQT;;KAEN,8BAA8B,KAAK;;;KAGnC,wBAAwB,2CAA2C,UAAU;cACpE,iCAAiC,2CAA2C,6BAA6B"}