@prisma-next/target-postgres 0.16.0-dev.3 → 0.16.0-dev.31

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 (166) hide show
  1. package/README.md +1 -1
  2. package/dist/{authoring-34L18kA1.mjs → authoring-DnO1B0N9.mjs} +29 -18
  3. package/dist/authoring-DnO1B0N9.mjs.map +1 -0
  4. package/dist/canonicalize-C7zKHw8m.mjs +59 -0
  5. package/dist/canonicalize-C7zKHw8m.mjs.map +1 -0
  6. package/dist/{canonicalize-D1F4vUnP.d.mts → canonicalize-CQlxSR4D.d.mts} +3 -18
  7. package/dist/canonicalize-CQlxSR4D.d.mts.map +1 -0
  8. package/dist/{codec-types-CQ07nOz-.d.mts → codec-types-DdoPc2dy.d.mts} +3 -2
  9. package/dist/codec-types-DdoPc2dy.d.mts.map +1 -0
  10. package/dist/codec-types.d.mts +1 -1
  11. package/dist/{codecs-G4DTY0F_.d.mts → codecs-CGE5dh94.d.mts} +7 -2
  12. package/dist/codecs-CGE5dh94.d.mts.map +1 -0
  13. package/dist/{codecs-TCsGgW-Y.mjs → codecs-Deand7sy.mjs} +84 -26
  14. package/dist/codecs-Deand7sy.mjs.map +1 -0
  15. package/dist/codecs.d.mts +2 -2
  16. package/dist/codecs.mjs +2 -2
  17. package/dist/contract-free.d.mts +1 -1
  18. package/dist/contract-free.d.mts.map +1 -1
  19. package/dist/contract-free.mjs +2 -2
  20. package/dist/{control-policy-CZKdMztu.mjs → control-policy-DEwdS3oK.mjs} +29 -29
  21. package/dist/control-policy-DEwdS3oK.mjs.map +1 -0
  22. package/dist/control.mjs +91 -239
  23. package/dist/control.mjs.map +1 -1
  24. package/dist/data-transform-BOWpliq8.mjs.map +1 -1
  25. package/dist/{ddl-DHXKzQ99.mjs → ddl-BQC6u-L9.mjs} +28 -4
  26. package/dist/{ddl-DHXKzQ99.mjs.map → ddl-BQC6u-L9.mjs.map} +1 -1
  27. package/dist/ddl.d.mts +3 -3
  28. package/dist/ddl.mjs +2 -2
  29. package/dist/{descriptor-meta-qubYaxQA.mjs → descriptor-meta-DGlJurgA.mjs} +4 -4
  30. package/dist/{descriptor-meta-qubYaxQA.mjs.map → descriptor-meta-DGlJurgA.mjs.map} +1 -1
  31. package/dist/{diff-database-schema-C-hnJ5mr.mjs → diff-database-schema-qRPwuYBH.mjs} +37 -15
  32. package/dist/diff-database-schema-qRPwuYBH.mjs.map +1 -0
  33. package/dist/diff-database-schema.mjs +1 -1
  34. package/dist/{errors-ByDS0xJL.mjs → errors-DBSNx7EJ.mjs} +6 -2
  35. package/dist/errors-DBSNx7EJ.mjs.map +1 -0
  36. package/dist/errors.d.mts +4 -1
  37. package/dist/errors.d.mts.map +1 -1
  38. package/dist/errors.mjs +2 -2
  39. package/dist/issue-planner.d.mts +2 -2
  40. package/dist/issue-planner.d.mts.map +1 -1
  41. package/dist/issue-planner.mjs +1 -1
  42. package/dist/migration.d.mts +2 -2
  43. package/dist/migration.mjs +2 -2
  44. package/dist/{nodes-DJC5B8Id.mjs → nodes-04EILM-z.mjs} +65 -2
  45. package/dist/nodes-04EILM-z.mjs.map +1 -0
  46. package/dist/{nodes-CQzM2hR0.d.mts → nodes-DjCsN-uv.d.mts} +69 -4
  47. package/dist/nodes-DjCsN-uv.d.mts.map +1 -0
  48. package/dist/{op-factory-call-DT7kdjVP.d.mts → op-factory-call-0TB5XNij.d.mts} +46 -8
  49. package/dist/op-factory-call-0TB5XNij.d.mts.map +1 -0
  50. package/dist/{op-factory-call-DuRj7WXX.mjs → op-factory-call-CIaPDDUc.mjs} +147 -64
  51. package/dist/op-factory-call-CIaPDDUc.mjs.map +1 -0
  52. package/dist/op-factory-call.d.mts +2 -2
  53. package/dist/op-factory-call.mjs +2 -2
  54. package/dist/pack.d.mts +2 -2
  55. package/dist/pack.d.mts.map +1 -1
  56. package/dist/pack.mjs +1 -1
  57. package/dist/{planner-DPGxFcXo.mjs → planner-BhnkIJX-.mjs} +121 -13
  58. package/dist/planner-BhnkIJX-.mjs.map +1 -0
  59. package/dist/{planner-ddl-builders-BKlmGDJl.mjs → planner-ddl-builders-CVo3L7Nd.mjs} +12 -7
  60. package/dist/planner-ddl-builders-CVo3L7Nd.mjs.map +1 -0
  61. package/dist/planner-ddl-builders.d.mts.map +1 -1
  62. package/dist/planner-ddl-builders.mjs +1 -1
  63. package/dist/{planner-produced-postgres-migration-CFDpqWWE.mjs → planner-produced-postgres-migration-BE3EJIRK.mjs} +9 -6
  64. package/dist/planner-produced-postgres-migration-BE3EJIRK.mjs.map +1 -0
  65. package/dist/{planner-produced-postgres-migration-C-dwGdb2.d.mts → planner-produced-postgres-migration-CRAHl6ak.d.mts} +3 -3
  66. package/dist/planner-produced-postgres-migration-CRAHl6ak.d.mts.map +1 -0
  67. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  68. package/dist/planner-produced-postgres-migration.mjs +1 -1
  69. package/dist/{planner-schema-lookup-CiVaAQP-.mjs → planner-schema-lookup-D3Y_OL-C.mjs} +3 -3
  70. package/dist/planner-schema-lookup-D3Y_OL-C.mjs.map +1 -0
  71. package/dist/planner-schema-lookup.mjs +1 -1
  72. package/dist/{planner-sql-checks-BuB877wH.mjs → planner-sql-checks-CmiQ6Nei.mjs} +3 -3
  73. package/dist/{planner-sql-checks-BuB877wH.mjs.map → planner-sql-checks-CmiQ6Nei.mjs.map} +1 -1
  74. package/dist/planner-sql-checks.mjs +1 -1
  75. package/dist/planner.d.mts +27 -1
  76. package/dist/planner.d.mts.map +1 -1
  77. package/dist/planner.mjs +2 -2
  78. package/dist/{postgres-contract-view-DebHMqGR.mjs → postgres-contract-view-BeIEyZfD.mjs} +3 -3
  79. package/dist/{postgres-contract-view-DebHMqGR.mjs.map → postgres-contract-view-BeIEyZfD.mjs.map} +1 -1
  80. package/dist/{postgres-migration-C_OPFhIF.mjs → postgres-migration--BzvpA92.mjs} +9 -6
  81. package/dist/postgres-migration--BzvpA92.mjs.map +1 -0
  82. package/dist/{postgres-migration-DLIvzHjX.d.mts → postgres-migration-BXelnqHO.d.mts} +15 -10
  83. package/dist/postgres-migration-BXelnqHO.d.mts.map +1 -0
  84. package/dist/{postgres-schema-CewLYHB7.mjs → postgres-schema-CTplQZDK.mjs} +2 -2
  85. package/dist/{postgres-schema-CewLYHB7.mjs.map → postgres-schema-CTplQZDK.mjs.map} +1 -1
  86. package/dist/{render-ops-BREh1kHe.mjs → render-ops-TcY9XEkz.mjs} +7 -2
  87. package/dist/render-ops-TcY9XEkz.mjs.map +1 -0
  88. package/dist/render-ops.d.mts.map +1 -1
  89. package/dist/render-ops.mjs +1 -1
  90. package/dist/{render-typescript-7yqILcwr.mjs → render-typescript-Ta7_6CGf.mjs} +20 -8
  91. package/dist/render-typescript-Ta7_6CGf.mjs.map +1 -0
  92. package/dist/render-typescript.d.mts +2 -0
  93. package/dist/render-typescript.d.mts.map +1 -1
  94. package/dist/render-typescript.mjs +1 -1
  95. package/dist/{resolve-ddl-schema-D0wi_P9Q.mjs → resolve-ddl-schema-BAsJEKW8.mjs} +2 -2
  96. package/dist/{resolve-ddl-schema-D0wi_P9Q.mjs.map → resolve-ddl-schema-BAsJEKW8.mjs.map} +1 -1
  97. package/dist/rls-canonicalize.d.mts +2 -26
  98. package/dist/rls-canonicalize.mjs +2 -2
  99. package/dist/runtime.mjs +1 -1
  100. package/dist/schema-ir-annotations.mjs +1 -1
  101. package/dist/{sql-utils-SU4FDvIV.mjs → sql-utils-B2lzkKfP.mjs} +22 -19
  102. package/dist/sql-utils-B2lzkKfP.mjs.map +1 -0
  103. package/dist/sql-utils.d.mts +4 -9
  104. package/dist/sql-utils.d.mts.map +1 -1
  105. package/dist/sql-utils.mjs +2 -2
  106. package/dist/types.mjs +1 -1
  107. package/package.json +20 -20
  108. package/src/contract-free/ddl.ts +47 -0
  109. package/src/core/authoring.ts +35 -26
  110. package/src/core/codec-helpers.ts +69 -16
  111. package/src/core/codec-type-map.ts +2 -0
  112. package/src/core/codecs.ts +29 -14
  113. package/src/core/ddl/nodes.ts +104 -0
  114. package/src/core/errors.ts +30 -0
  115. package/src/core/migrations/column-ddl-rendering.ts +2 -1
  116. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +38 -14
  117. package/src/core/migrations/issue-planner.ts +40 -13
  118. package/src/core/migrations/op-factory-call.ts +189 -44
  119. package/src/core/migrations/operations/constraints.ts +3 -2
  120. package/src/core/migrations/operations/data-transform.ts +1 -1
  121. package/src/core/migrations/operations/indexes.ts +80 -32
  122. package/src/core/migrations/operations/rls.ts +4 -1
  123. package/src/core/migrations/planner-ddl-builders.ts +16 -6
  124. package/src/core/migrations/planner-produced-postgres-migration.ts +8 -1
  125. package/src/core/migrations/planner-schema-lookup.ts +2 -2
  126. package/src/core/migrations/planner.ts +163 -5
  127. package/src/core/migrations/postgres-migration.ts +26 -8
  128. package/src/core/migrations/render-ops.ts +4 -1
  129. package/src/core/migrations/render-typescript.ts +20 -8
  130. package/src/core/migrations/runner.ts +7 -3
  131. package/src/core/psl-infer/infer-psl-contract.ts +36 -185
  132. package/src/core/psl-infer/postgres-type-map.ts +43 -65
  133. package/src/core/rls/canonicalize.ts +4 -21
  134. package/src/core/sql-utils.ts +16 -27
  135. package/src/exports/codecs.ts +2 -0
  136. package/src/exports/ddl.ts +4 -0
  137. package/src/exports/errors.ts +1 -1
  138. package/src/exports/op-factory-call.ts +1 -0
  139. package/src/exports/rls-canonicalize.ts +0 -6
  140. package/src/exports/sql-utils.ts +0 -1
  141. package/dist/authoring-34L18kA1.mjs.map +0 -1
  142. package/dist/canonicalize-D1F4vUnP.d.mts.map +0 -1
  143. package/dist/codec-types-CQ07nOz-.d.mts.map +0 -1
  144. package/dist/codecs-G4DTY0F_.d.mts.map +0 -1
  145. package/dist/codecs-TCsGgW-Y.mjs.map +0 -1
  146. package/dist/control-policy-CZKdMztu.mjs.map +0 -1
  147. package/dist/diff-database-schema-C-hnJ5mr.mjs.map +0 -1
  148. package/dist/errors-ByDS0xJL.mjs.map +0 -1
  149. package/dist/nodes-CQzM2hR0.d.mts.map +0 -1
  150. package/dist/nodes-DJC5B8Id.mjs.map +0 -1
  151. package/dist/op-factory-call-DT7kdjVP.d.mts.map +0 -1
  152. package/dist/op-factory-call-DuRj7WXX.mjs.map +0 -1
  153. package/dist/planner-DPGxFcXo.mjs.map +0 -1
  154. package/dist/planner-ddl-builders-BKlmGDJl.mjs.map +0 -1
  155. package/dist/planner-produced-postgres-migration-C-dwGdb2.d.mts.map +0 -1
  156. package/dist/planner-produced-postgres-migration-CFDpqWWE.mjs.map +0 -1
  157. package/dist/planner-schema-lookup-CiVaAQP-.mjs.map +0 -1
  158. package/dist/postgres-migration-C_OPFhIF.mjs.map +0 -1
  159. package/dist/postgres-migration-DLIvzHjX.d.mts.map +0 -1
  160. package/dist/render-ops-BREh1kHe.mjs.map +0 -1
  161. package/dist/render-typescript-7yqILcwr.mjs.map +0 -1
  162. package/dist/rls-canonicalize.d.mts.map +0 -1
  163. package/dist/sql-utils-SU4FDvIV.mjs.map +0 -1
  164. package/dist/wire-name-DbQ9-2RC.mjs +0 -104
  165. package/dist/wire-name-DbQ9-2RC.mjs.map +0 -1
  166. package/src/core/rls/wire-name.ts +0 -33
