@prisma-next/target-postgres 0.16.0-dev.24 → 0.16.0-dev.26

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 (99) hide show
  1. package/dist/{authoring-BCzcFRay.mjs → authoring-DnO1B0N9.mjs} +7 -14
  2. package/dist/authoring-DnO1B0N9.mjs.map +1 -0
  3. package/dist/canonicalize-C7zKHw8m.mjs +59 -0
  4. package/dist/canonicalize-C7zKHw8m.mjs.map +1 -0
  5. package/dist/{canonicalize-D1F4vUnP.d.mts → canonicalize-CQlxSR4D.d.mts} +3 -18
  6. package/dist/canonicalize-CQlxSR4D.d.mts.map +1 -0
  7. package/dist/contract-free.d.mts +1 -1
  8. package/dist/contract-free.d.mts.map +1 -1
  9. package/dist/contract-free.mjs +1 -1
  10. package/dist/{control-policy-B-_34g05.mjs → control-policy-DEwdS3oK.mjs} +23 -24
  11. package/dist/control-policy-DEwdS3oK.mjs.map +1 -0
  12. package/dist/control.mjs +10 -7
  13. package/dist/control.mjs.map +1 -1
  14. package/dist/{ddl-DYEob9xQ.mjs → ddl-BQC6u-L9.mjs} +27 -3
  15. package/dist/{ddl-DYEob9xQ.mjs.map → ddl-BQC6u-L9.mjs.map} +1 -1
  16. package/dist/ddl.d.mts +3 -3
  17. package/dist/ddl.mjs +2 -2
  18. package/dist/{descriptor-meta-D_0ZKcj-.mjs → descriptor-meta-DGlJurgA.mjs} +2 -2
  19. package/dist/{descriptor-meta-D_0ZKcj-.mjs.map → descriptor-meta-DGlJurgA.mjs.map} +1 -1
  20. package/dist/{diff-database-schema-C9H09OD3.mjs → diff-database-schema-qRPwuYBH.mjs} +22 -12
  21. package/dist/diff-database-schema-qRPwuYBH.mjs.map +1 -0
  22. package/dist/diff-database-schema.mjs +1 -1
  23. package/dist/errors.d.mts +4 -2
  24. package/dist/errors.d.mts.map +1 -1
  25. package/dist/errors.mjs +2 -2
  26. package/dist/issue-planner.d.mts +2 -2
  27. package/dist/issue-planner.d.mts.map +1 -1
  28. package/dist/issue-planner.mjs +1 -1
  29. package/dist/migration.d.mts +2 -2
  30. package/dist/migration.mjs +2 -2
  31. package/dist/{nodes-DJC5B8Id.mjs → nodes-04EILM-z.mjs} +65 -2
  32. package/dist/nodes-04EILM-z.mjs.map +1 -0
  33. package/dist/{nodes-CQzM2hR0.d.mts → nodes-DjCsN-uv.d.mts} +69 -4
  34. package/dist/nodes-DjCsN-uv.d.mts.map +1 -0
  35. package/dist/{op-factory-call-DT7kdjVP.d.mts → op-factory-call-0TB5XNij.d.mts} +46 -8
  36. package/dist/op-factory-call-0TB5XNij.d.mts.map +1 -0
  37. package/dist/{op-factory-call-BVYLIojV.mjs → op-factory-call-CIaPDDUc.mjs} +104 -27
  38. package/dist/op-factory-call-CIaPDDUc.mjs.map +1 -0
  39. package/dist/op-factory-call.d.mts +2 -2
  40. package/dist/op-factory-call.mjs +2 -2
  41. package/dist/pack.d.mts.map +1 -1
  42. package/dist/pack.mjs +1 -1
  43. package/dist/{planner-4sj5cJCY.mjs → planner-BhnkIJX-.mjs} +117 -9
  44. package/dist/planner-BhnkIJX-.mjs.map +1 -0
  45. package/dist/{planner-produced-postgres-migration-CcQPDWmX.mjs → planner-produced-postgres-migration-BE3EJIRK.mjs} +2 -2
  46. package/dist/{planner-produced-postgres-migration-CcQPDWmX.mjs.map → planner-produced-postgres-migration-BE3EJIRK.mjs.map} +1 -1
  47. package/dist/{planner-produced-postgres-migration-8QP8eMph.d.mts → planner-produced-postgres-migration-CRAHl6ak.d.mts} +2 -2
  48. package/dist/planner-produced-postgres-migration-CRAHl6ak.d.mts.map +1 -0
  49. package/dist/planner-produced-postgres-migration.d.mts +1 -1
  50. package/dist/planner-produced-postgres-migration.mjs +1 -1
  51. package/dist/{planner-schema-lookup-CiVaAQP-.mjs → planner-schema-lookup-D3Y_OL-C.mjs} +3 -3
  52. package/dist/planner-schema-lookup-D3Y_OL-C.mjs.map +1 -0
  53. package/dist/planner-schema-lookup.mjs +1 -1
  54. package/dist/planner.d.mts +21 -1
  55. package/dist/planner.d.mts.map +1 -1
  56. package/dist/planner.mjs +2 -2
  57. package/dist/{postgres-contract-view-B8yXVWYe.mjs → postgres-contract-view-BeIEyZfD.mjs} +2 -2
  58. package/dist/{postgres-contract-view-B8yXVWYe.mjs.map → postgres-contract-view-BeIEyZfD.mjs.map} +1 -1
  59. package/dist/{postgres-migration-GIOABsAa.mjs → postgres-migration--BzvpA92.mjs} +7 -4
  60. package/dist/postgres-migration--BzvpA92.mjs.map +1 -0
  61. package/dist/{postgres-migration-DLIvzHjX.d.mts → postgres-migration-BXelnqHO.d.mts} +15 -10
  62. package/dist/postgres-migration-BXelnqHO.d.mts.map +1 -0
  63. package/dist/rls-canonicalize.d.mts +2 -26
  64. package/dist/rls-canonicalize.mjs +2 -2
  65. package/dist/runtime.mjs +1 -1
  66. package/package.json +20 -20
  67. package/src/contract-free/ddl.ts +47 -0
  68. package/src/core/authoring.ts +10 -22
  69. package/src/core/ddl/nodes.ts +104 -0
  70. package/src/core/migrations/contract-to-postgres-database-schema-node.ts +24 -13
  71. package/src/core/migrations/issue-planner.ts +40 -13
  72. package/src/core/migrations/op-factory-call.ts +100 -9
  73. package/src/core/migrations/operations/indexes.ts +80 -35
  74. package/src/core/migrations/planner-schema-lookup.ts +2 -2
  75. package/src/core/migrations/planner.ts +155 -5
  76. package/src/core/migrations/postgres-migration.ts +26 -8
  77. package/src/core/psl-infer/infer-psl-contract.ts +8 -1
  78. package/src/core/rls/canonicalize.ts +4 -21
  79. package/src/exports/ddl.ts +4 -0
  80. package/src/exports/errors.ts +1 -1
  81. package/src/exports/op-factory-call.ts +1 -0
  82. package/src/exports/rls-canonicalize.ts +0 -6
  83. package/dist/authoring-BCzcFRay.mjs.map +0 -1
  84. package/dist/canonicalize-D1F4vUnP.d.mts.map +0 -1
  85. package/dist/control-policy-B-_34g05.mjs.map +0 -1
  86. package/dist/diff-database-schema-C9H09OD3.mjs.map +0 -1
  87. package/dist/nodes-CQzM2hR0.d.mts.map +0 -1
  88. package/dist/nodes-DJC5B8Id.mjs.map +0 -1
  89. package/dist/op-factory-call-BVYLIojV.mjs.map +0 -1
  90. package/dist/op-factory-call-DT7kdjVP.d.mts.map +0 -1
  91. package/dist/planner-4sj5cJCY.mjs.map +0 -1
  92. package/dist/planner-produced-postgres-migration-8QP8eMph.d.mts.map +0 -1
  93. package/dist/planner-schema-lookup-CiVaAQP-.mjs.map +0 -1
  94. package/dist/postgres-migration-DLIvzHjX.d.mts.map +0 -1
  95. package/dist/postgres-migration-GIOABsAa.mjs.map +0 -1
  96. package/dist/rls-canonicalize.d.mts.map +0 -1
  97. package/dist/wire-name-DbQ9-2RC.mjs +0 -104
  98. package/dist/wire-name-DbQ9-2RC.mjs.map +0 -1
  99. package/src/core/rls/wire-name.ts +0 -33