@@ -1 +0,0 @@
1
- {"version":3,"file":"op-factory-call-DuRj7WXX.mjs","names":["contractFreeDdl.alterTable","contractFreeDdl.dropDefaultAction","contractFreeDdl.addColumnAction","disableRowLevelSecurityDdl","contractFreeDdl.alterTable","contractFreeDdl.addColumnAction","contractFreeDdl.dropDefaultAction","exhaustive","contractFreeDdl.createTable","contractFreeDdl.alterTable","contractFreeDdl.addColumnAction","contractFreeDdl.createSchema"],"sources":["../src/core/migrations/bound-schema.ts","../src/core/migrations/operations/shared.ts","../src/core/migrations/operations/columns.ts","../src/core/migrations/operations/constraints.ts","../src/core/migrations/operations/dependencies.ts","../src/core/migrations/operations/indexes.ts","../src/core/migrations/operations/native-enum-types.ts","../src/core/migrations/operations/rls.ts","../src/core/migrations/operations/tables.ts","../src/core/migrations/planner-target-details.ts","../src/core/migrations/planner-recipes.ts","../src/core/migrations/op-factory-call.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\n\n/**\n * Maps a planner schema name to the contract-free DDL builder's optional\n * `schema` field: the unbound sentinel becomes `undefined` (the builder omits\n * the schema qualifier), every other name passes through.\n */\nexport function boundSchema(schemaName: string): string | undefined {\n return schemaName === UNBOUND_NAMESPACE_ID ? undefined : schemaName;\n}\n","import type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport type { OperationClass, PostgresPlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Literal-args shape for a foreign key definition. `references.schema`\n * carries the target table's namespace (schema) coordinate so the rendered\n * DDL qualifies the REFERENCES clause correctly for cross-schema FKs.\n */\nexport interface ForeignKeySpec {\n readonly name: string;\n readonly columns: readonly string[];\n readonly references: {\n readonly schema: string;\n readonly table: string;\n readonly columns: readonly string[];\n };\n readonly onDelete?: ReferentialAction;\n readonly onUpdate?: ReferentialAction;\n}\n\nexport function step(description: string, sql: string, params?: readonly unknown[]) {\n return { description, sql, ...ifDefined('params', params) };\n}\n\nexport function targetDetails(\n objectType: OperationClass,\n name: string,\n schema: string,\n table?: string,\n): { readonly id: 'postgres'; readonly details: PostgresPlanTargetDetails } {\n return {\n id: 'postgres',\n details: { schema, objectType, name, ...ifDefined('table', table) },\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { DdlColumn } from '@prisma-next/sql-relational-core/ast';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport {\n columnDefaultAst,\n columnExistsAst,\n columnNullabilityAst,\n columnTypeAst,\n noNullValuesAst,\n tableIsEmptyAst,\n} from '../../../contract-free/checks';\nimport * as contractFreeDdl from '../../../contract-free/ddl';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { boundSchema } from '../bound-schema';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\ntype CheckStep = { sql: string; params?: readonly unknown[] };\n\nasync function columnExistsSteps(\n lowerer: ExecuteRequestLowerer,\n options: { schema: string; table: string; column: string },\n): Promise<{ present: CheckStep; absent: CheckStep }> {\n const checks = columnExistsAst(options);\n const present = await lowerer.lowerToExecuteRequest(checks.columnPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.columnAbsent());\n return { present, absent };\n}\n\nexport async function dropColumn(\n schemaName: string,\n tableName: string,\n columnName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { present, absent } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n return {\n id: `dropColumn.${tableName}.${columnName}`,\n label: `Drop column \"${columnName}\" from \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `drop column \"${columnName}\"`,\n `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`,\n ),\n ],\n postcheck: [step(`verify column \"${columnName}\" does not exist`, absent.sql, absent.params)],\n };\n}\n\n/**\n * `qualifiedTargetType` is the new column type as it appears in the\n * `ALTER COLUMN TYPE` clause (schema-qualified for user-defined types, raw\n * native name for built-ins). `formatTypeExpected` is the unqualified\n * `format_type` form used in the postcheck. `rawTargetTypeForLabel` is the\n * string appearing in the human-readable label (typically `toType` when\n * explicit, else the column's native type).\n */\nexport async function alterColumnType(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n },\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const usingClause = options.using\n ? ` USING ${options.using}`\n : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n const typeCheck = await lowerer.lowerToExecuteRequest(\n columnTypeAst({\n schema: schemaName,\n table: tableName,\n column: columnName,\n expectedType: options.formatTypeExpected,\n }),\n );\n return {\n id: `alterType.${tableName}.${columnName}`,\n label: `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `alter type of \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} TYPE ${options.qualifiedTargetType}${usingClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" has type \"${options.formatTypeExpected}\"`,\n typeCheck.sql,\n typeCheck.params,\n ),\n ],\n meta: { warning: 'TABLE_REWRITE' },\n };\n}\n\nexport async function setNotNull(\n schemaName: string,\n tableName: string,\n columnName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n const noNulls = await lowerer.lowerToExecuteRequest(\n noNullValuesAst({ schema: schemaName, table: tableName, column: columnName }),\n );\n const notNullable = await lowerer.lowerToExecuteRequest(\n columnNullabilityAst({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n );\n return {\n id: `alterNullability.setNotNull.${tableName}.${columnName}`,\n label: `Set NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(`ensure column \"${columnName}\" exists`, present.sql, present.params),\n step(`ensure no NULL values in \"${columnName}\"`, noNulls.sql, noNulls.params),\n ],\n execute: [\n step(\n `set NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET NOT NULL`,\n ),\n ],\n postcheck: [\n step(`verify column \"${columnName}\" is NOT NULL`, notNullable.sql, notNullable.params),\n ],\n };\n}\n\nexport async function dropNotNull(\n schemaName: string,\n tableName: string,\n columnName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n const nullable = await lowerer.lowerToExecuteRequest(\n columnNullabilityAst({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: true,\n }),\n );\n return {\n id: `alterNullability.dropNotNull.${tableName}.${columnName}`,\n label: `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'widening',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `drop NOT NULL on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP NOT NULL`,\n ),\n ],\n postcheck: [step(`verify column \"${columnName}\" is nullable`, nullable.sql, nullable.params)],\n };\n}\n\n/**\n * `defaultSql` is the full `DEFAULT …` clause as produced by\n * `buildColumnDefaultSql` — e.g. `\"DEFAULT 42\"`,\n * `\"DEFAULT (CURRENT_TIMESTAMP)\"`, or `\"DEFAULT nextval('seq'::regclass)\"`.\n *\n * `operationClass` defaults to `'additive'` (setting a default on a column\n * that currently has none). The reconciliation planner passes `'widening'`\n * when the column already has a different default — policy enforcement\n * treats that as a widening change rather than an additive one.\n */\nexport async function setDefault(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n lowerer: ExecuteRequestLowerer,\n operationClass: 'additive' | 'widening' = 'additive',\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n const hasDefault = await lowerer.lowerToExecuteRequest(\n columnDefaultAst({ schema: schemaName, table: tableName, column: columnName }).defaultPresent(),\n );\n return {\n id: `setDefault.${tableName}.${columnName}`,\n label: `Set default on \"${tableName}\".\"${columnName}\"`,\n operationClass,\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `set default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} SET ${defaultSql}`,\n ),\n ],\n postcheck: [\n step(`verify column \"${columnName}\" has a default`, hasDefault.sql, hasDefault.params),\n ],\n };\n}\n\nexport async function dropDefault(\n schemaName: string,\n tableName: string,\n columnName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\n });\n const dropDefaultExec = await lowerer.lowerToExecuteRequest(\n contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(schemaName)),\n table: tableName,\n actions: [contractFreeDdl.dropDefaultAction(columnName)],\n }),\n );\n const noDefault = await lowerer.lowerToExecuteRequest(\n columnDefaultAst({ schema: schemaName, table: tableName, column: columnName }).defaultAbsent(),\n );\n return {\n id: `dropDefault.${tableName}.${columnName}`,\n label: `Drop default on \"${tableName}\".\"${columnName}\"`,\n operationClass: 'destructive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" exists`, present.sql, present.params)],\n execute: [step(`drop default on \"${columnName}\"`, dropDefaultExec.sql)],\n postcheck: [\n step(`verify column \"${columnName}\" has no default`, noDefault.sql, noDefault.params),\n ],\n };\n}\n\n/**\n * Builds the op for adding a NOT NULL column (no contract default) to a\n * non-empty table. Prechecks assert the column is absent and the table is\n * empty; the execute step lowers the typed `AddColumn` DDL node through the\n * adapter; postchecks assert the column exists and is NOT NULL.\n */\nexport async function addNotNullColumnDirect(\n schemaName: string,\n tableName: string,\n column: DdlColumn,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const columnName = column.name;\n const addColumn = await lowerer.lowerToExecuteRequest(\n contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(schemaName)),\n table: tableName,\n actions: [contractFreeDdl.addColumnAction(column)],\n }),\n );\n const absent = await lowerer.lowerToExecuteRequest(\n columnExistsAst({ schema: schemaName, table: tableName, column: columnName }).columnAbsent(),\n );\n const tableEmpty = await lowerer.lowerToExecuteRequest(tableIsEmptyAst(schemaName, tableName));\n const present = await lowerer.lowerToExecuteRequest(\n columnExistsAst({ schema: schemaName, table: tableName, column: columnName }).columnPresent(),\n );\n const notNullable = await lowerer.lowerToExecuteRequest(\n columnNullabilityAst({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n );\n return {\n id: `column.${tableName}.${columnName}`,\n label: `Add column ${columnName} to ${tableName}`,\n summary: `Adds column ${columnName} to table ${tableName}`,\n operationClass: 'additive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [\n step(`ensure column \"${columnName}\" is missing`, absent.sql, absent.params),\n step(\n `ensure table \"${tableName}\" is empty before adding NOT NULL column without default`,\n tableEmpty.sql,\n tableEmpty.params,\n ),\n ],\n execute: [step(`add column \"${columnName}\"`, addColumn.sql)],\n postcheck: [\n step(`verify column \"${columnName}\" exists`, present.sql, present.params),\n step(`verify column \"${columnName}\" is NOT NULL`, notNullable.sql, notNullable.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { REFERENTIAL_ACTION_SQL } from '@prisma-next/sql-contract/referential-action-sql';\nimport { constraintExistsAst } from '../../../contract-free/checks';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type ForeignKeySpec, type Op, step, targetDetails } from './shared';\n\nasync function constraintCheckSteps(\n lowerer: ExecuteRequestLowerer,\n options: { constraintName: string; schema: string; table: string },\n): Promise<{\n absent: { sql: string; params?: readonly unknown[] };\n present: { sql: string; params?: readonly unknown[] };\n}> {\n const checks = constraintExistsAst(options);\n const absent = await lowerer.lowerToExecuteRequest(checks.constraintAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.constraintPresent());\n return { absent, present };\n}\n\nfunction renderForeignKeySql(schemaName: string, tableName: string, fk: ForeignKeySpec): string {\n let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}\nADD CONSTRAINT ${quoteIdentifier(fk.name)}\nFOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')})\nREFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.references.columns\n .map(quoteIdentifier)\n .join(', ')})`;\n\n if (fk.onDelete !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onDelete];\n if (!action) {\n throw new Error(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);\n }\n sql += `\\nON DELETE ${action}`;\n }\n if (fk.onUpdate !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];\n if (!action) {\n throw new Error(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);\n }\n sql += `\\nON UPDATE ${action}`;\n }\n return sql;\n}\n\nexport async function addPrimaryKey(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `primaryKey.${tableName}.${constraintName}`,\n label: `Add primary key on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('primaryKey', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure primary key \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add primary key \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`,\n ),\n ],\n postcheck: [step(`verify primary key \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addUnique(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `unique.${tableName}.${constraintName}`,\n label: `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`,\n operationClass: 'additive',\n target: targetDetails('unique', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add unique constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`,\n ),\n ],\n postcheck: [step(`verify constraint \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addForeignKey(\n schemaName: string,\n tableName: string,\n fk: ForeignKeySpec,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `foreignKey.${tableName}.${fk.name}`,\n label: `Add foreign key \"${fk.name}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('foreignKey', fk.name, schemaName, tableName),\n precheck: [step(`ensure FK \"${fk.name}\" does not exist`, absent.sql, absent.params)],\n execute: [step(`add FK \"${fk.name}\"`, renderForeignKeySql(schemaName, tableName, fk))],\n postcheck: [step(`verify FK \"${fk.name}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addCheckConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n column: string,\n values: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const valueList = values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `checkConstraint.${tableName}.${constraintName}`,\n label: `Add check constraint \"${constraintName}\" on \"${tableName}\".\"${column}\"`,\n operationClass: 'additive',\n target: targetDetails('checkConstraint', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add check constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${quoteIdentifier(column)} IN (${valueList}))`,\n ),\n ],\n postcheck: [step(`verify constraint \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropCheckConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `dropCheckConstraint.${tableName}.${constraintName}`,\n label: `Drop check constraint \"${constraintName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('checkConstraint', constraintName, schemaName, tableName),\n precheck: [step(`ensure constraint \"${constraintName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `drop check constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(`verify constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n };\n}\n\n/**\n * `kind` feeds the operation's `target.details.objectType`. Descriptor-flow\n * does not carry kind information in its drop-constraint descriptor, so the\n * default is `'unique'`. The reconciliation planner passes the correct kind\n * (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the diff issue\n * that produced the drop.\n */\nexport async function dropConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n lowerer: ExecuteRequestLowerer,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `dropConstraint.${tableName}.${constraintName}`,\n label: `Drop constraint \"${constraintName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails(kind, constraintName, schemaName, tableName),\n precheck: [step(`ensure constraint \"${constraintName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `drop constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(`verify constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { extensionExistsAst } from '../../../contract-free/checks';\nimport { DEFAULT_NAMESPACE_ID } from '../../namespace-ids';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { type Op, step } from './shared';\n\nexport function createExtension(extensionName: string): Op {\n return {\n id: `extension.${extensionName}`,\n label: `Create extension \"${extensionName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${quoteIdentifier(extensionName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n\n/**\n * Install a Postgres extension as the baseline op for an extension-pack\n * contract space. Layered on top of {@link createExtension}: stamps an\n * `invariantId` (required so the per-space marker records the install),\n * scopes the op `id` under a caller-chosen namespace (e.g. `pgvector.`),\n * and emits pre- and postcheck SQL probing `pg_extension`. The richer\n * shape lets the runner's idempotency probe skip the install on re-run\n * (postcheck-pre-satisfied) without firing the precheck.\n *\n * Use this for hand-rolled baseline migrations in contract-space\n * extension packages (e.g. `extension-pgvector`, `extension-paradedb`);\n * use the bare {@link createExtension} for planner-emitted ops where the\n * caller already controls idempotency through the surrounding plan.\n */\nexport async function installExtension(\n options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n },\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { extensionName, invariantId, id } = options;\n const label = options.label ?? `Enable extension \"${extensionName}\"`;\n const checks = extensionExistsAst(extensionName);\n const absent = await lowerer.lowerToExecuteRequest(checks.extensionAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.extensionPresent());\n return {\n id,\n label,\n operationClass: 'additive',\n invariantId,\n target: {\n id: 'postgres',\n details: { schema: DEFAULT_NAMESPACE_ID, objectType: 'dependency', name: extensionName },\n },\n precheck: [\n step(`verify extension \"${extensionName}\" is not already enabled`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${extensionName}`,\n ),\n ],\n postcheck: [\n step(`confirm extension \"${extensionName}\" is enabled`, present.sql, present.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { indexExistsAst } from '../../../contract-free/checks';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\ntype CheckStep = { sql: string; params?: readonly unknown[] };\n\nasync function indexExistsSteps(\n lowerer: ExecuteRequestLowerer,\n schemaName: string,\n indexName: string,\n): Promise<{ present: CheckStep; absent: CheckStep }> {\n const checks = indexExistsAst(schemaName, indexName);\n const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());\n return { present, absent };\n}\n\nexport interface CreateIndexExtras {\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\nfunction renderIndexOptionValue(key: string, value: unknown): string {\n if (typeof value === 'string') return `'${escapeLiteral(value)}'`;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n throw new Error(\n `Index option \"${key}\" must be a string, finite number, or boolean; got ${typeof value}`,\n );\n}\n\nfunction renderIndexOptions(options: Record<string, unknown>): string {\n return Object.entries(options)\n .map(([key, value]) => `${quoteIdentifier(key)} = ${renderIndexOptionValue(key, value)}`)\n .join(', ');\n}\n\nexport async function createIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n extras?: CreateIndexExtras,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const using = extras?.type ? ` USING ${quoteIdentifier(extras.type)}` : '';\n const options = extras?.options;\n const withClause =\n options && Object.keys(options).length > 0 ? ` WITH (${renderIndexOptions(options)})` : '';\n const { present, absent } = await indexExistsSteps(lowerer, schemaName, indexName);\n return {\n id: `index.${tableName}.${indexName}`,\n label: `Create index \"${indexName}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [step(`ensure index \"${indexName}\" does not exist`, absent.sql, absent.params)],\n execute: [\n step(\n `create index \"${indexName}\"`,\n `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`,\n ),\n ],\n postcheck: [step(`verify index \"${indexName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { present, absent } = await indexExistsSteps(lowerer, schemaName, indexName);\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index \"${indexName}\"`,\n operationClass: 'destructive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [step(`ensure index \"${indexName}\" exists`, present.sql, present.params)],\n execute: [\n step(`drop index \"${indexName}\"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`),\n ],\n postcheck: [step(`verify index \"${indexName}\" does not exist`, absent.sql, absent.params)],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { createType, dropType } from '../../../contract-free/ddl';\nimport { validateEnumValueLength } from '../../sql-utils';\nimport { boundSchema } from '../bound-schema';\nimport { type Op, step, targetDetails } from './shared';\n\n/**\n * `CREATE TYPE <qualified> AS ENUM (…)` for a managed native enum, built as a\n * typed DDL node and lowered by the control adapter (the type name is quoted,\n * member values render as escaped string literals in declaration order —\n * Postgres enum sort order is semantic). `boundSchema` maps the unbound sentinel\n * to an absent schema so the type name renders unqualified and the connection's\n * `search_path` resolves the schema at runtime.\n */\nexport async function createNativeEnumType(\n schemaName: string,\n typeName: string,\n members: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n for (const member of members) {\n validateEnumValueLength(member, typeName);\n }\n const ddlNode = createType({\n ...ifDefined('schema', boundSchema(schemaName)),\n name: typeName,\n values: members,\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n return {\n id: `createNativeEnumType.${typeName}`,\n label: `Create enum type \"${typeName}\"`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [],\n execute: [step(`create enum type \"${typeName}\"`, statement.sql, statement.params)],\n postcheck: [],\n };\n}\n\n/** `DROP TYPE <qualified>` for an unclaimed managed native enum, via typed DDL. */\nexport async function dropNativeEnumType(\n schemaName: string,\n typeName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const ddlNode = dropType({\n ...ifDefined('schema', boundSchema(schemaName)),\n name: typeName,\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n return {\n id: `dropNativeEnumType.${typeName}`,\n label: `Drop enum type \"${typeName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [],\n execute: [step(`drop enum type \"${typeName}\"`, statement.sql, statement.params)],\n postcheck: [],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { rlsEnabledAst, rlsPolicyExistsAst } from '../../../contract-free/checks';\nimport {\n alterPolicyRename,\n createPolicy,\n disableRowLevelSecurity as disableRowLevelSecurityDdl,\n dropPolicy,\n} from '../../../contract-free/ddl';\nimport type { PostgresRlsPolicy } from '../../postgres-rls-policy';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\nconst PLAIN_IDENTIFIER = /^[A-Za-z_][A-Za-z0-9_$]*$/;\n\nfunction validateRoleName(role: string): string {\n if (!PLAIN_IDENTIFIER.test(role)) {\n throw new Error(\n `Invalid role name ${JSON.stringify(role)}: role names must be plain SQL identifiers matching ^[A-Za-z_][A-Za-z0-9_$]*$`,\n );\n }\n return role;\n}\n\nexport async function createRlsPolicy(\n schemaName: string,\n tableName: string,\n policy: PostgresRlsPolicy,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const validatedRoles = policy.roles.map(validateRoleName);\n const ddlNode = createPolicy({\n schema: schemaName,\n table: tableName,\n name: policy.name,\n permissive: policy.permissive,\n operation: policy.operation,\n roles: validatedRoles,\n ...ifDefined('using', policy.using),\n ...ifDefined('withCheck', policy.withCheck),\n });\n const checks = rlsPolicyExistsAst({\n schema: schemaName,\n table: tableName,\n policyName: policy.name,\n });\n const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());\n const execute = await lowerer.lowerToExecuteRequest(ddlNode);\n const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());\n return {\n id: `rlsPolicy.${schemaName}.${tableName}.${policy.name}`,\n label: `Create RLS policy \"${policy.name}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('rlsPolicy', policy.name, schemaName, tableName),\n precheck: [\n step(`ensure RLS policy \"${policy.name}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [step(`create RLS policy \"${policy.name}\"`, execute.sql, execute.params)],\n postcheck: [step(`verify RLS policy \"${policy.name}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropRlsPolicy(\n schemaName: string,\n tableName: string,\n policyName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const ddlNode = dropPolicy({ schema: schemaName, table: tableName, name: policyName });\n const checks = rlsPolicyExistsAst({ schema: schemaName, table: tableName, policyName });\n const present = await lowerer.lowerToExecuteRequest(checks.policyPresent());\n const execute = await lowerer.lowerToExecuteRequest(ddlNode);\n const absent = await lowerer.lowerToExecuteRequest(checks.policyAbsent());\n return {\n id: `rlsPolicy.${schemaName}.${tableName}.${policyName}.drop`,\n label: `Drop RLS policy \"${policyName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('rlsPolicy', policyName, schemaName, tableName),\n precheck: [step(`ensure RLS policy \"${policyName}\" exists`, present.sql, present.params)],\n execute: [step(`drop RLS policy \"${policyName}\"`, execute.sql, execute.params)],\n postcheck: [step(`verify RLS policy \"${policyName}\" is absent`, absent.sql, absent.params)],\n };\n}\n\nexport async function enableRowLevelSecurity(\n schemaName: string,\n tableName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const checks = rlsEnabledAst(schemaName, tableName);\n const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());\n const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());\n return {\n id: `rowLevelSecurity.${schemaName}.${tableName}`,\n label: `Enable row-level security on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('rowLevelSecurity', tableName, schemaName),\n precheck: [\n step(`check RLS is not already enabled on \"${tableName}\"`, disabled.sql, disabled.params),\n ],\n execute: [\n step(\n `enable row-level security on \"${tableName}\"`,\n `ALTER TABLE ${qualifyTableName(schemaName, tableName)} ENABLE ROW LEVEL SECURITY`,\n ),\n ],\n postcheck: [\n step(`verify row-level security is enabled on \"${tableName}\"`, enabled.sql, enabled.params),\n ],\n };\n}\n\nexport async function disableRowLevelSecurity(\n schemaName: string,\n tableName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const ddlNode = disableRowLevelSecurityDdl({ schema: schemaName, table: tableName });\n const checks = rlsEnabledAst(schemaName, tableName);\n const enabled = await lowerer.lowerToExecuteRequest(checks.rlsEnabled());\n const execute = await lowerer.lowerToExecuteRequest(ddlNode);\n const disabled = await lowerer.lowerToExecuteRequest(checks.rlsDisabled());\n return {\n id: `rowLevelSecurity.${schemaName}.${tableName}.disable`,\n label: `Disable row-level security on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('rowLevelSecurity', tableName, schemaName),\n precheck: [\n step(`check RLS is currently enabled on \"${tableName}\"`, enabled.sql, enabled.params),\n ],\n execute: [step(`disable row-level security on \"${tableName}\"`, execute.sql, execute.params)],\n postcheck: [\n step(\n `verify row-level security is disabled on \"${tableName}\"`,\n disabled.sql,\n disabled.params,\n ),\n ],\n };\n}\n\nexport async function renameRlsPolicy(\n schemaName: string,\n tableName: string,\n oldPolicyName: string,\n newPolicyName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const ddlNode = alterPolicyRename({\n schema: schemaName,\n table: tableName,\n name: oldPolicyName,\n newName: newPolicyName,\n });\n const oldChecks = rlsPolicyExistsAst({\n schema: schemaName,\n table: tableName,\n policyName: oldPolicyName,\n });\n const newChecks = rlsPolicyExistsAst({\n schema: schemaName,\n table: tableName,\n policyName: newPolicyName,\n });\n const oldPresent = await lowerer.lowerToExecuteRequest(oldChecks.policyPresent());\n const execute = await lowerer.lowerToExecuteRequest(ddlNode);\n const newPresent = await lowerer.lowerToExecuteRequest(newChecks.policyPresent());\n return {\n id: `rlsPolicy.${schemaName}.${tableName}.${oldPolicyName}.rename`,\n label: `Rename RLS policy \"${oldPolicyName}\" to \"${newPolicyName}\" on \"${tableName}\"`,\n operationClass: 'widening',\n target: targetDetails('rlsPolicy', newPolicyName, schemaName, tableName),\n precheck: [\n step(`ensure RLS policy \"${oldPolicyName}\" exists`, oldPresent.sql, oldPresent.params),\n ],\n execute: [\n step(\n `rename RLS policy \"${oldPolicyName}\" to \"${newPolicyName}\"`,\n execute.sql,\n execute.params,\n ),\n ],\n postcheck: [\n step(`verify RLS policy \"${newPolicyName}\" exists`, newPresent.sql, newPresent.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { tableExistsAst } from '../../../contract-free/checks';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\nexport async function dropTable(\n schemaName: string,\n tableName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const checks = tableExistsAst(schemaName, tableName);\n const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [step(`ensure table \"${tableName}\" exists`, present.sql, present.params)],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${qualified}`)],\n postcheck: [step(`verify table \"${tableName}\" does not exist`, absent.sql, absent.params)],\n };\n}\n","import { ifDefined } from '@prisma-next/utils/defined';\n\nexport type OperationClass =\n | 'dependency'\n | 'type'\n | 'table'\n | 'column'\n | 'primaryKey'\n | 'unique'\n | 'index'\n | 'foreignKey'\n | 'checkConstraint'\n | 'rlsPolicy'\n | 'rowLevelSecurity';\n\nexport interface PostgresPlanTargetDetails {\n readonly schema: string;\n readonly objectType: OperationClass;\n readonly name: string;\n readonly table?: string;\n}\n\nexport function buildTargetDetails(\n objectType: OperationClass,\n name: string,\n schema: string,\n table?: string,\n): PostgresPlanTargetDetails {\n return {\n schema,\n objectType,\n name,\n ...ifDefined('table', table),\n };\n}\n","import type { CodecControlHooks, SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { FunctionColumnDefault } from '@prisma-next/sql-relational-core/ast';\nimport { col } from '@prisma-next/sql-relational-core/contract-free';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport {\n columnDefaultAst,\n columnExistsAst,\n columnNullabilityAst,\n} from '../../contract-free/checks';\nimport * as contractFreeDdl from '../../contract-free/ddl';\nimport { boundSchema } from './bound-schema';\nimport { step } from './operations/shared';\nimport { buildColumnTypeSql } from './planner-ddl-builders';\nimport { buildTargetDetails, type PostgresPlanTargetDetails } from './planner-target-details';\n\nexport function buildAddColumnOperationIdentity(\n schema: string,\n tableName: string,\n columnName: string,\n): Pick<\n SqlMigrationPlanOperation<PostgresPlanTargetDetails>,\n 'id' | 'label' | 'summary' | 'target'\n> {\n return {\n id: `column.${tableName}.${columnName}`,\n label: `Add column ${columnName} to ${tableName}`,\n summary: `Adds column ${columnName} to table ${tableName}`,\n target: {\n id: 'postgres',\n details: buildTargetDetails('table', tableName, schema),\n },\n };\n}\n\nexport async function buildAddNotNullColumnWithTemporaryDefaultOperation(options: {\n readonly schema: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: StorageColumn;\n readonly codecHooks: Map<string, CodecControlHooks>;\n readonly storageTypes: Record<string, StorageTypeInstance>;\n readonly temporaryDefault: string;\n readonly lowerer: ExecuteRequestLowerer;\n}): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n const {\n schema,\n tableName,\n columnName,\n column,\n codecHooks,\n storageTypes,\n temporaryDefault,\n lowerer,\n } = options;\n\n // The recipe handles NOT NULL columns that carry no contract default, so the\n // temporary backfill value is the only default. It is a pre-rendered SQL\n // fragment (e.g. `''`, `0`, `'{}'::jsonb`), carried verbatim as a\n // `FunctionColumnDefault` so the adapter emits it as a `DEFAULT (...)` clause.\n const ddlColumn = col(columnName, buildColumnTypeSql(column, codecHooks, storageTypes), {\n notNull: true,\n default: new FunctionColumnDefault(temporaryDefault),\n });\n const addColumn = await lowerer.lowerToExecuteRequest(\n contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(schema)),\n table: tableName,\n actions: [contractFreeDdl.addColumnAction(ddlColumn)],\n }),\n );\n const dropTempDefault = await lowerer.lowerToExecuteRequest(\n contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(schema)),\n table: tableName,\n actions: [contractFreeDdl.dropDefaultAction(columnName)],\n }),\n );\n\n const absent = await lowerer.lowerToExecuteRequest(\n columnExistsAst({ schema, table: tableName, column: columnName }).columnAbsent(),\n );\n const present = await lowerer.lowerToExecuteRequest(\n columnExistsAst({ schema, table: tableName, column: columnName }).columnPresent(),\n );\n const notNullable = await lowerer.lowerToExecuteRequest(\n columnNullabilityAst({ schema, table: tableName, column: columnName, nullable: false }),\n );\n const noDefault = await lowerer.lowerToExecuteRequest(\n columnDefaultAst({ schema, table: tableName, column: columnName }).noDefault(),\n );\n\n return {\n ...buildAddColumnOperationIdentity(schema, tableName, columnName),\n operationClass: 'additive',\n precheck: [step(`ensure column \"${columnName}\" is missing`, absent.sql, absent.params)],\n execute: [\n {\n description: `add column \"${columnName}\"`,\n sql: addColumn.sql,\n },\n {\n description: `drop temporary default from column \"${columnName}\"`,\n sql: dropTempDefault.sql,\n },\n ],\n postcheck: [\n step(`verify column \"${columnName}\" exists`, present.sql, present.params),\n step(`verify column \"${columnName}\" is NOT NULL`, notNullable.sql, notNullable.params),\n step(\n `verify column \"${columnName}\" has no default after temporary default removal`,\n noDefault.sql,\n noDefault.params,\n ),\n ],\n };\n}\n","/**\n * Postgres migration IR: one concrete `*Call` class per pure factory under\n * `operations/`, plus a shared `PostgresOpFactoryCallNode` abstract base.\n *\n * Every call class carries the literal arguments its backing factory would\n * receive, computes a human-readable `label` in its constructor, and\n * implements two polymorphic hooks:\n *\n * - `toOp()` — converts the IR node to a runtime\n * `SqlMigrationPlanOperation` by delegating to the matching pure factory\n * under `operations/`. `DataTransformCall.toOp()` always throws\n * `MIGRATION.UNFILLED_PLACEHOLDER` because a planner-generated data transform is an\n * unfilled authoring stub by construction.\n * - `renderTypeScript()` / `importRequirements()` — inherited from\n * `TsExpression`. Used by `renderCallsToTypeScript` to emit the call as\n * a TypeScript expression inside the scaffolded `migration.ts`.\n *\n * The abstract base and all concrete classes are package-private. External\n * consumers see only the framework-level `OpFactoryCall` interface and the\n * `PostgresOpFactoryCall` union.\n */\n\nimport { errorUnfilledPlaceholder } from '@prisma-next/errors/migration';\nimport type { CodecControlHooks, SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer, Lowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n OpFactoryCall as FrameworkOpFactoryCall,\n MigrationOperationClass,\n} from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport type {\n AnyDdlColumnDefault,\n DdlColumn,\n DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport { FunctionColumnDefault, LiteralColumnDefault } from '@prisma-next/sql-relational-core/ast';\nimport { type ImportRequirement, jsonToTsSource, TsExpression } from '@prisma-next/ts-render';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport {\n columnExistsAst,\n nativeEnumTypeExistsAst,\n nativeEnumValueExistsAst,\n tableExistsAst,\n} from '../../contract-free/checks';\nimport * as contractFreeDdl from '../../contract-free/ddl';\nimport type { PostgresRlsPolicy, PostgresRlsPolicyInput } from '../postgres-rls-policy';\nimport {\n escapeLiteral,\n quoteIdentifier,\n quoteQualifiedName,\n validateEnumValueLength,\n} from '../sql-utils';\nimport type { PostgresColumnDefault } from '../types';\nimport { boundSchema } from './bound-schema';\nimport {\n addNotNullColumnDirect,\n alterColumnType,\n dropColumn,\n dropDefault,\n dropNotNull,\n setDefault,\n setNotNull,\n} from './operations/columns';\nimport {\n addCheckConstraint,\n addForeignKey,\n addPrimaryKey,\n addUnique,\n dropCheckConstraint,\n dropConstraint,\n} from './operations/constraints';\nimport { createExtension } from './operations/dependencies';\nimport { createIndex, dropIndex } from './operations/indexes';\nimport { createNativeEnumType, dropNativeEnumType } from './operations/native-enum-types';\nimport {\n createRlsPolicy,\n disableRowLevelSecurity,\n dropRlsPolicy,\n enableRowLevelSecurity,\n renameRlsPolicy,\n} from './operations/rls';\nimport type { ForeignKeySpec } from './operations/shared';\nimport { step, targetDetails } from './operations/shared';\nimport { dropTable } from './operations/tables';\nimport { buildAddNotNullColumnWithTemporaryDefaultOperation } from './planner-recipes';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\ntype Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n// Single module specifier emitted in user-edited `migration.ts` imports. The\n// Postgres migration facade re-exports both the `*Call` factory names\n// (createTable / addColumn / …) and the contract-free DDL builders\n// (col / lit / fn / primaryKey / foreignKey / unique) from\n// sql-relational-core/contract-free. We emit imports against the facade,\n// not against the underlying sql-relational-core subpath, because user\n// projects depend on `@prisma-next/postgres` (a runtime dep of every\n// init-scaffolded project) — they do not depend on the internal\n// `@prisma-next/sql-relational-core` package, so an emitted\n// `import … from '@prisma-next/sql-relational-core/contract-free'` fails\n// ESM resolution at runtime in user migrations even though pnpm has the\n// transitive package on disk.\nconst POSTGRES_MIGRATION_FACADE = '@prisma-next/postgres/migration';\n\nabstract class PostgresOpFactoryCallNode extends TsExpression implements FrameworkOpFactoryCall {\n abstract readonly factoryName: string;\n abstract readonly operationClass: MigrationOperationClass;\n abstract readonly label: string;\n abstract toOp(lowerer?: Lowerer): Op | Promise<Op>;\n\n importRequirements(): readonly ImportRequirement[] {\n return [{ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: this.factoryName }];\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\n// ============================================================================\n// Table\n// ============================================================================\n\nexport function postgresDefaultToDdlColumnDefault(\n columnDefault: PostgresColumnDefault | undefined,\n): DdlColumn['default'] {\n if (!columnDefault) return undefined;\n switch (columnDefault.kind) {\n case 'literal':\n return new LiteralColumnDefault(columnDefault.value);\n case 'function':\n if (columnDefault.expression === 'autoincrement()') return undefined;\n return new FunctionColumnDefault(columnDefault.expression);\n case 'sequence':\n return new FunctionColumnDefault(\n `nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`,\n );\n default: {\n const exhaustive: never = columnDefault;\n throw new Error(\n `postgresDefaultToDdlColumnDefault: unhandled kind \"${blindCast<{ kind: string }, 'exhaustiveness: surface the unhandled default kind'>(exhaustive).kind}\"`,\n );\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// TypeScript rendering helpers for DdlColumn / DdlTableConstraint\n// ---------------------------------------------------------------------------\n\nfunction renderDdlColumnDefault(def: AnyDdlColumnDefault | undefined): string {\n if (!def) return '';\n if (def.kind === 'literal') {\n return `lit(${jsonToTsSource(def.value)})`;\n }\n return `fn(${jsonToTsSource(def.expression)})`;\n}\n\nfunction renderDdlColumnAsTsCall(col: DdlColumn): string {\n const opts: string[] = [];\n if (col.notNull) opts.push('notNull: true');\n if (col.primaryKey) opts.push('primaryKey: true');\n if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default)}`);\n if (col.codecRef) opts.push(`codecRef: ${jsonToTsSource(col.codecRef)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `col(${jsonToTsSource(col.name)}, ${jsonToTsSource(col.type)}${optsStr})`;\n}\n\nfunction renderDdlConstraintAsTsCall(constraint: DdlTableConstraint): string {\n switch (constraint.kind) {\n case 'primary-key': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `primaryKey(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n case 'foreign-key': {\n const opts: string[] = [];\n if (constraint.name) opts.push(`name: ${jsonToTsSource(constraint.name)}`);\n if (constraint.onDelete) opts.push(`onDelete: ${jsonToTsSource(constraint.onDelete)}`);\n if (constraint.onUpdate) opts.push(`onUpdate: ${jsonToTsSource(constraint.onUpdate)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `foreignKey(${jsonToTsSource(constraint.columns)}, ${jsonToTsSource(constraint.refTable)}, ${jsonToTsSource(constraint.refColumns)}${optsStr})`;\n }\n case 'unique': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n case 'check-expression':\n return `checkExpression(${jsonToTsSource(constraint.name)}, ${jsonToTsSource(constraint.expression)})`;\n }\n}\n\nfunction needsColOrConstraintImport(columns: readonly DdlColumn[]): boolean {\n return columns.length > 0;\n}\n\nfunction constraintImportSymbols(constraints: readonly DdlTableConstraint[] | undefined): string[] {\n if (!constraints || constraints.length === 0) return [];\n const symbols = new Set<string>();\n for (const c of constraints) {\n if (c.kind === 'primary-key') symbols.add('primaryKey');\n else if (c.kind === 'foreign-key') symbols.add('foreignKey');\n else if (c.kind === 'unique') symbols.add('unique');\n else if (c.kind === 'check-expression') symbols.add('checkExpression');\n }\n return [...symbols];\n}\n\nfunction defaultImportSymbols(columns: readonly DdlColumn[]): string[] {\n const symbols = new Set<string>();\n for (const col of columns) {\n if (col.default?.kind === 'literal') symbols.add('lit');\n else if (col.default?.kind === 'function') symbols.add('fn');\n }\n return [...symbols];\n}\n\nexport class CreateTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createTable' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columns: readonly DdlColumn[];\n readonly constraints: readonly DdlTableConstraint[] | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columns: readonly DdlColumn[],\n constraints?: readonly DdlTableConstraint[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columns = Object.freeze([...columns]);\n this.constraints = constraints ? Object.freeze([...constraints]) : undefined;\n this.label = `Create table \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateTableCall.toOp: a DDL lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.createTable({\n ...ifDefined('schema', boundSchema(this.schemaName)),\n table: this.tableName,\n columns: this.columns,\n ...ifDefined('constraints', this.constraints),\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n const tableName = this.tableName;\n const checks = tableExistsAst(schemaName, tableName);\n const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());\n return {\n id: `table.${tableName}`,\n label: `Create table \"${tableName}\"`,\n summary: `Creates table \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [step(`ensure table \"${tableName}\" does not exist`, absent.sql, absent.params)],\n execute: [\n {\n description: `create table \"${tableName}\"`,\n sql: statement.sql,\n params: statement.params ?? [],\n },\n ],\n postcheck: [step(`verify table \"${tableName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n const columnsList = this.columns.map(renderDdlColumnAsTsCall).join(', ');\n const constraintsList = this.constraints\n ? this.constraints.map(renderDdlConstraintAsTsCall).join(', ')\n : undefined;\n\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`columns: [${columnsList}]`);\n if (constraintsList) opts.push(`constraints: [${constraintsList}]`);\n\n return `this.createTable({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n const req: ImportRequirement[] = [];\n if (needsColOrConstraintImport(this.columns)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'col' });\n for (const sym of defaultImportSymbols(this.columns)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n }\n for (const sym of constraintImportSymbols(this.constraints)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n return req;\n }\n}\n\nexport class DropTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropTable' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.label = `Drop table \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropTableCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropTable(this.schemaName, this.tableName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n return `this.dropTable({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Column\n// ============================================================================\n\nexport class AddColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addColumn' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly column: DdlColumn;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, column: DdlColumn) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.column = column;\n this.label = `Add column \"${column.name}\" to \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddColumnCall.toOp: a DDL lowerer is required on the Postgres planner path (column \"${this.column.name}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(this.schemaName)),\n table: this.tableName,\n actions: [contractFreeDdl.addColumnAction(this.column)],\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n const tableName = this.tableName;\n const columnName = this.column.name;\n const colChecks = columnExistsAst({ schema: schemaName, table: tableName, column: columnName });\n const absent = await lowerer.lowerToExecuteRequest(colChecks.columnAbsent());\n const present = await lowerer.lowerToExecuteRequest(colChecks.columnPresent());\n return {\n id: `column.${schemaName}.${tableName}.${columnName}`,\n label: `Add column \"${columnName}\" to \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" is missing`, absent.sql, absent.params)],\n execute: [step(`add column \"${columnName}\"`, statement.sql)],\n postcheck: [step(`verify column \"${columnName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${renderDdlColumnAsTsCall(this.column)}`);\n return `this.addColumn({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n const req: ImportRequirement[] = [\n { moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'col' },\n ];\n for (const sym of defaultImportSymbols([this.column])) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n return req;\n }\n}\n\nexport class DropColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropColumn' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop column \"${columnName}\" from \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropColumnCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropColumn(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropColumn({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport interface AlterColumnTypeOptions {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n}\n\nexport class AlterColumnTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'alterColumnType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly options: AlterColumnTypeOptions;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: AlterColumnTypeOptions,\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.options = options;\n this.label = `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AlterColumnTypeCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n opts.push(`options: ${jsonToTsSource(this.options)}`);\n return `this.alterColumnType({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class SetNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setNotNull' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Set NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `SetNotNullCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return setNotNull(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.setNotNull({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropNotNull' as const;\n readonly operationClass = 'widening' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropNotNullCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropNotNull(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropNotNull({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class SetDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setDefault' as const;\n readonly operationClass: 'additive' | 'widening';\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly defaultSql: string;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.defaultSql = defaultSql;\n this.operationClass = operationClass;\n this.label = `Set default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `SetDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return setDefault(\n this.schemaName,\n this.tableName,\n this.columnName,\n this.defaultSql,\n lowerer,\n this.operationClass,\n );\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n opts.push(`defaultSql: ${jsonToTsSource(this.defaultSql)}`);\n if (this.operationClass !== 'additive') {\n opts.push(`operationClass: ${jsonToTsSource(this.operationClass)}`);\n }\n return `this.setDefault({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropDefault' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropDefault(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropDefault({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// NOT NULL column additions (planner-internal; no authored surface)\n// ============================================================================\n\n/**\n * Planner-internal call for adding a NOT NULL column (no contract default) to\n * a table that must be empty at migration time. Carries the typed `DdlColumn`\n * and lowers it to an ADD COLUMN execute step via the adapter at `toOp` time.\n *\n * No authored `PostgresMigration` method: this call is only emitted by the\n * planner, never hand-written by migration authors.\n */\nexport class AddNotNullColumnDirectCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: DdlColumn;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string, column: DdlColumn) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.column = column;\n this.label = `Add column ${columnName} to ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddNotNullColumnDirectCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addNotNullColumnDirect(this.schemaName, this.tableName, this.column, lowerer);\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource({ id: `column.${this.tableName}.${this.columnName}`, label: this.label, operationClass: 'additive' })})`;\n }\n}\n\n/**\n * Planner-internal call for adding a NOT NULL column (no contract default)\n * using a temporary default value for non-empty tables. Carries all parameters\n * needed for `buildAddNotNullColumnWithTemporaryDefaultOperation`; both the\n * typed ADD COLUMN execute step and the pre/postchecks are lowered via the\n * adapter at `toOp` time.\n *\n * No authored `PostgresMigration` method: this call is only emitted by the\n * planner, never hand-written by migration authors.\n */\nexport class AddNotNullColumnWithTempDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: StorageColumn;\n readonly codecHooks: Map<string, CodecControlHooks>;\n readonly storageTypes: Record<string, StorageTypeInstance>;\n readonly temporaryDefault: string;\n readonly label: string;\n\n constructor(options: {\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: StorageColumn;\n readonly codecHooks: Map<string, CodecControlHooks>;\n readonly storageTypes: Record<string, StorageTypeInstance>;\n readonly temporaryDefault: string;\n }) {\n super();\n this.schemaName = options.schemaName;\n this.tableName = options.tableName;\n this.columnName = options.columnName;\n this.column = options.column;\n this.codecHooks = options.codecHooks;\n this.storageTypes = options.storageTypes;\n this.temporaryDefault = options.temporaryDefault;\n this.label = `Add column ${options.columnName} to ${options.tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddNotNullColumnWithTempDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return buildAddNotNullColumnWithTemporaryDefaultOperation({\n schema: this.schemaName,\n tableName: this.tableName,\n columnName: this.columnName,\n column: this.column,\n codecHooks: this.codecHooks,\n storageTypes: this.storageTypes,\n temporaryDefault: this.temporaryDefault,\n lowerer,\n });\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource({ id: `column.${this.tableName}.${this.columnName}`, label: this.label, operationClass: 'additive' })})`;\n }\n}\n\n// ============================================================================\n// Constraints\n// ============================================================================\n\nfunction constraintCallOptions(\n schemaName: string,\n tableName: string,\n constraintName: string,\n): string {\n const opts: string[] = [];\n if (schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(tableName)}`);\n opts.push(`constraint: ${jsonToTsSource(constraintName)}`);\n return opts.join(', ');\n}\n\nexport class AddPrimaryKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addPrimaryKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add primary key on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddPrimaryKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addPrimaryKey(\n this.schemaName,\n this.tableName,\n this.constraintName,\n this.columns,\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n return `this.addPrimaryKey({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, columns: ${jsonToTsSource(this.columns)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddUniqueCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addUnique' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddUniqueCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.addUnique({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, columns: ${jsonToTsSource(this.columns)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddForeignKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addForeignKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly fk: ForeignKeySpec;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, fk: ForeignKeySpec) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.fk = fk;\n this.label = `Add foreign key \"${fk.name}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddForeignKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.fk.name}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addForeignKey(this.schemaName, this.tableName, this.fk, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`foreignKey: ${jsonToTsSource(this.fk)}`);\n return `this.addForeignKey({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropConstraint' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly kind: 'foreignKey' | 'unique' | 'primaryKey';\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.kind = kind;\n this.label = `Drop constraint \"${constraintName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropConstraint(this.schemaName, this.tableName, this.constraintName, lowerer, this.kind);\n }\n\n renderTypeScript(): string {\n const opts = [constraintCallOptions(this.schemaName, this.tableName, this.constraintName)];\n if (this.kind !== 'unique') {\n opts.push(`kind: ${jsonToTsSource(this.kind)}`);\n }\n return `this.dropConstraint({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddCheckConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addCheckConstraint' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly column: string;\n readonly values: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n column: string,\n values: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.column = column;\n this.values = values;\n this.label = `Add check constraint \"${constraintName}\" on \"${tableName}\".\"${column}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addCheckConstraint(\n this.schemaName,\n this.tableName,\n this.constraintName,\n this.column,\n this.values,\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n return `this.addCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, column: ${jsonToTsSource(this.column)}, values: ${jsonToTsSource(this.values)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropCheckConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropCheckConstraint' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, constraintName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.label = `Drop check constraint \"${constraintName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropCheckConstraint(this.schemaName, this.tableName, this.constraintName, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.dropCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Indexes\n// ============================================================================\n\nexport class CreateIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createIndex' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly columns: readonly string[];\n // Named indexType (not typeName): `locationForCall` in issue-planner.ts reads\n // a call's `typeName` as a CREATE TYPE target location, which an index is not.\n readonly indexType: string | undefined;\n readonly options: Record<string, unknown> | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: { readonly type?: string; readonly options?: Record<string, unknown> },\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.columns = columns;\n this.indexType = extras?.type;\n this.options = extras?.options;\n this.label = `Create index \"${indexName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateIndexCall.toOp: a lowerer is required on the Postgres planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (this.indexType !== undefined) extras.type = this.indexType;\n if (this.options !== undefined) extras.options = this.options;\n return createIndex(\n this.schemaName,\n this.tableName,\n this.indexName,\n this.columns,\n lowerer,\n extras,\n );\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`index: ${jsonToTsSource(this.indexName)}`);\n opts.push(`columns: ${jsonToTsSource(this.columns)}`);\n if (this.indexType !== undefined || this.options !== undefined) {\n const extrasParts: string[] = [];\n if (this.indexType !== undefined) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);\n if (this.options !== undefined) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);\n opts.push(`extras: { ${extrasParts.join(', ')} }`);\n }\n return `this.createIndex({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropIndex' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, indexName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.label = `Drop index \"${indexName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropIndexCall.toOp: a lowerer is required on the Postgres planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropIndex(this.schemaName, this.tableName, this.indexName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`index: ${jsonToTsSource(this.indexName)}`);\n return `this.dropIndex({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Raw SQL\n// ============================================================================\n\n/**\n * Laundered pre-built operation.\n *\n * Wraps an already-materialized `SqlMigrationPlanOperation` — typically one\n * produced by a SQL-family method or a codec control hook — so the planner\n * can carry it alongside IR nodes without reverse-engineering it into a\n * structured call class. Doubles as the user-facing escape hatch for raw\n * migrations: authors can pass a full op shape to `rawSql({...})`.\n *\n * `toOp()` returns the stored op unchanged. `renderTypeScript()` emits\n * `rawSql({...})` with the op serialized as a JSON literal — round-tripping\n * requires every field on the op to be JSON-serializable (no closures).\n */\nexport class RawSqlCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly op: Op;\n\n constructor(op: Op) {\n super();\n this.op = op;\n this.label = op.label;\n this.operationClass = op.operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n return this.op;\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource(this.op)})`;\n }\n}\n\n// ============================================================================\n// Database dependencies (structured DDL)\n// ============================================================================\n\nexport class CreateExtensionCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createExtension' as const;\n readonly operationClass = 'additive' as const;\n readonly extensionName: string;\n readonly label: string;\n\n constructor(extensionName: string) {\n super();\n this.extensionName = extensionName;\n this.label = `Create extension \"${extensionName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createExtension(this.extensionName);\n }\n\n renderTypeScript(): string {\n return `createExtension(${jsonToTsSource(this.extensionName)})`;\n }\n}\n\nexport class CreateSchemaCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createSchema' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly label: string;\n\n constructor(schemaName: string) {\n super();\n this.schemaName = schemaName;\n this.label = `Create schema \"${schemaName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateSchemaCall.toOp: a DDL lowerer is required on the Postgres planner path (schema \"${this.schemaName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.createSchema({ schema: this.schemaName, ifNotExists: true });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n return {\n id: `schema.${schemaName}`,\n label: `Create schema \"${schemaName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n {\n description: `Create schema \"${schemaName}\"`,\n sql: statement.sql,\n params: statement.params ?? [],\n },\n ],\n postcheck: [],\n };\n }\n\n renderTypeScript(): string {\n return `this.createSchema({ schema: ${jsonToTsSource(this.schemaName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Native enum types\n// ============================================================================\n\nexport class CreateNativeEnumTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createNativeEnumType' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly members: readonly string[];\n readonly label: string;\n\n constructor(schemaName: string, typeName: string, members: readonly string[]) {\n super();\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.members = Object.freeze([...members]);\n this.label = `Create enum type \"${typeName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return createNativeEnumType(this.schemaName, this.typeName, this.members, lowerer);\n }\n\n renderTypeScript(): string {\n const opts = [\n `schema: ${jsonToTsSource(this.schemaName)}`,\n `typeName: ${jsonToTsSource(this.typeName)}`,\n `members: ${jsonToTsSource(this.members)}`,\n ];\n return `this.createNativeEnumType({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropNativeEnumTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropNativeEnumType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly label: string;\n\n constructor(schemaName: string, typeName: string) {\n super();\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.label = `Drop enum type \"${typeName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropNativeEnumType(this.schemaName, this.typeName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts = [\n `schema: ${jsonToTsSource(this.schemaName)}`,\n `typeName: ${jsonToTsSource(this.typeName)}`,\n ];\n return `this.dropNativeEnumType({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n/** Schema-qualified, quoted enum type name — unqualified when `schemaName` is the unbound sentinel, matching `boundSchema`'s DDL-node convention. */\nfunction qualifiedNativeEnumTypeName(schemaName: string, typeName: string): string {\n const bound = boundSchema(schemaName);\n return quoteQualifiedName(bound === undefined ? typeName : `${bound}.${typeName}`);\n}\n\nconst ADD_VALUE_TRANSACTION_CAVEAT =\n 'A newly added enum value cannot be used until the transaction that adds it commits, so a ' +\n 'migration that both appends a value and uses it in the same step will fail at apply.';\n\n/**\n * `ALTER TYPE <qualified> ADD VALUE '<value>'` for a suffix-appended member on\n * a managed native enum. Built directly as SQL text (qualified via\n * `quoteQualifiedName`, the value escaped via `escapeLiteral`) rather than a\n * typed DDL node — mirrors how `enableRowLevelSecurity` renders its execute\n * step, since no DDL-AST node exists for this statement. Prechecks/postchecks\n * are still typed catalog queries lowered through the control adapter.\n * `validateEnumValueLength` runs at construction, so an over-length value\n * fails before planning produces a call.\n */\nexport class AddNativeEnumValueCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addNativeEnumValue' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly typeName: string;\n readonly value: string;\n readonly label: string;\n readonly summary: string;\n\n constructor(schemaName: string, typeName: string, value: string) {\n super();\n validateEnumValueLength(value, typeName);\n this.schemaName = schemaName;\n this.typeName = typeName;\n this.value = value;\n this.label = `Add value \"${value}\" to enum type \"${typeName}\"`;\n this.summary = `Adds value \"${value}\" to enum type \"${typeName}\". ${ADD_VALUE_TRANSACTION_CAVEAT}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddNativeEnumValueCall.toOp: a lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const { schemaName, typeName, value } = this;\n const typeChecks = nativeEnumTypeExistsAst(schemaName, typeName);\n const valueChecks = nativeEnumValueExistsAst({ schema: schemaName, typeName, value });\n const typePresent = await lowerer.lowerToExecuteRequest(typeChecks.typePresent());\n const valueAbsent = await lowerer.lowerToExecuteRequest(valueChecks.valueAbsent());\n const valuePresent = await lowerer.lowerToExecuteRequest(valueChecks.valuePresent());\n const qualifiedType = qualifiedNativeEnumTypeName(schemaName, typeName);\n return {\n id: `addNativeEnumValue.${typeName}.${value}`,\n label: this.label,\n summary: this.summary,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(`ensure enum type \"${typeName}\" exists`, typePresent.sql, typePresent.params),\n step(\n `ensure value \"${value}\" is absent from enum type \"${typeName}\"`,\n valueAbsent.sql,\n valueAbsent.params,\n ),\n ],\n execute: [\n step(\n `add value \"${value}\" to enum type \"${typeName}\"`,\n `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`,\n ),\n ],\n postcheck: [\n step(\n `verify value \"${value}\" exists on enum type \"${typeName}\"`,\n valuePresent.sql,\n valuePresent.params,\n ),\n ],\n };\n }\n\n renderTypeScript(): string {\n const opts = [\n `schema: ${jsonToTsSource(this.schemaName)}`,\n `typeName: ${jsonToTsSource(this.typeName)}`,\n `value: ${jsonToTsSource(this.value)}`,\n ];\n return `this.addNativeEnumValue({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Data transform\n// ============================================================================\n\n/**\n * A planner-generated data-transform stub. `checkSlot` and `runSlot` name\n * the unfilled authoring slots that the rendered `migration.ts` will expose\n * to the user via `placeholder(\"…\")` calls. `toOp()` always throws\n * `MIGRATION.UNFILLED_PLACEHOLDER`: the planner cannot lower a stubbed transform to a runtime\n * op — the user must fill the rendered `migration.ts` and re-emit.\n */\nexport class DataTransformCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dataTransform' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly checkSlot: string;\n readonly runSlot: string;\n\n constructor(\n label: string,\n checkSlot: string,\n runSlot: string,\n operationClass: MigrationOperationClass = 'data',\n ) {\n super();\n this.label = label;\n this.checkSlot = checkSlot;\n this.runSlot = runSlot;\n this.operationClass = operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n throw errorUnfilledPlaceholder(this.label);\n }\n\n renderTypeScript(): string {\n return [\n `this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,\n ` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,\n ` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,\n '})',\n ].join('\\n');\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [\n { moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'placeholder' },\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n ];\n }\n}\n\nexport class CreatePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createRlsPolicy' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly policy: PostgresRlsPolicy;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, policy: PostgresRlsPolicy) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.policy = policy;\n this.label = `Create RLS policy \"${policy.name}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreatePostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy \"${this.policy.name}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return createRlsPolicy(this.schemaName, this.tableName, this.policy, lowerer);\n }\n\n renderTypeScript(): string {\n const p = this.policy;\n const input: PostgresRlsPolicyInput = {\n name: p.name,\n prefix: p.prefix,\n tableName: p.tableName,\n namespaceId: p.namespaceId,\n operation: p.operation,\n roles: p.roles,\n ...ifDefined('using', p.using),\n ...ifDefined('withCheck', p.withCheck),\n permissive: p.permissive,\n };\n return `this.createRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${jsonToTsSource(input)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropPostgresRlsPolicyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropRlsPolicy' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly policyName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, policyName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.policyName = policyName;\n this.label = `Drop RLS policy \"${policyName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropPostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy \"${this.policyName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropRlsPolicy(this.schemaName, this.tableName, this.policyName, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.dropRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, policy: ${jsonToTsSource(this.policyName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class EnableRowLevelSecurityCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'enableRowLevelSecurity' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.label = `Enable row-level security on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `EnableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return enableRowLevelSecurity(this.schemaName, this.tableName, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.enableRowLevelSecurity({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DisableRowLevelSecurityCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'disableRowLevelSecurity' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.label = `Disable row-level security on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DisableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return disableRowLevelSecurity(this.schemaName, this.tableName, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.disableRowLevelSecurity({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class RenamePostgresRlsPolicyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'renameRlsPolicy' as const;\n // `widening` is chosen so the rename plans under every allowance set except\n // additive-only init — a rename is neither additive-creation nor\n // destructive, and the class vocabulary has no neutral middle class. It is\n // NOT that a rename widens anything; this is the accepted typology tradeoff.\n readonly operationClass = 'widening' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly oldPolicyName: string;\n readonly newPolicyName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, oldPolicyName: string, newPolicyName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.oldPolicyName = oldPolicyName;\n this.newPolicyName = newPolicyName;\n this.label = `Rename RLS policy \"${oldPolicyName}\" to \"${newPolicyName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `RenamePostgresRlsPolicyCall.toOp: a lowerer is required on the Postgres planner path (policy \"${this.oldPolicyName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return renameRlsPolicy(\n this.schemaName,\n this.tableName,\n this.oldPolicyName,\n this.newPolicyName,\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n return `this.renameRlsPolicy({ schema: ${jsonToTsSource(this.schemaName)}, table: ${jsonToTsSource(this.tableName)}, from: ${jsonToTsSource(this.oldPolicyName)}, to: ${jsonToTsSource(this.newPolicyName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport type PostgresOpFactoryCall =\n | CreateTableCall\n | DropTableCall\n | AddColumnCall\n | DropColumnCall\n | AlterColumnTypeCall\n | SetNotNullCall\n | DropNotNullCall\n | SetDefaultCall\n | DropDefaultCall\n | AddNotNullColumnDirectCall\n | AddNotNullColumnWithTempDefaultCall\n | AddPrimaryKeyCall\n | AddForeignKeyCall\n | AddUniqueCall\n | AddCheckConstraintCall\n | DropCheckConstraintCall\n | CreateIndexCall\n | DropIndexCall\n | DropConstraintCall\n | RawSqlCall\n | CreateExtensionCall\n | CreateSchemaCall\n | CreateNativeEnumTypeCall\n | DropNativeEnumTypeCall\n | AddNativeEnumValueCall\n | CreatePostgresRlsPolicyCall\n | DropPostgresRlsPolicyCall\n | EnableRowLevelSecurityCall\n | DisableRowLevelSecurityCall\n | RenamePostgresRlsPolicyCall\n | DataTransformCall;\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAOA,SAAgB,YAAY,YAAwC;CAClE,OAAO,eAAe,uBAAuB,KAAA,IAAY;AAC3D;;;ACeA,SAAgB,KAAK,aAAqB,KAAa,QAA6B;CAClF,OAAO;EAAE;EAAa;EAAK,GAAG,UAAU,UAAU,MAAM;CAAE;AAC5D;AAEA,SAAgB,cACd,YACA,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e,KAAK,UAAU,EAAE,WAAW,eAAe,KAAK,SAAS,EAAE,UAAU,eAAe,KAAK,aAAa,EAAE,QAAQ,eAAe,KAAK,aAAa,EAAE;CAC7M;CAEA,qBAA4D;EAC1D,OAAO,CAAC;CACV;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-DPGxFcXo.mjs","names":["#lowerer"],"sources":["../src/core/migrations/verify-postgres-namespaces.ts","../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SchemaDiffIssue } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIRNode } from '@prisma-next/sql-schema-ir/types';\nimport { DEFAULT_NAMESPACE_ID } from '../namespace-ids';\nimport { isPostgresSchema } from '../postgres-schema';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresNamespaceSchemaNode } from '../schema-ir/postgres-namespace-schema-node';\nimport type { SqlSchemaDiffNode } from '../schema-ir/schema-node-kinds';\n\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: SqlStorage, namespaceId: string): string {\n const namespace = storage.namespaces[namespaceId];\n if (isPostgresSchema(namespace)) {\n return namespace.ddlSchemaName(storage);\n }\n return namespaceId;\n}\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: SqlSchemaIRNode): readonly string[] {\n if (PostgresDatabaseSchemaNode.is(schema)) {\n return schema.existingSchemas;\n }\n return [DEFAULT_NAMESPACE_ID];\n}\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 */\nexport function verifyPostgresNamespacePresence(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIRNode;\n}): readonly SchemaDiffIssue<SqlSchemaDiffNode>[] {\n const { contract, schema } = input;\n const existing = new Set(existingSchemasFromSchema(schema));\n const issues: SchemaDiffIssue<SqlSchemaDiffNode>[] = [];\n const namespaceIds = Object.keys(contract.storage.namespaces).sort();\n for (const namespaceId of namespaceIds) {\n if (namespaceId === UNBOUND_NAMESPACE_ID) continue;\n const ddlName = resolveDdlSchemaName(contract.storage, namespaceId);\n if (ddlName === UNBOUND_NAMESPACE_ID) continue;\n if (existing.has(ddlName)) continue;\n const namespace = new PostgresNamespaceSchemaNode({\n schemaName: ddlName,\n tables: {},\n });\n issues.push({\n path: ['database', ddlName],\n expected: namespace,\n });\n }\n return issues;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerConflict,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n partitionCallsByControlPolicy,\n partitionIssuesByControlPolicy,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaDiffIssue,\n SchemaOwnership,\n} from '@prisma-next/framework-components/control';\nimport { issueOutcome } from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { PostgresRlsPolicy } from '../postgres-rls-policy';\nimport { parseRlsPolicyWireName } from '../rls/wire-name';\nimport { postgresNodeStorageCoordinate } from '../schema-ir/node-storage-coordinate';\nimport { PostgresDatabaseSchemaNode } from '../schema-ir/postgres-database-schema-node';\nimport { PostgresPolicySchemaNode } from '../schema-ir/postgres-policy-schema-node';\nimport type { SqlSchemaDiffNode } from '../schema-ir/schema-node-kinds';\nimport {\n renderPostgresSuppression,\n resolveNamespaceIdForDdlSchema,\n resolvePostgresCallControlPolicySubject,\n resolvePostgresNodeIssueControlPolicySubject,\n resolvePostgresNodeIssueCreationFactoryName,\n} from './control-policy';\nimport { buildPostgresPlanDiff } from './diff-database-schema';\nimport { coalesceSubtreeIssues, issueNode, issueSchemaName, planIssues } from './issue-planner';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport {\n CreatePostgresRlsPolicyCall,\n DropPostgresRlsPolicyCall,\n RenamePostgresRlsPolicyCall,\n} from './op-factory-call';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\nimport { resolveDdlSchemaForNamespaceStorage } from './resolve-ddl-schema';\nimport { verifyPostgresNamespacePresence } from './verify-postgres-namespaces';\n\ntype PlannerFrameworkComponents = SqlMigrationPlannerPlanOptions extends {\n readonly frameworkComponents: infer T;\n}\n ? T\n : ReadonlyArray<unknown>;\n\ntype PlannerOptionsWithComponents = SqlMigrationPlannerPlanOptions & {\n readonly frameworkComponents: PlannerFrameworkComponents;\n};\n\nexport function createPostgresMigrationPlanner(\n lowerer: ExecuteRequestLowerer,\n): PostgresMigrationPlanner {\n return new PostgresMigrationPlanner(lowerer);\n}\n\n/**\n * Result of `PostgresMigrationPlanner.plan()`. A discriminated union whose\n * success variant carries a `TypeScriptRenderablePostgresMigration` — a\n * migration object that both the CLI (via `renderTypeScript()`) and the\n * SQL-typed callers (via `operations`, `describe()`, etc.) consume\n * uniformly.\n */\nexport type PostgresPlanResult =\n | {\n readonly kind: 'success';\n readonly plan: TypeScriptRenderablePostgresMigration;\n readonly warnings?: readonly SqlPlannerConflict[];\n }\n | SqlPlannerFailureResult;\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 */\nexport class PostgresMigrationPlanner implements MigrationPlanner<'sql', 'postgres'> {\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n\n constructor(lowerer?: ExecuteRequestLowerer) {\n this.#lowerer = lowerer;\n }\n\n plan(options: {\n readonly contract: unknown;\n readonly schema: unknown;\n readonly policy: MigrationOperationPolicy;\n /**\n * The \"from\" contract (state the planner assumes the database starts\n * at), or `null` for reconciliation flows. Only `migration plan` ever\n * supplies a non-null value; `db update` / `db init` reconcile against\n * the live schema and pass `null`. When present alongside the\n * `'data'` operation class, strategies that need from/to column-shape\n * comparisons (unsafe type change, nullability tightening) activate.\n *\n * Typed as the framework `Contract | null` to satisfy the\n * `MigrationPlanner` interface contract; `planSql` narrows to the SQL\n * shape via `SqlMigrationPlannerPlanOptions`. Used to populate\n * `describe().from` on the produced plan as\n * `fromContract?.storage.storageHash ?? null`.\n */\n readonly fromContract: Contract | null;\n readonly schemaName?: string;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n /**\n * Contract space this plan applies to. Stamped onto the produced\n * {@link TypeScriptRenderablePostgresMigration.spaceId} so the runner keys\n * the marker row by the right space.\n */\n readonly spaceId: string;\n /**\n * Ownership oracle over the contract-space composition — see\n * {@link SqlMigrationPlannerPlanOptions.ownership}.\n */\n readonly ownership?: SchemaOwnership;\n }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n this.#lowerer,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName =\n options.schemaName ??\n Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ??\n UNBOUND_NAMESPACE_ID;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n // The one combined tree diff drives the whole plan: relational findings\n // become structural DDL via `planIssues`, policy findings become RLS ops\n // via `planPostgresSchemaDiff`. Verify runs its own full-tree node diff\n // (`diffSchema`) over the same schema and rejects on a\n // surviving failure.\n PostgresDatabaseSchemaNode.assert(options.schema);\n const { issues: rawIssues } = buildPostgresPlanDiff({\n contract: options.contract,\n actualSchema: options.schema,\n frameworkComponents: options.frameworkComponents,\n });\n const policyDiffIssues = rawIssues.filter((issue) => isPolicyDiffIssue(issue));\n // Role diff issues resolve to the `external` control policy (see\n // `resolvePostgresNodeIssueControlPolicySubject`'s role branch), so the\n // control-policy partition below suppresses them to zero ops on its own,\n // before `mapNodeIssueToCall` ever sees them — no separate exclusion\n // needed here.\n const relationalDiffIssues = rawIssues.filter((issue) => !isPolicyDiffIssue(issue));\n\n // The generic differ is total and un-gated: strict-mode extras filtering\n // (dropping `not-expected` findings outside strict mode, mirroring the\n // retired coordinate walk's `if (strict) { ...extra_* } }` guards),\n // subtree coalescing (a missing/extra table also emits an issue for\n // every child under it — redundant once the table-level Create/Drop call\n // already accounts for the whole subtree), and ownership are all post-diff\n // planner steps.\n //\n // Ownership: a live extra is only this plan's to drop when no contract\n // space owns it. The differ ran against THIS space's contract, so a table\n // a sibling space owns surfaces here as `not-expected`; the planner asks\n // the ownership oracle (the passive aggregate) whether any space declares\n // it and, if so, leaves it alone — it is a sibling's table, not an orphan.\n // A table no space owns stays a genuine extra to drop under a destructive\n // policy. Ownership lives in the aggregate; the planner only asks. Absent\n // oracle (single-space, none handed) keeps every extra. Coalescing MUST\n // run before this so a sibling-owned table's child issues have already\n // collapsed into the one table-level issue that carries the table name.\n const strict =\n options.policy.allowedOperationClasses.includes('widening') ||\n options.policy.allowedOperationClasses.includes('destructive');\n const coalesced = coalesceSubtreeIssues(relationalDiffIssues);\n const owned = retainUnownedExtras(coalesced, options.ownership, options.contract);\n const gated = strict ? owned : owned.filter((issue) => issueOutcome(issue) !== 'not-expected');\n\n // Namespace presence (`CREATE SCHEMA`) is a planner-only op-generation\n // concern stitched in here rather than inside the shared diff — verify\n // never needs it (a missing schema already surfaces as a `not-found`\n // table in the relational findings). These synthesized issues are added\n // AFTER coalescing/scoping (never coalesced against the table diff —\n // their path is an ancestor of every table path under that schema, so\n // running them through the same coalesce would swallow the table-level\n // `not-found` issues that drive `CREATE TABLE`) and are NOT subject to\n // sibling-space scoping, matching the retired coordinate walk exactly.\n const namespaceIssues = verifyPostgresNamespacePresence({\n contract: options.contract,\n schema: options.schema,\n });\n const schemaIssues = [...namespaceIssues, ...gated];\n\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\n // The strategy layer reads the live schema by bare table name for existence\n // checks (shared-temp-default safety, FK/unique probes), so it takes one\n // per-schema namespace node — never the whole tree root, and never a flat\n // merge of every namespace (which would collide same-named tables across\n // schemas). Probing more than one namespace at once is future work.\n const relationalSchema = relationalNamespaceNode(options.schema, schemaName);\n\n // Input-side control-policy partition. `external` / `observed` subjects\n // — and non-creation issues for `tolerated` subjects — are dropped from\n // the planner's input entirely; the planner never observes them, never\n // diffs them, never generates DDL for them. Suppression warnings are\n // built directly from the suppressed partition (one per subject), so the\n // user-visible message survives even when the planner would have failed\n // to model the subject's live shape.\n const issuePartition = partitionIssuesByControlPolicy({\n issues: schemaIssues,\n contract: options.contract,\n resolveControlPolicySubject: (issue) =>\n resolvePostgresNodeIssueControlPolicySubject(issue, options.contract),\n resolveCreationFactoryName: resolvePostgresNodeIssueCreationFactoryName,\n });\n\n const result = planIssues({\n issues: issuePartition.plannable,\n toContract: options.contract,\n // `fromContract` is only supplied by `migration plan`. It is `null` for\n // `db update` / `db init`, which means data-safety strategies needing\n // from/to comparisons (unsafe type change, nullable tightening) are\n // inapplicable there — reconciliation falls through to\n // `mapNodeIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract,\n schemaName,\n codecHooks,\n storageTypes,\n ...ifDefined('schema', relationalSchema),\n policy: options.policy,\n frameworkComponents: options.frameworkComponents,\n strategies: postgresPlannerStrategies,\n });\n\n if (!result.ok) {\n return plannerFailure(result.failure);\n }\n\n const schemaDiffCalls = this.planPostgresSchemaDiff(options, policyDiffIssues);\n const schemaDiffPartition = partitionCallsByControlPolicy({\n calls: schemaDiffCalls,\n contract: options.contract,\n resolveControlPolicySubject: (call) =>\n resolvePostgresCallControlPolicySubject(call, options.contract),\n resolveFactoryName: (call) => call.factoryName,\n });\n\n // Inline `onFieldEvent`-emitted ops after structural DDL. The fixed\n // ordering is `structural → added → dropped → altered`, with\n // within-group sorting by `(tableName, fieldName)` so re-emits are\n // byte-stable. The hook fires only at the application emitter —\n // extension-space planning never reaches this helper.\n const fieldEventOps = planFieldEventOperations({\n priorContract: options.fromContract,\n newContract: options.contract,\n codecHooks,\n });\n // Codec hook ops are target-agnostic `OpFactoryCall`; Postgres planning\n // lifts them at this integration boundary (see field-event-planner JSDoc).\n const fieldEventPostgresCalls = blindCast<\n readonly PostgresOpFactoryCall[],\n 'Codec hook ops conform to PostgresOpFactoryCall at the app emitter boundary'\n >(fieldEventOps);\n const fieldEventPartition = partitionCallsByControlPolicy({\n calls: fieldEventPostgresCalls,\n contract: options.contract,\n resolveControlPolicySubject: (call) =>\n resolvePostgresCallControlPolicySubject(call, options.contract),\n resolveFactoryName: (call) => call.factoryName,\n });\n const calls = [...result.value.calls, ...schemaDiffPartition.kept, ...fieldEventPartition.kept];\n const warnings: SqlPlannerConflict[] = [\n ...issuePartition.suppressions,\n ...schemaDiffPartition.suppressions,\n ...fieldEventPartition.suppressions,\n ].map((record) => renderPostgresSuppression(record, options.contract));\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n this.#lowerer,\n ),\n ...(warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}),\n });\n }\n\n /**\n * Maps the RLS policy presence findings of the one combined tree diff\n * (`buildPostgresPlanDiff`, already ownership-filtered) into\n * `CREATE POLICY` / `DROP POLICY` / `ALTER POLICY … RENAME TO` ops. It\n * does not re-diff — it consumes exactly the policy-node subset of the\n * shared diff's issues. Enablement is NOT decided here: `ENABLE`/`DISABLE\n * ROW LEVEL SECURITY` derive from the table's marker-driven `rlsEnabled`\n * attribute diff on the relational side.\n *\n * Rename post-pass: a `not-found` and a `not-expected` policy on the SAME\n * table whose wire-name content hashes match but prefixes differ are one\n * prefix-only rename, collapsed into a single non-destructive\n * `RenamePostgresRlsPolicyCall`. Multi-candidate hash groups pair\n * deterministically by sorted wire name; leftovers proceed as\n * create/drop. Unparseable wire names never pair.\n *\n * The pairing runs only when the policy allows `widening` (rename's\n * class). Without it (db-init's additive-only set), pairing degrades\n * deliberately to the additive half: the new name is CREATEd and the old\n * policy survives live until a widening/destructive-allowed plan runs —\n * emitting an ungated widening rename would only fail at the runner's\n * class re-enforcement.\n */\n private planPostgresSchemaDiff(\n options: PlannerOptionsWithComponents,\n filteredDiffIssues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[],\n ): readonly PostgresOpFactoryCall[] {\n const allowsDestructive = options.policy.allowedOperationClasses.includes('destructive');\n const allowsWidening = options.policy.allowedOperationClasses.includes('widening');\n\n interface PolicyFinding {\n readonly node: PostgresPolicySchemaNode;\n readonly schemaForTable: string;\n }\n const missing: PolicyFinding[] = [];\n const extra: PolicyFinding[] = [];\n\n for (const issue of filteredDiffIssues) {\n // 'not-equal' is unreachable for content-addressed policies: the wire name\n // encodes the body hash, so two policies sharing a local key (same name)\n // are always equal and isEqualTo never returns false.\n if (issueOutcome(issue) === 'not-found') {\n const expected = issue.expected;\n PostgresPolicySchemaNode.assert(expected);\n // expected.namespaceId is the DDL schema name (resolved during projection);\n // this re-resolution is a no-op as long as PostgresSchema.ddlSchemaName() returns this.id.\n missing.push({\n node: expected,\n schemaForTable: resolveDdlSchemaForNamespaceStorage(\n options.contract.storage,\n expected.namespaceId,\n ),\n });\n } else if (issueOutcome(issue) === 'not-expected') {\n const actual = issue.actual;\n PostgresPolicySchemaNode.assert(actual);\n extra.push({\n node: actual,\n schemaForTable: resolveDdlSchemaForNamespaceStorage(\n options.contract.storage,\n actual.namespaceId,\n ),\n });\n }\n }\n\n const calls: PostgresOpFactoryCall[] = [];\n const renamedExtras = new Set<PolicyFinding>();\n const renamedMissing = new Set<PolicyFinding>();\n const pairingKey = (finding: PolicyFinding, hash: string): string =>\n JSON.stringify([finding.schemaForTable, finding.node.tableName, hash]);\n\n if (allowsWidening) {\n const extrasByGroup = new Map<string, PolicyFinding[]>();\n for (const finding of extra) {\n const parsed = parseRlsPolicyWireName(finding.node.name);\n if (parsed === undefined) continue;\n const key = pairingKey(finding, parsed.hash);\n const group = extrasByGroup.get(key) ?? [];\n group.push(finding);\n extrasByGroup.set(key, group);\n }\n for (const group of extrasByGroup.values()) {\n group.sort((a, b) => (a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0));\n }\n\n const sortedMissing = [...missing].sort((a, b) =>\n a.node.name < b.node.name ? -1 : a.node.name > b.node.name ? 1 : 0,\n );\n for (const missingFinding of sortedMissing) {\n const parsed = parseRlsPolicyWireName(missingFinding.node.name);\n if (parsed === undefined) continue;\n const candidates = extrasByGroup.get(pairingKey(missingFinding, parsed.hash));\n const candidate = candidates?.shift();\n if (candidate === undefined) continue;\n // Same name would never surface as missing+extra (the differ pairs by\n // name), so a matched candidate always differs in prefix only.\n renamedExtras.add(candidate);\n renamedMissing.add(missingFinding);\n calls.push(\n new RenamePostgresRlsPolicyCall(\n missingFinding.schemaForTable,\n missingFinding.node.tableName,\n candidate.node.name,\n missingFinding.node.name,\n ),\n );\n }\n }\n\n for (const finding of missing) {\n if (renamedMissing.has(finding)) continue;\n calls.push(\n new CreatePostgresRlsPolicyCall(\n finding.schemaForTable,\n finding.node.tableName,\n policyNodeToContractPolicy(finding.node),\n ),\n );\n }\n if (allowsDestructive) {\n for (const finding of extra) {\n if (renamedExtras.has(finding)) continue;\n calls.push(\n new DropPostgresRlsPolicyCall(\n finding.schemaForTable,\n finding.node.tableName,\n finding.node.name,\n ),\n );\n }\n }\n\n return calls;\n }\n\n private ensureAdditivePolicy(policy: MigrationOperationPolicy) {\n if (!policy.allowedOperationClasses.includes('additive')) {\n return plannerFailure([\n {\n kind: 'unsupportedOperation',\n summary: 'Migration planner requires additive operations be allowed',\n why: 'The planner requires the \"additive\" operation class to be allowed in the policy.',\n },\n ]);\n }\n return null;\n }\n}\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: SchemaDiffIssue<SqlSchemaDiffNode>): boolean {\n const node = issue.expected ?? issue.actual;\n return node !== undefined && PostgresPolicySchemaNode.is(node);\n}\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(\n issues: readonly SchemaDiffIssue<SqlSchemaDiffNode>[],\n ownership: SchemaOwnership | undefined,\n contract: Contract<SqlStorage>,\n): readonly SchemaDiffIssue<SqlSchemaDiffNode>[] {\n if (ownership === undefined) return issues;\n return issues.filter((issue) => {\n if (issueOutcome(issue) !== 'not-expected') return true;\n const node = issueNode(issue);\n if (node === undefined) return true;\n const coordinate = postgresNodeStorageCoordinate(node);\n if (coordinate === undefined) return true;\n const ddlSchemaName = issueSchemaName(issue);\n if (ddlSchemaName === undefined) return true;\n const namespaceId = resolveNamespaceIdForDdlSchema(contract, ddlSchemaName);\n return !ownership.declaresEntity({ namespaceId, ...coordinate });\n });\n}\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(\n schema: PostgresDatabaseSchemaNode,\n schemaName: string,\n): SqlSchemaIR | undefined {\n const namespaceNodes = Object.values(schema.namespaces);\n const namespaceNode =\n namespaceNodes.find((node) => node.schemaName === schemaName) ?? namespaceNodes[0];\n if (namespaceNode === undefined) return undefined;\n return blindCast<\n SqlSchemaIR,\n 'PostgresNamespaceSchemaNode carries tables (+ nativeEnums, read by codec hooks via PostgresNamespaceSchemaNode.is) structurally compatible with the SqlSchemaIR shape the strategy layer declares'\n >(namespaceNode);\n}\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: PostgresPolicySchemaNode): PostgresRlsPolicy {\n return new PostgresRlsPolicy({\n name: node.name,\n prefix: node.prefix,\n tableName: node.tableName,\n namespaceId: node.namespaceId,\n operation: node.operation,\n roles: [...node.roles],\n ...ifDefined('using', node.using),\n ...ifDefined('withCheck', node.withCheck),\n permissive: node.permissive,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoBA,SAAS,qBAAqB,SAAqB,aAA6B;CAC9E,MAAM,YAAY,QAAQ,WAAW;CACrC,IAAI,iBAAiB,SAAS,GAC5B,OAAO,UAAU,cAAc,OAAO;CAExC,OAAO;AACT;;;;;;;;;;;;;;;;;AAkBA,SAAS,0BAA0B,QAA4C;CAC7E,IAAI,2BAA2B,GAAG,MAAM,GACtC,OAAO,OAAO;CAEhB,OAAO,CAAC,oBAAoB;AAC9B;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,gCAAgC,OAGE;CAChD,MAAM,EAAE,UAAU,WAAW;CAC7B,MAAM,WAAW,IAAI,IAAI,0BAA0B,MAAM,CAAC;CAC1D,MAAM,SAA+C,CAAC;CACtD,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,CAAC,CAAC,KAAK;CACnE,KAAK,MAAM,eAAe,cAAc;EACtC,IAAI,gBAAgB,sBAAsB;EAC1C,MAAM,UAAU,qBAAqB,SAAS,SAAS,WAAW;EAClE,IAAI,YAAY,sBAAsB;EACtC,IAAI,SAAS,IAAI,OAAO,G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,KAAK,KAAK;EACrB,GAAG,UAAU,SAAS,KAAK,KAAK;EAChC,GAAG,UAAU,aAAa,KAAK,SAAS;EACxC,YAAY,KAAK;CACnB,CAAC;AACH"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-ddl-builders-BKlmGDJl.mjs","names":[],"sources":["../src/core/migrations/planner-ddl-builders.ts"],"sourcesContent":["import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type { StorageColumn, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { escapeLiteral, quoteIdentifier, quoteQualifiedName } from '../sql-utils';\nimport type { PostgresColumnDefault } from '../types';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\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_ ]*(\\[\\])?$/;\n\nfunction assertSafeNativeType(nativeType: string): void {\n if (!SAFE_NATIVE_TYPE_PATTERN.test(nativeType)) {\n throw new Error(\n `Unsafe native type name in contract: \"${nativeType}\". ` +\n 'Native type names must match /^[a-zA-Z][a-zA-Z0-9_ ]*(\\\\[\\\\])?$/',\n );\n }\n}\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: string): void {\n if (expression.includes(';') || /--|\\/\\*|\\$\\$|\\bSELECT\\b/i.test(expression)) {\n throw new Error(\n `Unsafe default expression in contract: \"${expression}\". ` +\n 'Default expressions must not contain semicolons, SQL comment tokens, dollar-quoting, or subqueries.',\n );\n }\n}\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 */\nexport function buildColumnTypeSql(\n column: StorageColumn,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance> = {},\n allowPseudoTypes = true,\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (allowPseudoTypes) {\n const columnDefault = column.default;\n if (columnDefault?.kind === 'function' && columnDefault.expression === 'autoincrement()') {\n if (resolved.nativeType === 'int4' || resolved.nativeType === 'integer') {\n return 'SERIAL';\n }\n if (resolved.nativeType === 'int8' || resolved.nativeType === 'bigint') {\n return 'BIGSERIAL';\n }\n if (resolved.nativeType === 'int2' || resolved.nativeType === 'smallint') {\n return 'SMALLSERIAL';\n }\n }\n }\n\n // A column whose codec supplied a `typeParams.typeName` references a named\n // database type (e.g. a native enum), not a parameterized builtin: render it\n // as its quoted, schema-qualified type-name identifier. DDL-render only — the\n // verify comparison value (`resolvedNativeType`) stays the bare name the\n // family expander produces, matching introspection.\n if (typeof resolved.typeParams?.['typeName'] === 'string') {\n const quoted = quoteQualifiedName(resolved.nativeType);\n return column.many ? `${quoted}[]` : quoted;\n }\n\n const expanded = expandParameterizedTypeSql(resolved, codecHooks);\n if (expanded !== null) {\n return column.many ? `${expanded}[]` : expanded;\n }\n\n if (column.typeRef) {\n const base = quoteQualifiedName(resolved.nativeType);\n return column.many ? `${base}[]` : base;\n }\n\n assertSafeNativeType(resolved.nativeType);\n return column.many ? `${resolved.nativeType}[]` : resolved.nativeType;\n}\n\nfunction expandParameterizedTypeSql(\n column: Pick<StorageColumn, 'nativeType' | 'codecId' | 'typeParams'>,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n): string | null {\n if (!column.typeParams || Object.keys(column.typeParams).length === 0) {\n return null;\n }\n\n if (!column.codecId) {\n throw new Error(\n `Column declares typeParams for nativeType \"${column.nativeType}\" but has no codecId. ` +\n 'Ensure the column is associated with a codec.',\n );\n }\n\n const hooks = codecHooks.get(column.codecId);\n if (!hooks?.expandNativeType) {\n if (hooks?.planTypeOperations) {\n return null;\n }\n throw new Error(\n `Column declares typeParams for nativeType \"${column.nativeType}\" ` +\n `but no expandNativeType hook is registered for codecId \"${column.codecId}\". ` +\n 'Ensure the extension providing this codec is included in extensionPacks.',\n );\n }\n\n const expanded = hooks.expandNativeType({\n nativeType: column.nativeType,\n codecId: column.codecId,\n ...ifDefined('typeParams', column.typeParams),\n });\n\n return expanded !== column.nativeType ? expanded : null;\n}\n\n/** Autoincrement columns use SERIAL types, so this returns empty for them. */\nexport function buildColumnDefaultSql(\n columnDefault: PostgresColumnDefault | undefined,\n column?: Pick<StorageColumn, 'many' | 'nativeType'>,\n): string {\n if (!columnDefault) {\n return '';\n }\n\n switch (columnDefault.kind) {\n case 'literal':\n return `DEFAULT ${renderDefaultLiteral(columnDefault.value, column)}`;\n case 'function': {\n if (columnDefault.expression === 'autoincrement()') {\n return '';\n }\n assertSafeDefaultExpression(columnDefault.expression);\n return `DEFAULT (${columnDefault.expression})`;\n }\n case 'sequence':\n return `DEFAULT nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`;\n }\n}\n\nexport function renderDefaultLiteral(\n value: unknown,\n column?: Pick<StorageColumn, 'many' | 'nativeType'>,\n): string {\n const isJsonColumn = column?.nativeType === 'json' || column?.nativeType === 'jsonb';\n\n if (column?.many && Array.isArray(value)) {\n return renderArrayLiteralDefault(value);\n }\n\n if (value instanceof Date) {\n return `'${escapeLiteral(value.toISOString())}'`;\n }\n if (typeof value === 'string') {\n return `'${escapeLiteral(value)}'`;\n }\n if (typeof value === 'number' || typeof value === 'boolean') {\n return String(value);\n }\n if (value === null) {\n return 'NULL';\n }\n const json = JSON.stringify(value);\n if (isJsonColumn) {\n return `'${escapeLiteral(json)}'::${column.nativeType}`;\n }\n return `'${escapeLiteral(json)}'`;\n}\n\nfunction renderArrayLiteralDefault(elements: unknown[]): string {\n if (elements.length === 0) {\n return \"'{}'\";\n }\n const rendered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,IAAI,cAAc,IAAI,EAAE,KAAK,OAAO;CAE7C,OAAO,IAAI,cAAc,IAAI,EAAE;AACjC;AAEA,SAAS,0BAA0B,UAA6B;CAC9D,IAAI,SAAS,WAAW,GACtB,OAAO;CAGT,OAAO,SADU,SAAS,KAAK,OAAO,qBAAqB,EAAE,CAAC,CAAC,CAAC,KAAK,IAC9C,EAAE;AAC3B"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-produced-postgres-migration-C-dwGdb2.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"mappings":";;;;;;;cAqCa,8CACH,6BACG;;cAcT,gBAAgB,iBAChB,MAAM,eACN,iBACA,UAAU;MASC,wBACT,0BAA0B,6BAC1B,QAAQ,0BAA0B;EAM7B,YAAY;;;;;;MASjB;EAIJ"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-produced-postgres-migration-CFDpqWWE.mjs","names":["#calls","#meta","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `MIGRATION.UNFILLED_PLACEHOLDER` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache:\n | readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[]\n | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, { from: this.#meta.from, to: this.#meta.to });\n }\n}\n"],"mappings":";;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CACA;CACA;CAOA,YACE,OACA,MACA,SACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,WAAW;CAClB;CAEA,IAAa,aAGT;EACF,KAAKC,qBAAqB,UAAU,KAAKJ,QAAQ,KAAKG,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKH;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAAE,MAAM,KAAKC,MAAM;GAAM,IAAI,KAAKA,MAAM;EAAG,CAAC;CAC1F;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-schema-lookup-CiVaAQP-.mjs","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"sourcesContent":["import { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { ForeignKey } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Pre-computed lookup sets for a schema table's constraints.\n * Converts O(n*m) linear scans to O(1) Set lookups per constraint check.\n */\nexport interface SchemaTableLookup {\n readonly uniqueKeys: Set<string>;\n readonly indexKeys: Set<string>;\n readonly uniqueIndexKeys: Set<string>;\n readonly fkKeys: Set<string>;\n}\n\nexport function buildSchemaLookupMap(schema: SqlSchemaIR): ReadonlyMap<string, SchemaTableLookup> {\n const map = new Map<string, SchemaTableLookup>();\n for (const [tableName, table] of Object.entries(schema.tables)) {\n map.set(tableName, buildSchemaTableLookup(table));\n }\n return map;\n}\n\nfunction buildSchemaTableLookup(table: SqlSchemaIR['tables'][string]): SchemaTableLookup {\n const uniqueKeys = new Set(table.uniques.map((u) => u.columns.join(',')));\n const indexKeys = new Set(table.indexes.map((i) => i.columns.join(',')));\n const uniqueIndexKeys = new Set(\n table.indexes.filter((i) => i.unique).map((i) => i.columns.join(',')),\n );\n const fkKeys = new Set<string>();\n for (const fk of table.foreignKeys) {\n // Keys are JSON-encoded tuples so identifiers containing any character\n // (including the column-list comma or pipe characters) cannot collide\n // across structurally-distinct FKs. Unqualified keys are 3-tuples\n // (cols, table, refCols); qualified keys are 4-tuples\n // (cols, schema, table, refCols) — the arity difference makes the two\n // key shapes fundamentally non-collidable.\n fkKeys.add(JSON.stringify([fk.columns, fk.referencedTable, fk.referencedColumns]));\n if (fk.referencedSchema !== undefined) {\n fkKeys.add(\n JSON.stringify([fk.columns, fk.referencedSchema, fk.referencedTable, fk.referencedColumns]),\n );\n }\n }\n return { uniqueKeys, indexKeys, uniqueIndexKeys, fkKeys };\n}\n\nexport function hasUniqueConstraint(\n lookup: SchemaTableLookup,\n columns: readonly string[],\n): boolean {\n const key = columns.join(',');\n return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);\n}\n\nexport function hasIndex(lookup: SchemaTableLookup, columns: readonly string[]): boolean {\n const key = columns.join(',');\n return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);\n}\n\nexport function hasForeignKey(lookup: SchemaTableLookup, fk: ForeignKey): boolean {\n // Mirror the encoding produced by buildSchemaTableLookup exactly:\n // unqualified 3-tuple for unbound-namespace FKs, qualified 4-tuple for\n // bound-namespace FKs.\n if (fk.target.namespaceId === UNBOUND_NAMESPACE_ID) {\n return lookup.fkKeys.has(\n JSON.stringify([fk.source.columns, fk.target.tableName, fk.target.columns]),\n );\n }\n return lookup.fkKeys.has(\n JSON.stringify([\n fk.source.columns,\n fk.target.namespaceId,\n fk.target.tableName,\n fk.target.columns,\n ]),\n );\n}\n"],"mappings":";;AAeA,SAAgB,qBAAqB,QAA6D;CAChG,MAAM,sBAAM,IAAI,IAA+B;CAC/C,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,OAAO,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CAEF,OAAO,OAAO,OAAO,IACnB,KAAK,UAAU;EACb,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;EACV,GAAG,OAAO;CACZ,CAAC,CACH;AACF"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"postgres-migration-C_OPFhIF.mjs","names":["SqlMigration","#endView","#startView"],"sources":["../src/core/migrations/postgres-migration.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { SqlControlAdapter } from '@prisma-next/family-sql/control-adapter';\nimport { Migration as SqlMigration } from '@prisma-next/family-sql/migration';\nimport type { ControlStack } from '@prisma-next/framework-components/control';\nimport { MigrationContractViews } from '@prisma-next/migration-tools/migration';\nimport type { SqlStorage } from '@prisma-next/sql-contract/types';\nimport type { DdlColumn, DdlTableConstraint } from '@prisma-next/sql-relational-core/ast';\nimport { errorPostgresMigrationStackMissing } from '../errors';\nimport { PostgresContractView } from '../postgres-contract-view';\nimport { PostgresRlsPolicy, type PostgresRlsPolicyInput } from '../postgres-rls-policy';\nimport {\n AddCheckConstraintCall,\n AddColumnCall,\n AddForeignKeyCall,\n AddNativeEnumValueCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n type AlterColumnTypeOptions,\n CreateIndexCall,\n CreateNativeEnumTypeCall,\n CreatePostgresRlsPolicyCall,\n CreateSchemaCall,\n CreateTableCall,\n DisableRowLevelSecurityCall,\n DropCheckConstraintCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNativeEnumTypeCall,\n DropNotNullCall,\n DropPostgresRlsPolicyCall,\n DropTableCall,\n EnableRowLevelSecurityCall,\n RenamePostgresRlsPolicyCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport { type DataTransformOptions, dataTransform } from './operations/data-transform';\nimport { installExtension } from './operations/dependencies';\nimport type { CreateIndexExtras } from './operations/indexes';\nimport type { ForeignKeySpec } from './operations/shared';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\n\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 `@prisma-next/family-mongo`: the renderer\n * emits `extends Migration` against a facade re-export of this class\n * from `@prisma-next/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 */\nexport abstract class PostgresMigration<\n Start extends Contract<SqlStorage> = Contract<SqlStorage>,\n End extends Contract<SqlStorage> = Contract<SqlStorage>,\n> extends SqlMigration<PostgresPlanTargetDetails, 'postgres', Start, End> {\n readonly targetId = 'postgres' as const;\n\n /**\n * Materialized Postgres control adapter, created once per migration\n * instance from the injected stack. `undefined` only when the migration\n * was instantiated without a stack (test fixtures); `controlAdapterFor`\n * throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING in that case to surface the misuse.\n */\n protected readonly controlAdapter: SqlControlAdapter<'postgres'> | undefined;\n\n #endView = new MigrationContractViews<PostgresContractView<End>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<End>(json),\n );\n #startView = new MigrationContractViews<PostgresContractView<Start>>(\n this,\n 'PostgresMigration',\n (json) => PostgresContractView.fromJson<Start>(json),\n );\n\n constructor(stack?: ControlStack<'sql', 'postgres'>) {\n super(stack);\n // The descriptor `create()` is typed as the wider `ControlAdapterInstance`;\n // the Postgres descriptor concretely returns a `SqlControlAdapter<'postgres'>`,\n // so the cast holds for any Postgres-target stack assembled at runtime.\n this.controlAdapter = stack?.adapter\n ? (stack.adapter.create(stack) as SqlControlAdapter<'postgres'>)\n : undefined;\n }\n\n /**\n * Returns the materialized control adapter, or throws a MIGRATION.POSTGRES_CONTROL_STACK_MISSING naming\n * `operation` when the migration was constructed without a `ControlStack`.\n * Single home for the null-check that every DDL/DML method shares.\n */\n private controlAdapterFor(operation: string): SqlControlAdapter<'postgres'> {\n if (!this.controlAdapter) {\n throw errorPostgresMigrationStackMissing(operation);\n }\n return this.controlAdapter;\n }\n\n /**\n * The typed, schema-qualified Postgres view over this migration's end-state\n * contract — `this.endContract.namespace.<schema>.table.<name>`, etc. Throws\n * if no `endContractJson` was provided.\n */\n get endContract(): PostgresContractView<End> {\n return this.#endView.endContract;\n }\n\n /**\n * The typed Postgres view over this migration's start-state contract, or\n * `null` for a baseline migration (no `startContractJson`).\n */\n get startContract(): PostgresContractView<Start> | null {\n return this.#startView.startContract;\n }\n\n /**\n * Instance-method wrapper around the free `dataTransform` factory that\n * supplies the stored control adapter. Authors call this from inside\n * `get operations()`; the adapter argument is hidden from the call site.\n */\n protected dataTransform<TContract extends Contract<SqlStorage>>(\n contract: TContract,\n name: string,\n options: DataTransformOptions,\n ): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return dataTransform(contract, name, options, this.controlAdapterFor('dataTransform'));\n }\n\n /**\n * Emit a `CREATE TABLE` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createTable(options: {\n readonly schema: string;\n readonly table: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateTableCall(\n options.schema,\n options.table,\n options.columns,\n options.constraints,\n ).toOp(this.controlAdapterFor('createTable'));\n }\n\n /**\n * Emit a `CREATE SCHEMA` migration operation. Builds a typed DDL node from\n * the supplied options and lowers it through the stored control adapter.\n * Throws if no adapter is present (i.e. migration instantiated without a stack).\n */\n protected createSchema(options: {\n readonly schema: string;\n readonly ifNotExists?: boolean;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateSchemaCall(options.schema).toOp(this.controlAdapterFor('createSchema'));\n }\n\n /**\n * Emit a `CREATE TYPE ... AS ENUM (...)` migration operation for a managed\n * native enum. Builds a typed DDL node and lowers it through the stored\n * control adapter (members render in declaration order). Throws if no adapter\n * is present.\n */\n protected createNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly members: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateNativeEnumTypeCall(options.schema, options.typeName, options.members).toOp(\n this.controlAdapterFor('createNativeEnumType'),\n );\n }\n\n /**\n * Emit a `DROP TYPE` migration operation for a managed native enum, lowered\n * through the stored control adapter. Throws if no adapter is present.\n */\n protected dropNativeEnumType(options: {\n readonly schema: string;\n readonly typeName: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNativeEnumTypeCall(options.schema, options.typeName).toOp(\n this.controlAdapterFor('dropNativeEnumType'),\n );\n }\n\n /**\n * Emit an `ALTER TYPE ... ADD VALUE` migration operation appending one\n * member to a managed native enum, lowered through the stored control\n * adapter. Throws if no adapter is present. Every appended value is its\n * own operation — call this once per value to append more than one.\n */\n protected addNativeEnumValue(options: {\n readonly schema: string;\n readonly typeName: string;\n readonly value: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddNativeEnumValueCall(options.schema, options.typeName, options.value).toOp(\n this.controlAdapterFor('addNativeEnumValue'),\n );\n }\n\n protected addColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: DdlColumn;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('addColumn'),\n );\n }\n\n protected addPrimaryKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddPrimaryKeyCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addPrimaryKey'));\n }\n\n protected addUnique(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly columns: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddUniqueCall(\n options.schema,\n options.table,\n options.constraint,\n options.columns,\n ).toOp(this.controlAdapterFor('addUnique'));\n }\n\n protected addForeignKey(options: {\n readonly schema: string;\n readonly table: string;\n readonly foreignKey: ForeignKeySpec;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddForeignKeyCall(options.schema, options.table, options.foreignKey).toOp(\n this.controlAdapterFor('addForeignKey'),\n );\n }\n\n protected addCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly column: string;\n readonly values: readonly string[];\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AddCheckConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.column,\n options.values,\n ).toOp(this.controlAdapterFor('addCheckConstraint'));\n }\n\n protected dropCheckConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropCheckConstraintCall(options.schema, options.table, options.constraint).toOp(\n this.controlAdapterFor('dropCheckConstraint'),\n );\n }\n\n protected dropConstraint(options: {\n readonly schema: string;\n readonly table: string;\n readonly constraint: string;\n readonly kind?: 'foreignKey' | 'unique' | 'primaryKey';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropConstraintCall(\n options.schema,\n options.table,\n options.constraint,\n options.kind ?? 'unique',\n ).toOp(this.controlAdapterFor('dropConstraint'));\n }\n\n protected dropTable(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropTableCall(options.schema, options.table).toOp(\n this.controlAdapterFor('dropTable'),\n );\n }\n\n protected dropColumn(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropColumnCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropColumn'),\n );\n }\n\n protected alterColumnType(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly options: AlterColumnTypeOptions;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new AlterColumnTypeCall(\n options.schema,\n options.table,\n options.column,\n options.options,\n ).toOp(this.controlAdapterFor('alterColumnType'));\n }\n\n protected setNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('setNotNull'),\n );\n }\n\n protected dropNotNull(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropNotNullCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropNotNull'),\n );\n }\n\n protected setDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n readonly defaultSql: string;\n readonly operationClass?: 'additive' | 'widening';\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new SetDefaultCall(\n options.schema,\n options.table,\n options.column,\n options.defaultSql,\n options.operationClass,\n ).toOp(this.controlAdapterFor('setDefault'));\n }\n\n protected dropDefault(options: {\n readonly schema: string;\n readonly table: string;\n readonly column: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropDefaultCall(options.schema, options.table, options.column).toOp(\n this.controlAdapterFor('dropDefault'),\n );\n }\n\n protected createIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n readonly columns: readonly string[];\n readonly extras?: CreateIndexExtras;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreateIndexCall(\n options.schema,\n options.table,\n options.index,\n options.columns,\n options.extras,\n ).toOp(this.controlAdapterFor('createIndex'));\n }\n\n protected dropIndex(options: {\n readonly schema: string;\n readonly table: string;\n readonly index: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropIndexCall(options.schema, options.table, options.index).toOp(\n this.controlAdapterFor('dropIndex'),\n );\n }\n\n protected installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return installExtension(options, this.controlAdapterFor('installExtension'));\n }\n\n protected enableRowLevelSecurity(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new EnableRowLevelSecurityCall(options.schema, options.table).toOp(\n this.controlAdapterFor('enableRowLevelSecurity'),\n );\n }\n\n protected disableRowLevelSecurity(options: {\n readonly schema: string;\n readonly table: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DisableRowLevelSecurityCall(options.schema, options.table).toOp(\n this.controlAdapterFor('disableRowLevelSecurity'),\n );\n }\n\n protected createRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly policy: PostgresRlsPolicyInput;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new CreatePostgresRlsPolicyCall(\n options.schema,\n options.table,\n new PostgresRlsPolicy(options.policy),\n ).toOp(this.controlAdapterFor('createRlsPolicy'));\n }\n\n protected dropRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly policy: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new DropPostgresRlsPolicyCall(options.schema, options.table, options.policy).toOp(\n this.controlAdapterFor('dropRlsPolicy'),\n );\n }\n\n protected renameRlsPolicy(options: {\n readonly schema: string;\n readonly table: string;\n readonly from: string;\n readonly to: string;\n }): Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>> {\n return new RenamePostgresRlsPolicyCall(\n options.schema,\n options.table,\n options.from,\n options.to,\n ).toOp(this.controlAdapterFor('renameRlsPolicy'));\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAsB,oBAAtB,cAGUA,UAAgE;CACxE,WAAoB;;;;;;;CAQpB;CAEA,WAAW,IAAI,uBACb,MACA,sBACC,SAAS,qBAAqB,SAAc,IAAI,CACnD;CACA,aAAa,IAAI,uBACf,MACA,sBACC,SAAS,qBAAqB,SAAgB,IAAI,CACrD;CAEA,YAAY,OAAyC;EACnD,MAAM,KAAK;EAIX,KAAK,iBAAiB,OAAO,UACxB,MAAM,QAAQ,OAAO,KAAK,IAC3B,KAAA;CACN;;;;;;CAOA,kBAA0B,WAAkD;EAC1E,IAAI,CAAC,KAAK,gBACR,MAAM,mCAAmC,SAAS;EAEpD,OAAO,KAAK;CACd;;;;;;CAOA,IAAI,cAAyC;EAC3C,OAAO,KAAKC,SAAS;CACvB;;;;;CAMA,IAAI,gBAAoD;EACtD,OAAO,KAAKC,WAAW;CACzB;;;;;;CAOA,cACE,UACA,MACA,SAC+D;EAC/D,OAAO,cAAc,UAAU,MAAM,SAAS,KAAK,kBAAkB,eAAe,CAAC;CACvF;;;;;;CAOA,YAAsB,SAM4C;EAChE,OAAO,IAAI,gBACT,QAAQ,QACR,QAA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-1 +0,0 @@
1
- {"version":3,"file":"postgres-migration-DLIvzHjX.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAmBiB;WACN;WACA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBCoDC,kBACpB,cAAc,SAAS,cAAc,SAAS,aAC9C,YAAY,SAAS,cAAc,SAAS,qBACpC,UAAa,uCAAuC,OAAO;;WAC1D;;;;;;;qBAQU,gBAAgB;cAavB,QAAQ;;;;;;UAeZ;;;;;;MAYJ,eAAe,qBAAqB;;;;;MAQpC,iBAAiB,qBAAqB;;;;;;YAShC,cAAc,kBAAkB,SAAS,aACjD,UAAU,WACV,cACA,SAAS,uBACR,QAAQ,0BAA0B;;;;;;YAS3B,YAAY;aACX;aACA;aACA;aACA,kBAAkB;aAClB,uBAAuB;MAC9B,QAAQ,0BAA0B;;;;;;YAc5B,aAAa;aACZ;aACA;MACP,QAAQ,0BAA0B;;;;;;;YAU5B,qBAAqB;aACpB;aACA;aACA;MACP,QAAQ,0BAA0B;;;;;YAU5B,mBAAmB;aAClB;aACA;MACP,QAAQ,0BAA0B;;;;;;;YAY5B,mBAAmB;aAClB;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,UAAU;aACT;aACA;aACA,QAAQ;MACf,QAAQ,0BAA0B;YAM5B,cAAc;aACb;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,UAAU;aACT;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,cAAc;aACb;aACA;aACA,YAAY;MACnB,QAAQ,0BAA0B;YAM5B,mBAAmB;aAClB;aACA;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAU5B,oBAAoB;aACnB;aACA;aACA;MACP,QAAQ,0BAA0B;YAM5B,eAAe;aACd;aACA;aACA;aACA;MACP,QAAQ,0BAA0B;YAS5B,UAAU;aACT;aACA;MACP,QAAQ,0BAA0B;YAM5B,WAAW;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