@@ -1 +0,0 @@
1
- {"version":3,"file":"nodes-DJC5B8Id.mjs","names":[],"sources":["../src/core/ddl/nodes.ts"],"sourcesContent":["import {\n type DdlColumn,\n DdlNode,\n type DdlTableConstraint,\n} from '@prisma-next/sql-relational-core/ast';\nimport type { RlsPolicyOperation } from '../rls/canonicalize';\n\n// ---------------------------------------------------------------------------\n// AlterTableAction — nested polymorphic hierarchy\n// ---------------------------------------------------------------------------\n\nexport interface AlterTableActionVisitor<R> {\n addColumn(action: AddColumnAction): R;\n dropDefault(action: DropDefaultAction): R;\n}\n\nexport abstract class AlterTableAction {\n abstract readonly kind: string;\n abstract accept<R>(visitor: AlterTableActionVisitor<R>): R;\n}\n\nexport class AddColumnAction extends AlterTableAction {\n readonly kind = 'add-column' as const;\n readonly column: DdlColumn;\n\n constructor(column: DdlColumn) {\n super();\n this.column = column;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.addColumn(this);\n }\n}\n\nexport class DropDefaultAction extends AlterTableAction {\n readonly kind = 'drop-default' as const;\n readonly columnName: string;\n\n constructor(columnName: string) {\n super();\n this.columnName = columnName;\n Object.freeze(this);\n }\n\n override accept<R>(visitor: AlterTableActionVisitor<R>): R {\n return visitor.dropDefault(this);\n }\n}\n\n/**\n * The set of ALTER TABLE subactions currently expressible as typed DDL.\n *\n * The remaining actions — SetDefault, SetNotNull, DropNotNull,\n * AlterColumnType — are still emitted as raw SQL by `operations/columns.ts`\n * and join this union as they are converted to typed DDL. Until then it is\n * intentionally partial: only the ALTER subactions used by the\n * already-converted ops (AddColumn, DropDefault) appear here.\n */\nexport type AnyAlterTableAction = AddColumnAction | DropDefaultAction;\n\n// ---------------------------------------------------------------------------\n// Top-level DDL visitor\n// ---------------------------------------------------------------------------\n\nexport interface PostgresDdlVisitor<R> {\n createTable(node: PostgresCreateTable): R;\n createSchema(node: PostgresCreateSchema): R;\n createType(node: PostgresCreateType): R;\n dropType(node: PostgresDropType): R;\n alterTable(node: PostgresAlterTable): R;\n createPolicy(node: PostgresCreatePolicy): R;\n dropPolicy(node: PostgresDropPolicy): R;\n alterPolicyRename(node: PostgresAlterPolicyRename): R;\n disableRowLevelSecurity(node: PostgresDisableRowLevelSecurity): R;\n}\n\nexport abstract class PostgresDdlNode extends DdlNode {\n abstract accept<R>(visitor: PostgresDdlVisitor<R>): R;\n}\n\nfunction freezeDdlColumns(columns: readonly DdlColumn[]): ReadonlyArray<DdlColumn> {\n return Object.freeze([...columns]);\n}\n\nfunction freezeConstraints(\n constraints: readonly DdlTableConstraint[] | undefined,\n): ReadonlyArray<DdlTableConstraint> | undefined {\n return constraints ? Object.freeze([...constraints]) : undefined;\n}\n\nexport class PostgresCreateTable extends PostgresDdlNode {\n readonly kind = 'create-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly ifNotExists: boolean | undefined;\n readonly columns: ReadonlyArray<DdlColumn>;\n readonly constraints: ReadonlyArray<DdlTableConstraint> | undefined;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly ifNotExists?: boolean;\n readonly columns: readonly DdlColumn[];\n readonly constraints?: readonly DdlTableConstraint[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.columns = freezeDdlColumns(options.columns);\n this.constraints = freezeConstraints(options.constraints);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createTable(this);\n }\n}\n\nexport class PostgresCreateSchema extends PostgresDdlNode {\n readonly kind = 'create-schema' as const;\n readonly schema: string;\n readonly ifNotExists: boolean | undefined;\n\n constructor(options: { readonly schema: string; readonly ifNotExists?: boolean }) {\n super();\n this.schema = options.schema;\n this.ifNotExists = options.ifNotExists;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createSchema(this);\n }\n}\n\nexport class PostgresCreateType extends PostgresDdlNode {\n readonly kind = 'create-type' as const;\n readonly schema: string | undefined;\n readonly name: string;\n readonly values: ReadonlyArray<string>;\n\n constructor(options: {\n readonly schema?: string;\n readonly name: string;\n readonly values: readonly string[];\n }) {\n super();\n this.schema = options.schema;\n this.name = options.name;\n this.values = Object.freeze([...options.values]);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createType(this);\n }\n}\n\nexport class PostgresDropType extends PostgresDdlNode {\n readonly kind = 'drop-type' as const;\n readonly schema: string | undefined;\n readonly name: string;\n\n constructor(options: { readonly schema?: string; readonly name: string }) {\n super();\n this.schema = options.schema;\n this.name = options.name;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.dropType(this);\n }\n}\n\nexport class PostgresAlterTable extends PostgresDdlNode {\n readonly kind = 'alter-table' as const;\n readonly table: string;\n readonly schema: string | undefined;\n readonly actions: ReadonlyArray<AnyAlterTableAction>;\n\n constructor(options: {\n readonly table: string;\n readonly schema?: string;\n readonly actions: readonly AnyAlterTableAction[];\n }) {\n super();\n this.table = options.table;\n this.schema = options.schema;\n this.actions = Object.freeze([...options.actions]);\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterTable(this);\n }\n}\n\nexport type { RlsPolicyOperation };\n\nexport class PostgresCreatePolicy extends PostgresDdlNode {\n readonly kind = 'create-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: ReadonlyArray<string>;\n readonly using: string | undefined;\n readonly withCheck: string | undefined;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly permissive: boolean;\n readonly operation: RlsPolicyOperation;\n readonly roles: readonly string[];\n readonly using?: string;\n readonly withCheck?: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.permissive = options.permissive;\n this.operation = options.operation;\n this.roles = Object.freeze([...options.roles]);\n this.using = options.using;\n this.withCheck = options.withCheck;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.createPolicy(this);\n }\n}\n\nexport class PostgresDropPolicy extends PostgresDdlNode {\n readonly kind = 'drop-policy' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n\n constructor(options: { readonly schema: string; readonly table: string; readonly name: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.dropPolicy(this);\n }\n}\n\nexport class PostgresAlterPolicyRename extends PostgresDdlNode {\n readonly kind = 'alter-policy-rename' as const;\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly newName: string;\n\n constructor(options: {\n readonly schema: string;\n readonly table: string;\n readonly name: string;\n readonly newName: string;\n }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.name = options.name;\n this.newName = options.newName;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.alterPolicyRename(this);\n }\n}\n\nexport class PostgresDisableRowLevelSecurity extends PostgresDdlNode {\n readonly kind = 'disable-row-level-security' as const;\n readonly schema: string;\n readonly table: string;\n\n constructor(options: { readonly schema: string; readonly table: string }) {\n super();\n this.schema = options.schema;\n this.table = options.table;\n this.freeze();\n }\n\n override accept<R>(visitor: PostgresDdlVisitor<R>): R {\n return visitor.disableRowLevelSecurity(this);\n }\n}\n\nexport type AnyPostgresDdlNode =\n | PostgresCreateTable\n | PostgresCreateSchema\n | PostgresCreateType\n | PostgresDropType\n | PostgresAlterTable\n | PostgresCreatePolicy\n | PostgresDropPolicy\n | PostgresAlterPolicyRename\n | PostgresDisableRowLevelSecurity;\n"],"mappings":";;AAgBA,IAAsB,mBAAtB,MAAuC,CAGvC;AAEA,IAAa,kBAAb,cAAqC,iBAAiB;CACpD,OAAgB;CAChB;CAEA,YAAY,QAAmB;EAC7B,MAAM;EACN,KAAK,SAAS;EACd,OAAO,OAAO,IAAI;CACpB;CAEA,OAAmB,SAAwC;EACzD,OAAO,QAAQ,UAAU,IAAI;CAC/B;AACF;AAEA,IAAa,oBAAb,cAAuC,iBAAiB;CACtD,OAAgB;CAChB;CAEA,YAAY,YAAoB;EAC9B,MAAM;EACN,KAAK,aAAa;EAClB,OAAO,OAAO,IAAI;CACpB;CAEA,OAAmB,SAAwC;EACzD,OAAO,QAAQ,YAAY,IAAI;CACjC;AACF;AA6BA,IAAsB,kBAAtB,cAA8C,QAAQ,CAEtD;AAEA,SAAS,iBAAiB,SAAyD;CACjF,OAAO,OAAO,OAAO,CAAC,GAAG,OAAO,CAAC;AACnC;AAEA,SAAS,kBACP,aAC+C;CAC/C,OAAO,cAAc,OAAO,OAAO,CAAC,GAAG,WAAW,CAAC,IAAI,KAAA;AACzD;AAEA,IAAa,sBAAb,cAAyC,gBAAgB;CACvD,OAAgB;CAChB;CACA;CACA;CACA;CACA;CAEA,YAAY,SAMT;EACD,MAAM;EACN,KAAK,QAAQ,QAAQ;EACrB,KAAK,SAAS,QAAQ;EACtB,KAAK,cAAc,QAAQ;EAC3B,KAAK,UAAU,iBAAiB,QAAQ,OAAO;EAC/C,KAA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ction","contractFreeDdl.addColumnAction","disableRowLevelSecurityDdl","contractFreeDdl.alterTable","contractFreeDdl.addColumnAction","contractFreeDdl.dropDefaultAction","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 { InternalError } from '@prisma-next/utils/internal-error';\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 InternalError(`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 InternalError(`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 { postgresError } from '../../errors';\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 postgresError(\n 'CONTRACT.INDEX_INVALID',\n `Index option \"${key}\" must be a string, finite number, or boolean; got ${typeof value}`,\n { meta: { key, valueType: 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 { postgresError } from '../../errors';\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 postgresError(\n 'CONTRACT.ROLE_INVALID',\n `Invalid role name ${JSON.stringify(role)}: role names must be plain SQL identifiers matching ^[A-Za-z_][A-Za-z0-9_$]*$`,\n { meta: { role, reason: 'not-a-plain-identifier' } },\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 { assertNever } from '@prisma-next/utils/internal-error';\nimport {\n columnExistsAst,\n nativeEnumTypeExistsAst,\n nativeEnumValueExistsAst,\n tableExistsAst,\n} from '../../contract-free/checks';\nimport * as contractFreeDdl from '../../contract-free/ddl';\nimport { postgresError } from '../errors';\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 return assertNever(\n exhaustive,\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `CreateTableCall.toOp: a DDL lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'CreateTableCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `DropTableCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'DropTableCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddColumnCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropColumnCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AlterColumnTypeCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'SetNotNullCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropNotNullCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'SetDefaultCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropDefaultCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddNotNullColumnDirectCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddNotNullColumnWithTempDefaultCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddPrimaryKeyCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddUniqueCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddForeignKeyCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropConstraintCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'AddCheckConstraintCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropCheckConstraintCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'CreateIndexCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropIndexCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `CreateSchemaCall.toOp: a DDL lowerer is required on the Postgres planner path (schema \"${this.schemaName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'CreateSchemaCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `CreateNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'CreateNativeEnumTypeCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `DropNativeEnumTypeCall.toOp: a DDL lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'DropNativeEnumTypeCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `AddNativeEnumValueCall.toOp: a lowerer is required on the Postgres planner path (type \"${this.typeName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'AddNativeEnumValueCall' } },\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 // endContract is imported by the migration scaffold's contractImports; an op never renders outside it.\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'CreatePostgresRlsPolicyCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'DropPostgresRlsPolicyCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `EnableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'EnableRowLevelSecurityCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\n `DisableRowLevelSecurityCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n { meta: { factory: 'DisableRowLevelSecurityCall' } },\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 postgresError(\n 'MIGRATION.POSTGRES_CONTROL_STACK_MISSING',\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 { meta: { factory: 'RenamePostgresRlsPolicyCall' } },\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,e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O;CACd;CAEA,MAAM,KAAK,SAA8C;EACvD,IAAI,YAAY,KAAA,GACd,MAAM,cACJ,4CACA,iGAAiG,KAAK,cAAc,cAAc,KAAK,UAAU,kEACjJ,EAAE,MAAM,EAAE,SAAS,8BAA8B,EAAE,CACrD;EAEF,OAAO,gBACL,KAAK,YACL,KAAK,WACL,KAAK,eACL,KAAK,eACL,OACF;CACF;CAEA,mBAA2B;EACzB,OAAO,kCAAkC,eAAe,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":"op-factory-call-DT7kdjVP.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/op-factory-call.ts"],"mappings":";;;;;;;;;;KAKY,OAAK,0BAA0B;;;;;;UAO1B;WACN;WACA;WACA;aACE;aACA;aACA;;WAEF,WAAW;WACX,WAAW;;;;KCsEjB,KAAK,0BAA0B;uBAgBrB,kCAAkC,wBAAwB;oBACrD;oBACA,gBAAgB;oBAChB;WACT,KAAK,UAAU,UAAU,KAAK,QAAQ;EAE/C,+BAA+B;YAIrB;;cAuGC,wBAAwB;WAC1B;WACA;WACA;WACA;WACA,kBAAkB;WAClB,sBAAsB;WACtB;cAGP,oBACA,mBACA,kBAAkB,aAClB,uBAAuB;EAWnB,KAAK,UAAU,wBAAwB,QAAQ;EAsCrD;EAiBS,+BAA+B;;cAe7B,sBAAsB;WACxB;WACA;WACA;WACA;WACA;cAEG,oBAAoB;EAQ1B,KAAK,UAAU,wBAAwB,QAAQ;EAWrD;EASS,+BAA+B;;cAS7B,sBAAsB;WACxB;WACA;WACA;WACA;WACA,QAAQ;WACR;cAEG,oBAAoB,mBAAmB,QAAQ;EASrD,KAAK,UAAU,wBAAwB,QAAQ;EA+BrD;EAUS,+BAA+B;;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;EAiBrD;EAIS,+BAA+B;;KAK9B,wBACR,kBACA,gBACA,gBACA,iBACA,sBACA,iBACA,kBACA,iBACA,kBACA,6BACA,sCACA,oBACA,oBACA,gBACA,yBACA,0BACA,kBACA,gBACA,qBACA,aACA,sBACA,mBACA,2BACA,yBACA,yBACA,8BACA,4BACA,6BACA,8BACA,8BACA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"planner-4sj5cJCY.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 /**\n * POSIX-relative path from the migration package dir to\n * `migrations/snapshots` — see\n * {@link SqlMigrationPlannerPlanOptions.snapshotsImportPath}.\n */\n readonly snapshotsImportPath: string;\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 context.snapshotsImportPath,\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 options.snapshotsImportPath,\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,KAA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A,GAAW,OAAO,KAAA;CACxC,OAAO,UAGL,aAAa;AACjB;;;;;;;;;;AAWA,SAAS,2BAA2B,MAAmD;CACrF,OAAO,IAAI,kBAAkB;EAC3B,MAAM,KAAK;EACX,QAAQ,KAAK;EACb,WAAW,KAAK;EAChB,aAAa,KAAK;EAClB,WAAW,KAAK;EAChB,OAAO,CAAC,GAAG,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-produced-postgres-migration-8QP8eMph.d.mts","names":[],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"mappings":";;;;;;;cAqCa,8CACH,6BACG;;cAeT,gBAAgB,iBAChB,MAAM,eACN,iBACA,6BACA,UAAU;MAUC,wBACT,0BAA0B,6BAC1B,QAAQ,0BAA0B;EAM7B,YAAY;;;;;;MASjB;EAIJ"}
@@ -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,QAA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,IACnB,KAAK,UAAU;EAAC,GAAG,OAAO;EAAS,GAAG,OAAO;EAAW,GAAG,OAAO;CAAO,CAAC,CAC5E;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-DLIvzHjX.d.mts","names":[],"sources":["../src/core/migrations/operations/indexes.ts","../src/core/migrations/postgres-migration.ts"],"mappings":";;;;;;;;;;;;;UAoBiB;WACN;WACA,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uBCmDC,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,0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