@prisma-next/target-postgres 0.13.0-dev.37 → 0.13.0-dev.39
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.
- package/dist/control.mjs +1 -1
- package/dist/{issue-planner-CoI_0uM1.mjs → issue-planner-DL6g3CmE.mjs} +2 -2
- package/dist/{issue-planner-CoI_0uM1.mjs.map → issue-planner-DL6g3CmE.mjs.map} +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.mjs +2 -2
- package/dist/{op-factory-call-B1bXWtfa.mjs → op-factory-call-D_p5vxwt.mjs} +3 -2
- package/dist/op-factory-call-D_p5vxwt.mjs.map +1 -0
- package/dist/op-factory-call-DmQEc3XV.d.mts.map +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/{planner-DS5XBhmi.mjs → planner-Bs_baQax.mjs} +3 -3
- package/dist/{planner-DS5XBhmi.mjs.map → planner-Bs_baQax.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-DTwCCek_.mjs → planner-produced-postgres-migration-Cji5vxUf.mjs} +2 -2
- package/dist/{planner-produced-postgres-migration-DTwCCek_.mjs.map → planner-produced-postgres-migration-Cji5vxUf.mjs.map} +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/{postgres-migration-otiaw3Ru.mjs → postgres-migration-B5jKrXv3.mjs} +2 -2
- package/dist/{postgres-migration-otiaw3Ru.mjs.map → postgres-migration-B5jKrXv3.mjs.map} +1 -1
- package/package.json +17 -17
- package/src/core/migrations/op-factory-call.ts +2 -1
- package/dist/op-factory-call-B1bXWtfa.mjs.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"op-factory-call-D_p5vxwt.mjs","names":["exhaustive","contractFreeDdl.createTable","contractFreeDdl.alterTable","contractFreeDdl.addColumnAction","contractFreeDdl.createSchema"],"sources":["../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/tables.ts","../src/core/migrations/planner-target-details.ts","../src/core/migrations/planner-recipes.ts","../src/core/migrations/op-factory-call.ts"],"sourcesContent":["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 { quoteIdentifier } from '../../sql-utils';\nimport type { OperationClass, PostgresPlanTargetDetails } from '../planner-target-details';\n\nexport type Op = SqlMigrationPlanOperation<PostgresPlanTargetDetails>;\n\n/**\n * Literal-args shape for a column definition consumed by `addColumn` and\n * similar operations. Fully materialized: codec expansion and default\n * rendering have already happened in the wrapper.\n *\n * - `typeSql` is the column's DDL type string (e.g. `\"integer\"`, `\"SERIAL\"`,\n * `\"varchar(100)\"`), already produced by `buildColumnTypeSql` in the\n * call-factory wrapper.\n * - `defaultSql` is the full `DEFAULT …` clause (e.g. `\"DEFAULT 42\"`) or an\n * empty string when the column has no default, matching\n * `buildColumnDefaultSql`'s output.\n */\nexport interface ColumnSpec {\n readonly name: string;\n readonly typeSql: string;\n readonly defaultSql: string;\n readonly nullable: boolean;\n}\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\nexport function renderColumnDefinition(column: ColumnSpec): string {\n const parts = [\n quoteIdentifier(column.name),\n column.typeSql,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n return parts.join(' ');\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport {\n columnDefaultAst,\n columnExistsAst,\n columnNullabilityAst,\n columnTypeAst,\n noNullValuesAst,\n tableIsEmptyAst,\n} from '../../../contract-free/checks';\nimport { 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 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 qualified = qualifyTableName(schemaName, tableName);\n const { present } = await columnExistsSteps(lowerer, {\n schema: schemaName,\n table: tableName,\n column: columnName,\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: [\n step(\n `drop default on \"${columnName}\"`,\n `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`,\n ),\n ],\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 is the raw ADD COLUMN SQL passed by the caller\n * (slice-7 deferred); postchecks assert the column exists and is NOT NULL.\n */\nexport async function addNotNullColumnDirect(\n schemaName: string,\n tableName: string,\n columnName: string,\n executeStepSql: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\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}\"`, executeStepSql)],\n postcheck: [\n step(`verify column \"${columnName}\" exists`, present.sql, present.params),\n step(`verify column \"${columnName}\" is NOT NULL`, notNullable.sql, notNullable.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { REFERENTIAL_ACTION_SQL } from '@prisma-next/sql-contract/referential-action-sql';\nimport { constraintExistsAst } from '../../../contract-free/checks';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type ForeignKeySpec, type Op, step, targetDetails } from './shared';\n\nasync function constraintCheckSteps(\n lowerer: ExecuteRequestLowerer,\n options: { constraintName: string; schema: string; table: string },\n): Promise<{\n absent: { sql: string; params?: readonly unknown[] };\n present: { sql: string; params?: readonly unknown[] };\n}> {\n const checks = constraintExistsAst(options);\n const absent = await lowerer.lowerToExecuteRequest(checks.constraintAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.constraintPresent());\n return { absent, present };\n}\n\nfunction renderForeignKeySql(schemaName: string, tableName: string, fk: ForeignKeySpec): string {\n let sql = `ALTER TABLE ${qualifyTableName(schemaName, tableName)}\nADD CONSTRAINT ${quoteIdentifier(fk.name)}\nFOREIGN KEY (${fk.columns.map(quoteIdentifier).join(', ')})\nREFERENCES ${qualifyTableName(fk.references.schema, fk.references.table)} (${fk.references.columns\n .map(quoteIdentifier)\n .join(', ')})`;\n\n if (fk.onDelete !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onDelete];\n if (!action) {\n throw new Error(`Unknown referential action for onDelete: ${String(fk.onDelete)}`);\n }\n sql += `\\nON DELETE ${action}`;\n }\n if (fk.onUpdate !== undefined) {\n const action = REFERENTIAL_ACTION_SQL[fk.onUpdate];\n if (!action) {\n throw new Error(`Unknown referential action for onUpdate: ${String(fk.onUpdate)}`);\n }\n sql += `\\nON UPDATE ${action}`;\n }\n return sql;\n}\n\nexport async function addPrimaryKey(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `primaryKey.${tableName}.${constraintName}`,\n label: `Add primary key on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('primaryKey', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure primary key \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add primary key \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} PRIMARY KEY (${columnList})`,\n ),\n ],\n postcheck: [step(`verify primary key \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addUnique(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `unique.${tableName}.${constraintName}`,\n label: `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`,\n operationClass: 'additive',\n target: targetDetails('unique', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add unique constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`,\n ),\n ],\n postcheck: [step(`verify constraint \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addForeignKey(\n schemaName: string,\n tableName: string,\n fk: ForeignKeySpec,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `foreignKey.${tableName}.${fk.name}`,\n label: `Add foreign key \"${fk.name}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('foreignKey', fk.name, schemaName, tableName),\n precheck: [step(`ensure FK \"${fk.name}\" does not exist`, absent.sql, absent.params)],\n execute: [step(`add FK \"${fk.name}\"`, renderForeignKeySql(schemaName, tableName, fk))],\n postcheck: [step(`verify FK \"${fk.name}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function addCheckConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n column: string,\n values: readonly string[],\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const valueList = values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `checkConstraint.${tableName}.${constraintName}`,\n label: `Add check constraint \"${constraintName}\" on \"${tableName}\".\"${column}\"`,\n operationClass: 'additive',\n target: targetDetails('checkConstraint', constraintName, schemaName, tableName),\n precheck: [\n step(`ensure constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `add check constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} CHECK (${quoteIdentifier(column)} IN (${valueList}))`,\n ),\n ],\n postcheck: [step(`verify constraint \"${constraintName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropCheckConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const { absent, present } = await constraintCheckSteps(lowerer, {\n constraintName,\n schema: schemaName,\n table: tableName,\n });\n return {\n id: `dropCheckConstraint.${tableName}.${constraintName}`,\n label: `Drop check constraint \"${constraintName}\" on \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('checkConstraint', constraintName, schemaName, tableName),\n precheck: [step(`ensure constraint \"${constraintName}\" exists`, present.sql, present.params)],\n execute: [\n step(\n `drop check constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(`verify constraint \"${constraintName}\" does not exist`, absent.sql, absent.params),\n ],\n };\n}\n\n/**\n * `kind` feeds the operation's `target.details.objectType`. Descriptor-flow\n * does not carry kind information in its drop-constraint descriptor, so the\n * default is `'unique'`. The reconciliation planner passes the correct kind\n * (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the `SchemaIssue`\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 { 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: 'public', objectType: 'dependency', name: extensionName },\n },\n precheck: [\n step(`verify extension \"${extensionName}\" is not already enabled`, absent.sql, absent.params),\n ],\n execute: [\n step(\n `create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${extensionName}`,\n ),\n ],\n postcheck: [\n step(`confirm extension \"${extensionName}\" is enabled`, present.sql, present.params),\n ],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { indexExistsAst } from '../../../contract-free/checks';\nimport { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\n\ntype CheckStep = { sql: string; params?: readonly unknown[] };\n\nasync function indexExistsSteps(\n lowerer: ExecuteRequestLowerer,\n schemaName: string,\n indexName: string,\n): Promise<{ present: CheckStep; absent: CheckStep }> {\n const checks = indexExistsAst(schemaName, indexName);\n const present = await lowerer.lowerToExecuteRequest(checks.indexPresent());\n const absent = await lowerer.lowerToExecuteRequest(checks.indexAbsent());\n return { present, absent };\n}\n\nexport interface CreateIndexExtras {\n readonly type?: string;\n readonly options?: Record<string, unknown>;\n}\n\nfunction renderIndexOptionValue(key: string, value: unknown): string {\n if (typeof value === 'string') return `'${escapeLiteral(value)}'`;\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'boolean') return value ? 'true' : 'false';\n throw new Error(\n `Index option \"${key}\" must be a string, finite number, or boolean; got ${typeof value}`,\n );\n}\n\nfunction renderIndexOptions(options: Record<string, unknown>): string {\n return Object.entries(options)\n .map(([key, value]) => `${quoteIdentifier(key)} = ${renderIndexOptionValue(key, value)}`)\n .join(', ');\n}\n\nexport async function createIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n lowerer: ExecuteRequestLowerer,\n extras?: CreateIndexExtras,\n): Promise<Op> {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\n const using = extras?.type ? ` USING ${quoteIdentifier(extras.type)}` : '';\n const options = extras?.options;\n const withClause =\n options && Object.keys(options).length > 0 ? ` WITH (${renderIndexOptions(options)})` : '';\n const { present, absent } = await indexExistsSteps(lowerer, schemaName, indexName);\n return {\n id: `index.${tableName}.${indexName}`,\n label: `Create index \"${indexName}\" on \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [step(`ensure index \"${indexName}\" does not exist`, absent.sql, absent.params)],\n execute: [\n step(\n `create index \"${indexName}\"`,\n `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`,\n ),\n ],\n postcheck: [step(`verify index \"${indexName}\" exists`, present.sql, present.params)],\n };\n}\n\nexport async function dropIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n lowerer: ExecuteRequestLowerer,\n): Promise<Op> {\n const { present, absent } = await indexExistsSteps(lowerer, schemaName, indexName);\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index \"${indexName}\"`,\n operationClass: 'destructive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [step(`ensure index \"${indexName}\" exists`, present.sql, present.params)],\n execute: [\n step(`drop index \"${indexName}\"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`),\n ],\n postcheck: [step(`verify index \"${indexName}\" does not exist`, absent.sql, absent.params)],\n };\n}\n","import type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport { 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\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 {\n columnDefaultAst,\n columnExistsAst,\n columnNullabilityAst,\n} from '../../contract-free/checks';\nimport { quoteIdentifier } from '../sql-utils';\nimport { step } from './operations/shared';\nimport { buildAddColumnSql } from './planner-ddl-builders';\nimport { qualifyTableName } from './planner-sql-checks';\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 const qualified = qualifyTableName(schema, tableName);\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: buildAddColumnSql(\n qualified,\n columnName,\n column,\n codecHooks,\n temporaryDefault,\n storageTypes,\n ),\n },\n {\n description: `drop temporary default from column \"${columnName}\"`,\n sql: `ALTER TABLE ${qualified} ALTER COLUMN ${quoteIdentifier(columnName)} DROP DEFAULT`,\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 * `PN-MIG-2001` 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 { columnExistsAst, tableExistsAst } from '../../contract-free/checks';\nimport * as contractFreeDdl from '../../contract-free/ddl';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport type { PostgresColumnDefault } from '../types';\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 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\nfunction boundSchema(schemaName: string): string | undefined {\n return schemaName === UNBOUND_NAMESPACE_ID ? undefined : schemaName;\n}\n\nabstract class PostgresOpFactoryCallNode extends TsExpression implements FrameworkOpFactoryCall {\n abstract readonly factoryName: string;\n abstract readonly operationClass: MigrationOperationClass;\n abstract readonly label: string;\n abstract toOp(lowerer?: Lowerer): Op | Promise<Op>;\n\n importRequirements(): readonly ImportRequirement[] {\n return [{ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: this.factoryName }];\n }\n\n protected freeze(): void {\n Object.freeze(this);\n }\n}\n\n// ============================================================================\n// Table\n// ============================================================================\n\nexport function postgresDefaultToDdlColumnDefault(\n columnDefault: PostgresColumnDefault | undefined,\n): DdlColumn['default'] {\n if (!columnDefault) return undefined;\n switch (columnDefault.kind) {\n case 'literal':\n return new LiteralColumnDefault(columnDefault.value);\n case 'function':\n if (columnDefault.expression === 'autoincrement()') return undefined;\n return new FunctionColumnDefault(columnDefault.expression);\n case 'sequence':\n return new FunctionColumnDefault(\n `nextval('${escapeLiteral(quoteIdentifier(columnDefault.name))}'::regclass)`,\n );\n default: {\n const exhaustive: never = columnDefault;\n throw new Error(\n `postgresDefaultToDdlColumnDefault: unhandled kind \"${blindCast<{ kind: string }, 'exhaustiveness: surface the unhandled default kind'>(exhaustive).kind}\"`,\n );\n }\n }\n}\n\n// ---------------------------------------------------------------------------\n// TypeScript rendering helpers for DdlColumn / DdlTableConstraint\n// ---------------------------------------------------------------------------\n\nfunction renderDdlColumnDefault(def: AnyDdlColumnDefault | undefined): string {\n if (!def) return '';\n if (def.kind === 'literal') {\n return `lit(${jsonToTsSource(def.value)})`;\n }\n return `fn(${jsonToTsSource(def.expression)})`;\n}\n\nfunction renderDdlColumnAsTsCall(col: DdlColumn): string {\n const opts: string[] = [];\n if (col.notNull) opts.push('notNull: true');\n if (col.primaryKey) opts.push('primaryKey: true');\n if (col.default) opts.push(`default: ${renderDdlColumnDefault(col.default)}`);\n if (col.codecRef) opts.push(`codecRef: ${jsonToTsSource(col.codecRef)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `col(${jsonToTsSource(col.name)}, ${jsonToTsSource(col.type)}${optsStr})`;\n}\n\nfunction renderDdlConstraintAsTsCall(constraint: DdlTableConstraint): string {\n switch (constraint.kind) {\n case 'primary-key': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `primaryKey(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n case 'foreign-key': {\n const opts: string[] = [];\n if (constraint.name) opts.push(`name: ${jsonToTsSource(constraint.name)}`);\n if (constraint.onDelete) opts.push(`onDelete: ${jsonToTsSource(constraint.onDelete)}`);\n if (constraint.onUpdate) opts.push(`onUpdate: ${jsonToTsSource(constraint.onUpdate)}`);\n const optsStr = opts.length > 0 ? `, { ${opts.join(', ')} }` : '';\n return `foreignKey(${jsonToTsSource(constraint.columns)}, ${jsonToTsSource(constraint.refTable)}, ${jsonToTsSource(constraint.refColumns)}${optsStr})`;\n }\n case 'unique': {\n const nameOpt = constraint.name ? `, { name: ${jsonToTsSource(constraint.name)} }` : '';\n return `unique(${jsonToTsSource(constraint.columns)}${nameOpt})`;\n }\n }\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 }\n return [...symbols];\n}\n\nfunction defaultImportSymbols(columns: readonly DdlColumn[]): string[] {\n const symbols = new Set<string>();\n for (const col of columns) {\n if (col.default?.kind === 'literal') symbols.add('lit');\n else if (col.default?.kind === 'function') symbols.add('fn');\n }\n return [...symbols];\n}\n\nexport class CreateTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createTable' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columns: readonly DdlColumn[];\n readonly constraints: readonly DdlTableConstraint[] | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columns: readonly DdlColumn[],\n constraints?: readonly DdlTableConstraint[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columns = Object.freeze([...columns]);\n this.constraints = constraints ? Object.freeze([...constraints]) : undefined;\n this.label = `Create table \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateTableCall.toOp: a DDL lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.createTable({\n ...ifDefined('schema', boundSchema(this.schemaName)),\n table: this.tableName,\n columns: this.columns,\n ...ifDefined('constraints', this.constraints),\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n const tableName = this.tableName;\n const checks = tableExistsAst(schemaName, tableName);\n const absent = await lowerer.lowerToExecuteRequest(checks.tableAbsent());\n const present = await lowerer.lowerToExecuteRequest(checks.tablePresent());\n return {\n id: `table.${tableName}`,\n label: `Create table \"${tableName}\"`,\n summary: `Creates table \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [step(`ensure table \"${tableName}\" does not exist`, absent.sql, absent.params)],\n execute: [\n {\n description: `create table \"${tableName}\"`,\n sql: statement.sql,\n params: statement.params ?? [],\n },\n ],\n postcheck: [step(`verify table \"${tableName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n const columnsList = this.columns.map(renderDdlColumnAsTsCall).join(', ');\n const constraintsList = this.constraints\n ? this.constraints.map(renderDdlConstraintAsTsCall).join(', ')\n : undefined;\n\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`columns: [${columnsList}]`);\n if (constraintsList) opts.push(`constraints: [${constraintsList}]`);\n\n return `this.createTable({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n const req: ImportRequirement[] = [];\n if (needsColOrConstraintImport(this.columns)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'col' });\n for (const sym of defaultImportSymbols(this.columns)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n }\n for (const sym of constraintImportSymbols(this.constraints)) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n return req;\n }\n}\n\nexport class DropTableCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropTable' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.label = `Drop table \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropTableCall.toOp: a lowerer is required on the Postgres planner path (table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropTable(this.schemaName, this.tableName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n return `this.dropTable({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Column\n// ============================================================================\n\nexport class AddColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addColumn' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly column: DdlColumn;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, column: DdlColumn) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.column = column;\n this.label = `Add column \"${column.name}\" to \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddColumnCall.toOp: a DDL lowerer is required on the Postgres planner path (column \"${this.column.name}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.alterTable({\n ...ifDefined('schema', boundSchema(this.schemaName)),\n table: this.tableName,\n actions: [contractFreeDdl.addColumnAction(this.column)],\n });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n const tableName = this.tableName;\n const columnName = this.column.name;\n const colChecks = columnExistsAst({ schema: schemaName, table: tableName, column: columnName });\n const absent = await lowerer.lowerToExecuteRequest(colChecks.columnAbsent());\n const present = await lowerer.lowerToExecuteRequest(colChecks.columnPresent());\n return {\n id: `column.${schemaName}.${tableName}.${columnName}`,\n label: `Add column \"${columnName}\" to \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('column', columnName, schemaName, tableName),\n precheck: [step(`ensure column \"${columnName}\" is missing`, absent.sql, absent.params)],\n execute: [step(`add column \"${columnName}\"`, statement.sql)],\n postcheck: [step(`verify column \"${columnName}\" exists`, present.sql, present.params)],\n };\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${renderDdlColumnAsTsCall(this.column)}`);\n return `this.addColumn({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n const req: ImportRequirement[] = [\n { moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'col' },\n ];\n for (const sym of defaultImportSymbols([this.column])) {\n req.push({ moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: sym });\n }\n return req;\n }\n}\n\nexport class DropColumnCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropColumn' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop column \"${columnName}\" from \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropColumnCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropColumn(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropColumn({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport interface AlterColumnTypeOptions {\n readonly qualifiedTargetType: string;\n readonly formatTypeExpected: string;\n readonly rawTargetTypeForLabel: string;\n readonly using?: string;\n}\n\nexport class AlterColumnTypeCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'alterColumnType' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly options: AlterColumnTypeOptions;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n options: AlterColumnTypeOptions,\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.options = options;\n this.label = `Alter type of \"${tableName}\".\"${columnName}\" to ${options.rawTargetTypeForLabel}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AlterColumnTypeCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return alterColumnType(this.schemaName, this.tableName, this.columnName, this.options, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n opts.push(`options: ${jsonToTsSource(this.options)}`);\n return `this.alterColumnType({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class SetNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setNotNull' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Set NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `SetNotNullCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return setNotNull(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.setNotNull({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropNotNullCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropNotNull' as const;\n readonly operationClass = 'widening' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop NOT NULL on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropNotNullCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropNotNull(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropNotNull({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class SetDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'setDefault' as const;\n readonly operationClass: 'additive' | 'widening';\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly defaultSql: string;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.defaultSql = defaultSql;\n this.operationClass = operationClass;\n this.label = `Set default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `SetDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return setDefault(\n this.schemaName,\n this.tableName,\n this.columnName,\n this.defaultSql,\n lowerer,\n this.operationClass,\n );\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n opts.push(`defaultSql: ${jsonToTsSource(this.defaultSql)}`);\n if (this.operationClass !== 'additive') {\n opts.push(`operationClass: ${jsonToTsSource(this.operationClass)}`);\n }\n return `this.setDefault({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropDefault' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.label = `Drop default on \"${tableName}\".\"${columnName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropDefault(this.schemaName, this.tableName, this.columnName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`column: ${jsonToTsSource(this.columnName)}`);\n return `this.dropDefault({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// NOT NULL column additions (planner-internal; no authored surface)\n// ============================================================================\n\n/**\n * Planner-internal call for adding a NOT NULL column (no contract default) to\n * a table that must be empty at migration time. Carries the raw ADD COLUMN SQL\n * (produced by `buildAddColumnSql` at plan time — deferred from slice-7 typed\n * DDL) plus the parameters needed to lower the typed pre/postchecks at render\n * 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 executeStepSql: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, columnName: string, executeStepSql: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.columnName = columnName;\n this.executeStepSql = executeStepSql;\n this.label = `Add column ${columnName} to ${tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddNotNullColumnDirectCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addNotNullColumnDirect(\n this.schemaName,\n this.tableName,\n this.columnName,\n this.executeStepSql,\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 override importRequirements(): readonly ImportRequirement[] {\n return [];\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`; the typed\n * pre/postchecks are lowered at render time via `toOp(lowerer)`. The execute\n * SQL (`buildAddColumnSql`) is still raw per slice-7 deferral.\n *\n * No authored `PostgresMigration` method: this call is only emitted by the\n * planner, never hand-written by migration authors.\n */\nexport class AddNotNullColumnWithTempDefaultCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: StorageColumn;\n readonly codecHooks: Map<string, CodecControlHooks>;\n readonly storageTypes: Record<string, StorageTypeInstance>;\n readonly temporaryDefault: string;\n readonly label: string;\n\n constructor(options: {\n readonly schemaName: string;\n readonly tableName: string;\n readonly columnName: string;\n readonly column: StorageColumn;\n readonly codecHooks: Map<string, CodecControlHooks>;\n readonly storageTypes: Record<string, StorageTypeInstance>;\n readonly temporaryDefault: string;\n }) {\n super();\n this.schemaName = options.schemaName;\n this.tableName = options.tableName;\n this.columnName = options.columnName;\n this.column = options.column;\n this.codecHooks = options.codecHooks;\n this.storageTypes = options.storageTypes;\n this.temporaryDefault = options.temporaryDefault;\n this.label = `Add column ${options.columnName} to ${options.tableName}`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddNotNullColumnWithTempDefaultCall.toOp: a lowerer is required on the Postgres planner path (column \"${this.columnName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return buildAddNotNullColumnWithTemporaryDefaultOperation({\n schema: this.schemaName,\n tableName: this.tableName,\n columnName: this.columnName,\n column: this.column,\n codecHooks: this.codecHooks,\n storageTypes: this.storageTypes,\n temporaryDefault: this.temporaryDefault,\n lowerer,\n });\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource({ id: `column.${this.tableName}.${this.columnName}`, label: this.label, operationClass: 'additive' })})`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Constraints\n// ============================================================================\n\nfunction constraintCallOptions(\n schemaName: string,\n tableName: string,\n constraintName: string,\n): string {\n const opts: string[] = [];\n if (schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(tableName)}`);\n opts.push(`constraint: ${jsonToTsSource(constraintName)}`);\n return opts.join(', ');\n}\n\nexport class AddPrimaryKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addPrimaryKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add primary key on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddPrimaryKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addPrimaryKey(\n this.schemaName,\n this.tableName,\n this.constraintName,\n this.columns,\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n return `this.addPrimaryKey({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, columns: ${jsonToTsSource(this.columns)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddUniqueCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addUnique' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly columns: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.columns = columns;\n this.label = `Add unique constraint on \"${tableName}\" (${columns.join(', ')})`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddUniqueCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addUnique(this.schemaName, this.tableName, this.constraintName, this.columns, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.addUnique({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, columns: ${jsonToTsSource(this.columns)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddForeignKeyCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addForeignKey' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly fk: ForeignKeySpec;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, fk: ForeignKeySpec) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.fk = fk;\n this.label = `Add foreign key \"${fk.name}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddForeignKeyCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.fk.name}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addForeignKey(this.schemaName, this.tableName, this.fk, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`foreignKey: ${jsonToTsSource(this.fk)}`);\n return `this.addForeignKey({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropConstraint' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly kind: 'foreignKey' | 'unique' | 'primaryKey';\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.kind = kind;\n this.label = `Drop constraint \"${constraintName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropConstraint(this.schemaName, this.tableName, this.constraintName, lowerer, this.kind);\n }\n\n renderTypeScript(): string {\n const opts = [constraintCallOptions(this.schemaName, this.tableName, this.constraintName)];\n if (this.kind !== 'unique') {\n opts.push(`kind: ${jsonToTsSource(this.kind)}`);\n }\n return `this.dropConstraint({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class AddCheckConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'addCheckConstraint' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly column: string;\n readonly values: readonly string[];\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n constraintName: string,\n column: string,\n values: readonly string[],\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.column = column;\n this.values = values;\n this.label = `Add check constraint \"${constraintName}\" on \"${tableName}\".\"${column}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `AddCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return addCheckConstraint(\n this.schemaName,\n this.tableName,\n this.constraintName,\n this.column,\n this.values,\n lowerer,\n );\n }\n\n renderTypeScript(): string {\n return `this.addCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)}, column: ${jsonToTsSource(this.column)}, values: ${jsonToTsSource(this.values)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropCheckConstraintCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropCheckConstraint' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly constraintName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, constraintName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.constraintName = constraintName;\n this.label = `Drop check constraint \"${constraintName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropCheckConstraintCall.toOp: a lowerer is required on the Postgres planner path (constraint \"${this.constraintName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropCheckConstraint(this.schemaName, this.tableName, this.constraintName, lowerer);\n }\n\n renderTypeScript(): string {\n return `this.dropCheckConstraint({ ${constraintCallOptions(this.schemaName, this.tableName, this.constraintName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Indexes\n// ============================================================================\n\nexport class CreateIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createIndex' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly columns: readonly string[];\n // Named indexType (not typeName): `locationForCall` in issue-planner.ts reads\n // a call's `typeName` as a CREATE TYPE target location, which an index is not.\n readonly indexType: string | undefined;\n readonly options: Record<string, unknown> | undefined;\n readonly label: string;\n\n constructor(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: { readonly type?: string; readonly options?: Record<string, unknown> },\n ) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.columns = columns;\n this.indexType = extras?.type;\n this.options = extras?.options;\n this.label = `Create index \"${indexName}\" on \"${tableName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateIndexCall.toOp: a lowerer is required on the Postgres planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (this.indexType !== undefined) extras.type = this.indexType;\n if (this.options !== undefined) extras.options = this.options;\n return createIndex(\n this.schemaName,\n this.tableName,\n this.indexName,\n this.columns,\n lowerer,\n extras,\n );\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`index: ${jsonToTsSource(this.indexName)}`);\n opts.push(`columns: ${jsonToTsSource(this.columns)}`);\n if (this.indexType !== undefined || this.options !== undefined) {\n const extrasParts: string[] = [];\n if (this.indexType !== undefined) extrasParts.push(`type: ${jsonToTsSource(this.indexType)}`);\n if (this.options !== undefined) extrasParts.push(`options: ${jsonToTsSource(this.options)}`);\n opts.push(`extras: { ${extrasParts.join(', ')} }`);\n }\n return `this.createIndex({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\nexport class DropIndexCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dropIndex' as const;\n readonly operationClass = 'destructive' as const;\n readonly schemaName: string;\n readonly tableName: string;\n readonly indexName: string;\n readonly label: string;\n\n constructor(schemaName: string, tableName: string, indexName: string) {\n super();\n this.schemaName = schemaName;\n this.tableName = tableName;\n this.indexName = indexName;\n this.label = `Drop index \"${indexName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `DropIndexCall.toOp: a lowerer is required on the Postgres planner path (index \"${this.indexName}\" on table \"${this.tableName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n return dropIndex(this.schemaName, this.tableName, this.indexName, lowerer);\n }\n\n renderTypeScript(): string {\n const opts: string[] = [];\n if (this.schemaName !== UNBOUND_NAMESPACE_ID) {\n opts.push(`schema: ${jsonToTsSource(this.schemaName)}`);\n }\n opts.push(`table: ${jsonToTsSource(this.tableName)}`);\n opts.push(`index: ${jsonToTsSource(this.indexName)}`);\n return `this.dropIndex({ ${opts.join(', ')} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// Raw SQL\n// ============================================================================\n\n/**\n * Laundered pre-built operation.\n *\n * Wraps an already-materialized `SqlMigrationPlanOperation` — typically one\n * produced by a SQL-family method or a codec control hook — so the planner\n * can carry it alongside IR nodes without reverse-engineering it into a\n * structured call class. Doubles as the user-facing escape hatch for raw\n * migrations: authors can pass a full op shape to `rawSql({...})`.\n *\n * `toOp()` returns the stored op unchanged. `renderTypeScript()` emits\n * `rawSql({...})` with the op serialized as a JSON literal — round-tripping\n * requires every field on the op to be JSON-serializable (no closures).\n */\nexport class RawSqlCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'rawSql' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly op: Op;\n\n constructor(op: Op) {\n super();\n this.op = op;\n this.label = op.label;\n this.operationClass = op.operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n return this.op;\n }\n\n renderTypeScript(): string {\n return `rawSql(${jsonToTsSource(this.op)})`;\n }\n}\n\n// ============================================================================\n// Database dependencies (structured DDL)\n// ============================================================================\n\nexport class CreateExtensionCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createExtension' as const;\n readonly operationClass = 'additive' as const;\n readonly extensionName: string;\n readonly label: string;\n\n constructor(extensionName: string) {\n super();\n this.extensionName = extensionName;\n this.label = `Create extension \"${extensionName}\"`;\n this.freeze();\n }\n\n toOp(): Op {\n return createExtension(this.extensionName);\n }\n\n renderTypeScript(): string {\n return `createExtension(${jsonToTsSource(this.extensionName)})`;\n }\n}\n\nexport class CreateSchemaCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'createSchema' as const;\n readonly operationClass = 'additive' as const;\n readonly schemaName: string;\n readonly label: string;\n\n constructor(schemaName: string) {\n super();\n this.schemaName = schemaName;\n this.label = `Create schema \"${schemaName}\"`;\n this.freeze();\n }\n\n async toOp(lowerer?: ExecuteRequestLowerer): Promise<Op> {\n if (lowerer === undefined) {\n throw new Error(\n `CreateSchemaCall.toOp: a DDL lowerer is required on the Postgres planner path (schema \"${this.schemaName}\"). Pass the control adapter to createPostgresMigrationPlanner.`,\n );\n }\n const ddlNode = contractFreeDdl.createSchema({ schema: this.schemaName, ifNotExists: true });\n const statement = await lowerer.lowerToExecuteRequest(ddlNode);\n const schemaName = this.schemaName;\n return {\n id: `schema.${schemaName}`,\n label: `Create schema \"${schemaName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n {\n description: `Create schema \"${schemaName}\"`,\n sql: statement.sql,\n params: statement.params ?? [],\n },\n ],\n postcheck: [],\n };\n }\n\n renderTypeScript(): string {\n return `this.createSchema({ schema: ${jsonToTsSource(this.schemaName)} })`;\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [];\n }\n}\n\n// ============================================================================\n// 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 * `PN-MIG-2001`: the planner cannot lower a stubbed transform to a runtime\n * op — the user must fill the rendered `migration.ts` and re-emit.\n */\nexport class DataTransformCall extends PostgresOpFactoryCallNode {\n readonly factoryName = 'dataTransform' as const;\n readonly operationClass: MigrationOperationClass;\n readonly label: string;\n readonly checkSlot: string;\n readonly runSlot: string;\n\n constructor(\n label: string,\n checkSlot: string,\n runSlot: string,\n operationClass: MigrationOperationClass = 'data',\n ) {\n super();\n this.label = label;\n this.checkSlot = checkSlot;\n this.runSlot = runSlot;\n this.operationClass = operationClass;\n this.freeze();\n }\n\n toOp(): Op {\n throw errorUnfilledPlaceholder(this.label);\n }\n\n renderTypeScript(): string {\n return [\n `this.dataTransform(endContract, ${jsonToTsSource(this.label)}, {`,\n ` check: () => placeholder(${jsonToTsSource(this.checkSlot)}),`,\n ` run: () => placeholder(${jsonToTsSource(this.runSlot)}),`,\n '})',\n ].join('\\n');\n }\n\n override importRequirements(): readonly ImportRequirement[] {\n return [\n { moduleSpecifier: POSTGRES_MIGRATION_FACADE, symbol: 'placeholder' },\n {\n moduleSpecifier: './end-contract.json',\n symbol: 'endContract',\n kind: 'default',\n attributes: { type: 'json' },\n },\n ];\n }\n}\n\nexport 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 | DataTransformCall;\n"],"mappings":";;;;;;;;;;;;AA4CA,SAAgB,KAAK,aAAqB,KAAa,QAA6B;CAClF,OAAO;EAAE;EAAa;EAAK,GAAG,UAAU,UAAU,MAAM;CAAE;AAC5D;AAEA,SAAgB,cACd,YACA,MACA,QACA,OAC0E;CAC1E,OAAO;EACL,IAAI;EACJ,SAAS;GAAE;GAAQ;GAAY;GAAM,GAAG,UAAU,SAAS,KAAK;EAAE;CACpE;AACF;;;AC3CA,eAAe,kBACb,SACA,SACoD;CACpD,MAAM,SAAS,gBAAgB,OAAO;CAGtC,OAAO;EAAE,SAAA,MAFa,QAAQ,sBAAsB,OAAO,cAAc,CAAC;EAExD,QAAA,MADG,QAAQ,sBAAsB,OAAO,aAAa,CAAC;CAC/C;AAC3B;AAEA,eAAsB,WACpB,YACA,WACA,YACA,SACa;CACb,MAAM,YAAY,iBAAiB,YAAY,SAAS;CACxD,MAAM,EAAE,SAAS,WAAW,MAAM,kBAAkB,SAAS;EAC3D,QAAQ;EACR,OAAO;EACP,QAAQ;CACV,CAAC;CACD,OAAO;EACL,IAAI,cAAc,UAAU,GAAG;EAC/B,OAAO,gBAAgB,WAAW,UAAU,UAAU;EACtD,gBAAgB;EAChB,QAAQ,cAAc,UAAU,YAAY,YAAY,SAAS;EACjE,UAAU,CAAC,KAAK,kBAAkB,WAAW,WAAW,QAAQ,KAAK,QAAQ,MAAM,CAAC;EACpF,SAAS,CACP,KACE,gBAAgB,WAAW,IAC3B,eAAe,UAAU,eAAe,gBAAgB,UAAU,GACpE,CACF;EACA,W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B,eAAe,KAAK,SAAS,EAAE;GAC7D,4BAA4B,eAAe,KAAK,OAAO,EAAE;GACzD;EACF,CAAC,CAAC,KAAK,IAAI;CACb;CAEA,qBAA4D;EAC1D,OAAO,CACL;GAAE,iBAAiB;GAA2B,QAAQ;EAAc,GACpE;GACE,iBAAiB;GACjB,QAAQ;GACR,MAAM;GACN,YAAY,EAAE,MAAM,OAAO;EAC7B,CACF;CACF;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"op-factory-call-DmQEc3XV.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/op-factory-call.ts"],"mappings":";;;;;;;;;KAMY,IAAA,GAAK,yBAAyB,CAAC,yBAAA;;;;;;UA0B1B,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAiB;AAAA;;;KC4BlC,EAAA,GAAK,yBAAyB,CAAC,yBAAA;AAAA,uBAoBrB,yBAAA,SAAkC,YAAA,YAAwB,aAAA;EAAA,kBACrD,WAAA;EAAA,kBACA,cAAA,EAAgB,uBAAA;EAAA,kBAChB,KAAA;EAAA,SACT,IAAA,CAAK,OAAA,GAAU,OAAA,GAAU,EAAA,GAAK,OAAA,CAAQ,EAAA;EAE/C,kBAAA,aAA+B,iBAAA;EAAA,UAIrB,MAAA;AAAA;AAAA,
|
|
1
|
+
{"version":3,"file":"op-factory-call-DmQEc3XV.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts","../src/core/migrations/op-factory-call.ts"],"mappings":";;;;;;;;;KAMY,IAAA,GAAK,yBAAyB,CAAC,yBAAA;;;;;;UA0B1B,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,MAAA;IAAA,SACA,KAAA;IAAA,SACA,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ACA,cAAA,EAAgB,uBAAA;EAAA,SAChB,KAAA;EAAA,SACA,SAAA;EAAA,SACA,OAAA;cAGP,KAAA,UACA,SAAA,UACA,OAAA,UACA,cAAA,GAAgB,uBAAA;EAUlB,IAAA,IAAQ,EAAA;EAIR,gBAAA;EASS,kBAAA,aAA+B,iBAAA;AAAA;AAAA,KAa9B,qBAAA,GACR,eAAA,GACA,aAAA,GACA,aAAA,GACA,cAAA,GACA,mBAAA,GACA,cAAA,GACA,eAAA,GACA,cAAA,GACA,eAAA,GACA,0BAAA,GACA,mCAAA,GACA,iBAAA,GACA,iBAAA,GACA,aAAA,GACA,sBAAA,GACA,uBAAA,GACA,eAAA,GACA,aAAA,GACA,kBAAA,GACA,UAAA,GACA,mBAAA,GACA,gBAAA,GACA,iBAAA"}
|
package/dist/op-factory-call.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { C as SetNotNullCall, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, l as CreateExtensionCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as DataTransformCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, x as RawSqlCall, y as DropNotNullCall } from "./op-factory-call-
|
|
1
|
+
import { C as SetNotNullCall, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, l as CreateExtensionCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, p as DataTransformCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, x as RawSqlCall, y as DropNotNullCall } from "./op-factory-call-D_p5vxwt.mjs";
|
|
2
2
|
export { AddCheckConstraintCall, AddColumnCall, AddForeignKeyCall, AddPrimaryKeyCall, AddUniqueCall, AlterColumnTypeCall, CreateExtensionCall, CreateIndexCall, CreateSchemaCall, CreateTableCall, DataTransformCall, DropCheckConstraintCall, DropColumnCall, DropConstraintCall, DropDefaultCall, DropIndexCall, DropNotNullCall, DropTableCall, RawSqlCall, SetDefaultCall, SetNotNullCall };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as parsePostgresDefault } from "./default-normalizer-DyyCHQWs.mjs";
|
|
2
2
|
import { t as normalizeSchemaNativeType } from "./native-type-normalizer-Bc9XJzWC.mjs";
|
|
3
3
|
import { r as isPostgresSchema } from "./postgres-schema-COGZ1ark.mjs";
|
|
4
|
-
import { n as postgresPlannerStrategies, t as planIssues } from "./issue-planner-
|
|
5
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
4
|
+
import { n as postgresPlannerStrategies, t as planIssues } from "./issue-planner-DL6g3CmE.mjs";
|
|
5
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Cji5vxUf.mjs";
|
|
6
6
|
import { blindCast } from "@prisma-next/utils/casts";
|
|
7
7
|
import { extractCodecControlHooks, partitionCallsByControlPolicy, partitionIssuesByControlPolicy, planFieldEventOperations, plannerFailure } from "@prisma-next/family-sql/control";
|
|
8
8
|
import { ifDefined } from "@prisma-next/utils/defined";
|
|
@@ -321,4 +321,4 @@ var PostgresMigrationPlanner = class {
|
|
|
321
321
|
//#endregion
|
|
322
322
|
export { createPostgresMigrationPlanner as t };
|
|
323
323
|
|
|
324
|
-
//# sourceMappingURL=planner-
|
|
324
|
+
//# sourceMappingURL=planner-Bs_baQax.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-DS5XBhmi.mjs","names":["#lowerer"],"sources":["../src/core/migrations/control-policy.ts","../src/core/migrations/verify-postgres-namespaces.ts","../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { ControlPolicySubject } from '@prisma-next/family-sql/control';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { entityAt, UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { isPostgresSchema } from '../postgres-schema';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\n\n/**\n * Factory calls that create a whole, previously-absent top-level storage\n * object. Used to decide whether `tolerated` permits a call (it only allows\n * creating absent objects, never modifying existing ones).\n *\n * Deliberately an explicit, closed set rather than a `factoryName`\n * create/alter/drop classification: it answers exactly one yes/no question\n * and is fail-closed. Any call not listed here — including future or\n * extension-contributed factories — is treated as NOT object-creation, so it\n * is suppressed under `tolerated` rather than permissively emitted.\n */\nconst OBJECT_CREATION_FACTORIES: ReadonlySet<string> = new Set<string>([\n 'createTable',\n 'createSchema',\n]);\n\nfunction createsNewTopLevelObject(call: PostgresOpFactoryCall): boolean {\n return OBJECT_CREATION_FACTORIES.has(call.factoryName);\n}\n\nfunction ddlSchemaNameForNamespace(contract: Contract<SqlStorage>, namespaceId: string): string {\n const namespace = contract.storage.namespaces[namespaceId];\n return isPostgresSchema(namespace) ? namespace.ddlSchemaName(contract.storage) : namespaceId;\n}\n\nfunction resolveNamespaceIdForTable(\n contract: Contract<SqlStorage>,\n tableName: string,\n ddlSchemaName: string | undefined,\n): string {\n for (const namespaceId of Object.keys(contract.storage.namespaces)) {\n const table = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: tableName,\n });\n if (!table) continue;\n if (\n ddlSchemaName === undefined ||\n ddlSchemaNameForNamespace(contract, namespaceId) === ddlSchemaName\n ) {\n return namespaceId;\n }\n }\n return UNBOUND_NAMESPACE_ID;\n}\n\nfunction resolveNamespaceIdForDdlSchema(\n contract: Contract<SqlStorage>,\n ddlSchemaName: string,\n): string {\n for (const namespaceId of Object.keys(contract.storage.namespaces)) {\n const ns = contract.storage.namespaces[namespaceId];\n if (isPostgresSchema(ns) && ns.ddlSchemaName(contract.storage) === ddlSchemaName) {\n return namespaceId;\n }\n if (namespaceId === ddlSchemaName) {\n return namespaceId;\n }\n }\n return UNBOUND_NAMESPACE_ID;\n}\n\ninterface PostgresCallFields {\n readonly schemaName?: string;\n readonly tableName?: string;\n readonly columnName?: string;\n}\n\nfunction postgresCallFields(call: PostgresOpFactoryCall): PostgresCallFields {\n return {\n ...ifDefined('schemaName', 'schemaName' in call ? call.schemaName : undefined),\n ...ifDefined('tableName', 'tableName' in call ? call.tableName : undefined),\n ...ifDefined('columnName', 'columnName' in call ? call.columnName : undefined),\n };\n}\n\nexport function formatPostgresControlPolicySubjectLabel(\n factoryName: string,\n subject: ControlPolicySubject | undefined,\n contract: Contract<SqlStorage>,\n): string {\n if (subject?.table) {\n const ddlSchema = ddlSchemaNameForNamespace(contract, subject.namespaceId);\n return `${factoryName}(${ddlSchema}.${subject.table})`;\n }\n return factoryName;\n}\n\nexport function resolvePostgresCallControlPolicySubject(\n call: PostgresOpFactoryCall,\n contract: Contract<SqlStorage>,\n): ControlPolicySubject | undefined {\n const callFields = postgresCallFields(call);\n const createsNewObject = createsNewTopLevelObject(call);\n\n if (call.factoryName === 'createSchema' && callFields.schemaName) {\n return {\n namespaceId: resolveNamespaceIdForDdlSchema(contract, callFields.schemaName),\n createsNewObject,\n };\n }\n\n if (callFields.tableName) {\n const namespaceId = resolveNamespaceIdForTable(\n contract,\n callFields.tableName,\n callFields.schemaName,\n );\n const tableControlPolicy = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: callFields.tableName,\n })?.control;\n return {\n namespaceId,\n ...ifDefined('explicitNodeControlPolicy', tableControlPolicy),\n table: callFields.tableName,\n ...ifDefined('column', callFields.columnName),\n createsNewObject,\n };\n }\n\n if (callFields.schemaName) {\n return {\n namespaceId: resolveNamespaceIdForDdlSchema(contract, callFields.schemaName),\n createsNewObject,\n };\n }\n\n return undefined;\n}\n\n/**\n * Issue kinds that describe the absence of a whole, top-level Postgres\n * object — the same kinds `createsNewTopLevelObject` recognises for calls.\n * Used by {@link resolvePostgresIssueCreationFactoryName} to decide whether\n * a `tolerated` subject permits the issue to flow into the planner\n * (create-if-absent) and to seed the suppressed-subject warning's\n * `factoryName` when the planner is skipped.\n */\nconst POSTGRES_ISSUE_CREATION_FACTORY: Readonly<Record<string, string>> = Object.freeze({\n missing_schema: 'createSchema',\n missing_table: 'createTable',\n});\n\nexport function resolvePostgresIssueCreationFactoryName(issue: SchemaIssue): string | undefined {\n return POSTGRES_ISSUE_CREATION_FACTORY[issue.kind];\n}\n\n/**\n * Resolve the control-policy subject coordinate for a single\n * {@link SchemaIssue}. Mirrors the resolution `resolvePostgresCallControlPolicySubject`\n * performs for a generated DDL call, but works *off the issue* — so the\n * planner can partition issues by effective policy before the diff engine\n * runs. `createsNewObject` is derived from the issue's kind: schema/table/\n * type-missing issues describe a brand-new top-level object; everything else\n * touches an existing object.\n *\n * An `extra_table` issue carries no contract namespace coordinate (the table\n * isn't in any contract namespace), so the subject's `namespaceId` falls\n * back to {@link UNBOUND_NAMESPACE_ID}; the call-side resolver does the same\n * for the `DropTableCall` it produces.\n */\nexport function resolvePostgresIssueControlPolicySubject(\n issue: SchemaIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicySubject | undefined {\n const createsNewObject = POSTGRES_ISSUE_CREATION_FACTORY[issue.kind] !== undefined;\n\n if (issue.kind === 'missing_schema' && issue.namespaceId) {\n return { namespaceId: issue.namespaceId, createsNewObject };\n }\n\n if ('table' in issue && issue.table) {\n const namespaceId =\n 'namespaceId' in issue && issue.namespaceId\n ? issue.namespaceId\n : resolveNamespaceIdForTable(contract, issue.table, undefined);\n const table = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: issue.table,\n });\n return {\n namespaceId,\n ...ifDefined('explicitNodeControlPolicy', table?.control),\n table: issue.table,\n ...ifDefined('column', 'column' in issue ? issue.column : undefined),\n createsNewObject,\n };\n }\n\n return undefined;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SchemaIssue } 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 { isPostgresSchema } from '../postgres-schema';\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 Postgres-flavoured\n * annotations slot on the schema IR. Defaults to the always-present\n * `public` schema when introspection did not populate the slot — a fresh\n * Postgres database always carries `public` (unless an operator dropped\n * it manually), so any verifier path that runs without an enriched\n * introspection still suppresses the redundant `CREATE SCHEMA \"public\"`.\n *\n * Production introspection (`PostgresControlAdapter.introspect`) is the\n * authoritative source: it queries `pg_namespace` and writes every\n * non-system schema into `annotations.pg.existingSchemas`. Tests that\n * want to assert against a richer initial state pass the slot\n * explicitly via the schema IR.\n */\nfunction existingSchemasFromSchema(schema: SqlSchemaIR): readonly string[] {\n const annotations = (schema as { annotations?: { pg?: { existingSchemas?: unknown } } })\n .annotations;\n const slot = annotations?.pg?.existingSchemas;\n if (Array.isArray(slot)) {\n return slot.filter((s): s is string => typeof s === 'string');\n }\n return ['public'];\n}\n\n/**\n * Emits a `missing_schema` issue for every contract-declared Postgres\n * namespace whose live container does not yet exist.\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 stamps `namespaceId` with the contract namespace\n * coordinate so the downstream `mapIssueToCall` re-resolves the DDL\n * schema name through the same polymorphic path — keeping the\n * coordinate, not the resolved name, as the issue's stable identity.\n */\nexport function verifyPostgresNamespacePresence(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIR;\n}): readonly SchemaIssue[] {\n const { contract, schema } = input;\n const existing = new Set(existingSchemasFromSchema(schema));\n const issues: SchemaIssue[] = [];\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 issues.push({\n kind: 'missing_schema',\n namespaceId,\n message: `Schema \"${ddlName}\" is missing from database`,\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 { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport {\n formatPostgresControlPolicySubjectLabel,\n resolvePostgresCallControlPolicySubject,\n resolvePostgresIssueControlPolicySubject,\n resolvePostgresIssueCreationFactoryName,\n} from './control-policy';\nimport { planIssues } from './issue-planner';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\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\ntype VerifySqlSchemaOptionsWithComponents = Parameters<typeof verifySqlSchema>[0] & {\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()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the unified\n * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,\n * type-change, nullable-tightening, codec-hook storage types,\n * component-declared dependency installs, and shared-temp-default /\n * empty-table-guarded NOT-NULL add-column. The same strategy list runs for\n * `migration plan`, `db update`, and `db init`; behavior diverges purely on\n * `policy.allowedOperationClasses` (the data-safe strategies short-circuit\n * when `'data'` is excluded). The issue planner applies operation-class\n * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both\n * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`\n * authoring surface.\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 }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n this.#lowerer,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName =\n options.schemaName ??\n Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ??\n UNBOUND_NAMESPACE_ID;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\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 resolvePostgresIssueControlPolicySubject(issue, options.contract),\n resolveCreationFactoryName: resolvePostgresIssueCreationFactoryName,\n formatSubjectLabel: (factoryName, subject) =>\n formatPostgresControlPolicySubjectLabel(factoryName, subject, options.contract),\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 // `mapIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract,\n schemaName,\n codecHooks,\n storageTypes,\n schema: options.schema,\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 // 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 formatSubjectLabel: (factoryName, subject) =>\n formatPostgresControlPolicySubjectLabel(factoryName, subject, options.contract),\n });\n const calls = [...result.value.calls, ...fieldEventPartition.kept];\n const warnings: SqlPlannerConflict[] = [\n ...issuePartition.warnings,\n ...fieldEventPartition.warnings,\n ];\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n this.#lowerer,\n ),\n ...(warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}),\n });\n }\n\n 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 private collectSchemaIssues(options: PlannerOptionsWithComponents): readonly SchemaIssue[] {\n // `db init` uses additive-only policy and intentionally ignores extra\n // schema objects. Any reconciliation-capable policy (widening or\n // destructive) must inspect extras to reconcile strict equality.\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyOptions: VerifySqlSchemaOptionsWithComponents = {\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parsePostgresDefault,\n normalizeNativeType: normalizeSchemaNativeType,\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n // Schema presence is a Postgres-specific concern (no equivalent in\n // SQLite / Mongo), so the issue emission lives in the target layer\n // rather than in the family verifier. Stitch it in here so a single\n // `SchemaIssue[]` flows through `planIssues` and the planner emits\n // CREATE SCHEMA in the dep bucket before any CreateTableCall.\n const namespaceIssues = verifyPostgresNamespacePresence({\n contract: options.contract,\n schema: options.schema,\n });\n if (namespaceIssues.length === 0) {\n return verifyResult.schema.issues;\n }\n return [...namespaceIssues, ...verifyResult.schema.issues];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,4BAAiD,IAAI,IAAY,CACrE,eACA,cACF,CAAC;AAED,SAAS,yBAAyB,MAAsC;CACtE,OAAO,0BAA0B,IAAI,KAAK,WAAW;AACvD;AAEA,SAAS,0BAA0B,UAAgC,aAA6B;CAC9F,MAAM,YAAY,SAAS,QAAQ,WAAW;CAC9C,OAAO,iBAAiB,SAAS,IAAI,UAAU,cAAc,SAAS,OAAO,IAAI;AACnF;AAEA,SAAS,2BACP,UACA,WACA,eACQ;CACR,KAAK,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,GAAG;EAMlE,IAAI,CALU,SAAuB,SAAS,SAAS;GACrD;GACA,YAAY;GACZ,YAAY;EACd,CACS,GAAG;EACZ,IACE,kBAAkB,KAAA,KAClB,0BAA0B,UAAU,WAAW,MAAM,eAErD,OAAO;CAEX;CACA,OAAO;AACT;AAEA,SAAS,+BACP,UACA,eACQ;CACR,KAAK,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,GAAG;EAClE,MAAM,KAAK,SAAS,QAAQ,WAAW;EACvC,IAAI,iBAAiB,EAAE,KAAK,GAAG,cAAc,SAAS,OAAO,MAAM,eACjE,OAAO;EAET,IAA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AAO;EAE7B,OAAO,CAAC,GAAG,iBAAiB,GAAG,aAAa,OAAO,MAAM;CAC3D;AACF"}
|
|
1
|
+
{"version":3,"file":"planner-Bs_baQax.mjs","names":["#lowerer"],"sources":["../src/core/migrations/control-policy.ts","../src/core/migrations/verify-postgres-namespaces.ts","../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type { ControlPolicySubject } from '@prisma-next/family-sql/control';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport { entityAt, UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport type { SqlStorage, StorageTable } from '@prisma-next/sql-contract/types';\nimport { ifDefined } from '@prisma-next/utils/defined';\nimport { isPostgresSchema } from '../postgres-schema';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\n\n/**\n * Factory calls that create a whole, previously-absent top-level storage\n * object. Used to decide whether `tolerated` permits a call (it only allows\n * creating absent objects, never modifying existing ones).\n *\n * Deliberately an explicit, closed set rather than a `factoryName`\n * create/alter/drop classification: it answers exactly one yes/no question\n * and is fail-closed. Any call not listed here — including future or\n * extension-contributed factories — is treated as NOT object-creation, so it\n * is suppressed under `tolerated` rather than permissively emitted.\n */\nconst OBJECT_CREATION_FACTORIES: ReadonlySet<string> = new Set<string>([\n 'createTable',\n 'createSchema',\n]);\n\nfunction createsNewTopLevelObject(call: PostgresOpFactoryCall): boolean {\n return OBJECT_CREATION_FACTORIES.has(call.factoryName);\n}\n\nfunction ddlSchemaNameForNamespace(contract: Contract<SqlStorage>, namespaceId: string): string {\n const namespace = contract.storage.namespaces[namespaceId];\n return isPostgresSchema(namespace) ? namespace.ddlSchemaName(contract.storage) : namespaceId;\n}\n\nfunction resolveNamespaceIdForTable(\n contract: Contract<SqlStorage>,\n tableName: string,\n ddlSchemaName: string | undefined,\n): string {\n for (const namespaceId of Object.keys(contract.storage.namespaces)) {\n const table = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: tableName,\n });\n if (!table) continue;\n if (\n ddlSchemaName === undefined ||\n ddlSchemaNameForNamespace(contract, namespaceId) === ddlSchemaName\n ) {\n return namespaceId;\n }\n }\n return UNBOUND_NAMESPACE_ID;\n}\n\nfunction resolveNamespaceIdForDdlSchema(\n contract: Contract<SqlStorage>,\n ddlSchemaName: string,\n): string {\n for (const namespaceId of Object.keys(contract.storage.namespaces)) {\n const ns = contract.storage.namespaces[namespaceId];\n if (isPostgresSchema(ns) && ns.ddlSchemaName(contract.storage) === ddlSchemaName) {\n return namespaceId;\n }\n if (namespaceId === ddlSchemaName) {\n return namespaceId;\n }\n }\n return UNBOUND_NAMESPACE_ID;\n}\n\ninterface PostgresCallFields {\n readonly schemaName?: string;\n readonly tableName?: string;\n readonly columnName?: string;\n}\n\nfunction postgresCallFields(call: PostgresOpFactoryCall): PostgresCallFields {\n return {\n ...ifDefined('schemaName', 'schemaName' in call ? call.schemaName : undefined),\n ...ifDefined('tableName', 'tableName' in call ? call.tableName : undefined),\n ...ifDefined('columnName', 'columnName' in call ? call.columnName : undefined),\n };\n}\n\nexport function formatPostgresControlPolicySubjectLabel(\n factoryName: string,\n subject: ControlPolicySubject | undefined,\n contract: Contract<SqlStorage>,\n): string {\n if (subject?.table) {\n const ddlSchema = ddlSchemaNameForNamespace(contract, subject.namespaceId);\n return `${factoryName}(${ddlSchema}.${subject.table})`;\n }\n return factoryName;\n}\n\nexport function resolvePostgresCallControlPolicySubject(\n call: PostgresOpFactoryCall,\n contract: Contract<SqlStorage>,\n): ControlPolicySubject | undefined {\n const callFields = postgresCallFields(call);\n const createsNewObject = createsNewTopLevelObject(call);\n\n if (call.factoryName === 'createSchema' && callFields.schemaName) {\n return {\n namespaceId: resolveNamespaceIdForDdlSchema(contract, callFields.schemaName),\n createsNewObject,\n };\n }\n\n if (callFields.tableName) {\n const namespaceId = resolveNamespaceIdForTable(\n contract,\n callFields.tableName,\n callFields.schemaName,\n );\n const tableControlPolicy = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: callFields.tableName,\n })?.control;\n return {\n namespaceId,\n ...ifDefined('explicitNodeControlPolicy', tableControlPolicy),\n table: callFields.tableName,\n ...ifDefined('column', callFields.columnName),\n createsNewObject,\n };\n }\n\n if (callFields.schemaName) {\n return {\n namespaceId: resolveNamespaceIdForDdlSchema(contract, callFields.schemaName),\n createsNewObject,\n };\n }\n\n return undefined;\n}\n\n/**\n * Issue kinds that describe the absence of a whole, top-level Postgres\n * object — the same kinds `createsNewTopLevelObject` recognises for calls.\n * Used by {@link resolvePostgresIssueCreationFactoryName} to decide whether\n * a `tolerated` subject permits the issue to flow into the planner\n * (create-if-absent) and to seed the suppressed-subject warning's\n * `factoryName` when the planner is skipped.\n */\nconst POSTGRES_ISSUE_CREATION_FACTORY: Readonly<Record<string, string>> = Object.freeze({\n missing_schema: 'createSchema',\n missing_table: 'createTable',\n});\n\nexport function resolvePostgresIssueCreationFactoryName(issue: SchemaIssue): string | undefined {\n return POSTGRES_ISSUE_CREATION_FACTORY[issue.kind];\n}\n\n/**\n * Resolve the control-policy subject coordinate for a single\n * {@link SchemaIssue}. Mirrors the resolution `resolvePostgresCallControlPolicySubject`\n * performs for a generated DDL call, but works *off the issue* — so the\n * planner can partition issues by effective policy before the diff engine\n * runs. `createsNewObject` is derived from the issue's kind: schema/table/\n * type-missing issues describe a brand-new top-level object; everything else\n * touches an existing object.\n *\n * An `extra_table` issue carries no contract namespace coordinate (the table\n * isn't in any contract namespace), so the subject's `namespaceId` falls\n * back to {@link UNBOUND_NAMESPACE_ID}; the call-side resolver does the same\n * for the `DropTableCall` it produces.\n */\nexport function resolvePostgresIssueControlPolicySubject(\n issue: SchemaIssue,\n contract: Contract<SqlStorage>,\n): ControlPolicySubject | undefined {\n const createsNewObject = POSTGRES_ISSUE_CREATION_FACTORY[issue.kind] !== undefined;\n\n if (issue.kind === 'missing_schema' && issue.namespaceId) {\n return { namespaceId: issue.namespaceId, createsNewObject };\n }\n\n if ('table' in issue && issue.table) {\n const namespaceId =\n 'namespaceId' in issue && issue.namespaceId\n ? issue.namespaceId\n : resolveNamespaceIdForTable(contract, issue.table, undefined);\n const table = entityAt<StorageTable>(contract.storage, {\n namespaceId,\n entityKind: 'table',\n entityName: issue.table,\n });\n return {\n namespaceId,\n ...ifDefined('explicitNodeControlPolicy', table?.control),\n table: issue.table,\n ...ifDefined('column', 'column' in issue ? issue.column : undefined),\n createsNewObject,\n };\n }\n\n return undefined;\n}\n","import type { Contract } from '@prisma-next/contract/types';\nimport type { SchemaIssue } 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 { isPostgresSchema } from '../postgres-schema';\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 Postgres-flavoured\n * annotations slot on the schema IR. Defaults to the always-present\n * `public` schema when introspection did not populate the slot — a fresh\n * Postgres database always carries `public` (unless an operator dropped\n * it manually), so any verifier path that runs without an enriched\n * introspection still suppresses the redundant `CREATE SCHEMA \"public\"`.\n *\n * Production introspection (`PostgresControlAdapter.introspect`) is the\n * authoritative source: it queries `pg_namespace` and writes every\n * non-system schema into `annotations.pg.existingSchemas`. Tests that\n * want to assert against a richer initial state pass the slot\n * explicitly via the schema IR.\n */\nfunction existingSchemasFromSchema(schema: SqlSchemaIR): readonly string[] {\n const annotations = (schema as { annotations?: { pg?: { existingSchemas?: unknown } } })\n .annotations;\n const slot = annotations?.pg?.existingSchemas;\n if (Array.isArray(slot)) {\n return slot.filter((s): s is string => typeof s === 'string');\n }\n return ['public'];\n}\n\n/**\n * Emits a `missing_schema` issue for every contract-declared Postgres\n * namespace whose live container does not yet exist.\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 stamps `namespaceId` with the contract namespace\n * coordinate so the downstream `mapIssueToCall` re-resolves the DDL\n * schema name through the same polymorphic path — keeping the\n * coordinate, not the resolved name, as the issue's stable identity.\n */\nexport function verifyPostgresNamespacePresence(input: {\n readonly contract: Contract<SqlStorage>;\n readonly schema: SqlSchemaIR;\n}): readonly SchemaIssue[] {\n const { contract, schema } = input;\n const existing = new Set(existingSchemasFromSchema(schema));\n const issues: SchemaIssue[] = [];\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 issues.push({\n kind: 'missing_schema',\n namespaceId,\n message: `Schema \"${ddlName}\" is missing from database`,\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 { verifySqlSchema } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type {\n MigrationPlanner,\n MigrationPlanWithAuthoringSurface,\n MigrationScaffoldContext,\n SchemaIssue,\n} from '@prisma-next/framework-components/control';\nimport { UNBOUND_NAMESPACE_ID } from '@prisma-next/framework-components/ir';\nimport { blindCast } from '@prisma-next/utils/casts';\nimport { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport {\n formatPostgresControlPolicySubjectLabel,\n resolvePostgresCallControlPolicySubject,\n resolvePostgresIssueControlPolicySubject,\n resolvePostgresIssueCreationFactoryName,\n} from './control-policy';\nimport { planIssues } from './issue-planner';\nimport type { PostgresOpFactoryCall } from './op-factory-call';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\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\ntype VerifySqlSchemaOptionsWithComponents = Parameters<typeof verifySqlSchema>[0] & {\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()` verifies the live schema against the target contract (producing\n * `SchemaIssue[]`) and delegates to `planIssues` with the unified\n * `postgresPlannerStrategies` list: enum-change, NOT-NULL backfill,\n * type-change, nullable-tightening, codec-hook storage types,\n * component-declared dependency installs, and shared-temp-default /\n * empty-table-guarded NOT-NULL add-column. The same strategy list runs for\n * `migration plan`, `db update`, and `db init`; behavior diverges purely on\n * `policy.allowedOperationClasses` (the data-safe strategies short-circuit\n * when `'data'` is excluded). The issue planner applies operation-class\n * policy gates and emits a single `PostgresOpFactoryCall[]` that drives both\n * the runtime-ops view (via `renderOps`) and the `renderTypeScript()`\n * authoring surface.\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 }): PostgresPlanResult {\n return this.planSql(options as SqlMigrationPlannerPlanOptions);\n }\n\n emptyMigration(\n context: MigrationScaffoldContext,\n spaceId: string,\n ): MigrationPlanWithAuthoringSurface {\n return new TypeScriptRenderablePostgresMigration(\n [],\n {\n from: context.fromHash,\n to: context.toHash,\n },\n spaceId,\n this.#lowerer,\n );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName =\n options.schemaName ??\n Object.keys(options.contract.storage.namespaces).find((id) => id !== UNBOUND_NAMESPACE_ID) ??\n UNBOUND_NAMESPACE_ID;\n const policyResult = this.ensureAdditivePolicy(options.policy);\n if (policyResult) {\n return policyResult;\n }\n\n const schemaIssues = this.collectSchemaIssues(options);\n const codecHooks = extractCodecControlHooks(options.frameworkComponents);\n const storageTypes = options.contract.storage.types ?? {};\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 resolvePostgresIssueControlPolicySubject(issue, options.contract),\n resolveCreationFactoryName: resolvePostgresIssueCreationFactoryName,\n formatSubjectLabel: (factoryName, subject) =>\n formatPostgresControlPolicySubjectLabel(factoryName, subject, options.contract),\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 // `mapIssueToCall`'s direct destructive handlers.\n fromContract: options.fromContract,\n schemaName,\n codecHooks,\n storageTypes,\n schema: options.schema,\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 // 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 formatSubjectLabel: (factoryName, subject) =>\n formatPostgresControlPolicySubjectLabel(factoryName, subject, options.contract),\n });\n const calls = [...result.value.calls, ...fieldEventPartition.kept];\n const warnings: SqlPlannerConflict[] = [\n ...issuePartition.warnings,\n ...fieldEventPartition.warnings,\n ];\n\n return Object.freeze({\n kind: 'success' as const,\n plan: new TypeScriptRenderablePostgresMigration(\n calls,\n {\n from: options.fromContract?.storage.storageHash ?? null,\n to: options.contract.storage.storageHash,\n },\n options.spaceId,\n this.#lowerer,\n ),\n ...(warnings.length > 0 ? { warnings: Object.freeze(warnings) } : {}),\n });\n }\n\n 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 private collectSchemaIssues(options: PlannerOptionsWithComponents): readonly SchemaIssue[] {\n // `db init` uses additive-only policy and intentionally ignores extra\n // schema objects. Any reconciliation-capable policy (widening or\n // destructive) must inspect extras to reconcile strict equality.\n const allowed = options.policy.allowedOperationClasses;\n const strict = allowed.includes('widening') || allowed.includes('destructive');\n const verifyOptions: VerifySqlSchemaOptionsWithComponents = {\n contract: options.contract,\n schema: options.schema,\n strict,\n typeMetadataRegistry: new Map(),\n frameworkComponents: options.frameworkComponents,\n normalizeDefault: parsePostgresDefault,\n normalizeNativeType: normalizeSchemaNativeType,\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n // Schema presence is a Postgres-specific concern (no equivalent in\n // SQLite / Mongo), so the issue emission lives in the target layer\n // rather than in the family verifier. Stitch it in here so a single\n // `SchemaIssue[]` flows through `planIssues` and the planner emits\n // CREATE SCHEMA in the dep bucket before any CreateTableCall.\n const namespaceIssues = verifyPostgresNamespacePresence({\n contract: options.contract,\n schema: options.schema,\n });\n if (namespaceIssues.length === 0) {\n return verifyResult.schema.issues;\n }\n return [...namespaceIssues, ...verifyResult.schema.issues];\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAoBA,MAAM,4BAAiD,IAAI,IAAY,CACrE,eACA,cACF,CAAC;AAED,SAAS,yBAAyB,MAAsC;CACtE,OAAO,0BAA0B,IAAI,KAAK,WAAW;AACvD;AAEA,SAAS,0BAA0B,UAAgC,aAA6B;CAC9F,MAAM,YAAY,SAAS,QAAQ,WAAW;CAC9C,OAAO,iBAAiB,SAAS,IAAI,UAAU,cAAc,SAAS,OAAO,IAAI;AACnF;AAEA,SAAS,2BACP,UACA,WACA,eACQ;CACR,KAAK,MAAM,eAAe,OAAO,KAAK,SAAS,QAAQ,UAAU,GAAG;EAMlE,IAAI,CALU,SAAuB,SAAS,SAAS;GACrD;GACA,YAAY;GACZ,YAAY;EACd,CACS,GAAG;EACZ,IACE,kBAAkB,KAAA,KAClB,0BAA0B,UAAU,WAAW,MAAM,eAErD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AAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,IAAI;GAC9B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;EAE0B,CAAC;EAMlD,MAAM,kBAAkB,gCAAgC;GACtD,UAAU,QAAQ;GAClB,QAAQ,QAAQ;EAClB,CAAC;EACD,IAAI,gBAAgB,WAAW,GAC7B,OAAO,aAAa,OAAO;EAE7B,OAAO,CAAC,GAAG,iBAAiB,GAAG,aAAa,OAAO,MAAM;CAC3D;AACF"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as PostgresMigration } from "./postgres-migration-
|
|
1
|
+
import { t as PostgresMigration } from "./postgres-migration-B5jKrXv3.mjs";
|
|
2
2
|
import { t as renderOps } from "./render-ops-BREh1kHe.mjs";
|
|
3
3
|
import { t as renderCallsToTypeScript } from "./render-typescript-KMgosran.mjs";
|
|
4
4
|
//#region src/core/migrations/planner-produced-postgres-migration.ts
|
|
@@ -40,4 +40,4 @@ var TypeScriptRenderablePostgresMigration = class extends PostgresMigration {
|
|
|
40
40
|
//#endregion
|
|
41
41
|
export { TypeScriptRenderablePostgresMigration as t };
|
|
42
42
|
|
|
43
|
-
//# sourceMappingURL=planner-produced-postgres-migration-
|
|
43
|
+
//# sourceMappingURL=planner-produced-postgres-migration-Cji5vxUf.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"planner-produced-postgres-migration-
|
|
1
|
+
{"version":3,"file":"planner-produced-postgres-migration-Cji5vxUf.mjs","names":["#calls","#meta","#spaceId","#lowerer","#operationsCache"],"sources":["../src/core/migrations/planner-produced-postgres-migration.ts"],"sourcesContent":["/**\n * Planner-produced Postgres migration.\n *\n * Returned by `PostgresMigrationPlanner.plan(...)` and `emptyMigration(...)`.\n * Holds the migration IR (`PostgresOpFactoryCall[]`) alongside\n * `MigrationMeta` and exposes both the runtime-ops view (`get operations`)\n * and the TypeScript authoring view (`renderTypeScript()`). Satisfies\n * `MigrationPlanWithAuthoringSurface` so the CLI can uniformly serialize any\n * planner result back to `migration.ts`.\n *\n * Extends the family-level `SqlMigration` alias rather than the target-local\n * migration base directly — mirrors Mongo's `PlannerProducedMongoMigration`\n * shape and keeps CLI wiring one step removed from target internals.\n *\n * Placeholder-bearing plans: `renderTypeScript()` always succeeds and embeds\n * `() => placeholder(\"slot\")` at each stub. `operations`, in contrast, is\n * _not safe to enumerate_ on a stub-bearing plan — `DataTransformCall.toOp()`\n * throws `PN-MIG-2001` because a planner-stubbed closure cannot be lowered\n * to a runtime op. Callers that know a plan may carry stubs must render to\n * `migration.ts`, let the user fill the slots, and re-load the edited\n * migration before enumerating ops. The walk-schema planner does not emit\n * `DataTransformCall`s today, so this asymmetry is invisible until the\n * issue-planner integration lands in Phase 2.\n */\n\nimport type { SqlMigrationPlanOperation } from '@prisma-next/family-sql/control';\nimport type { ExecuteRequestLowerer } from '@prisma-next/family-sql/control-adapter';\nimport type {\n MigrationPlanWithAuthoringSurface,\n OpFactoryCall,\n} from '@prisma-next/framework-components/control';\nimport type { MigrationMeta } from '@prisma-next/migration-tools/migration';\nimport type { PostgresPlanTargetDetails } from './planner-target-details';\nimport { PostgresMigration } from './postgres-migration';\nimport { renderOps } from './render-ops';\nimport { renderCallsToTypeScript } from './render-typescript';\n\nexport class TypeScriptRenderablePostgresMigration\n extends PostgresMigration\n implements MigrationPlanWithAuthoringSurface\n{\n readonly #calls: readonly OpFactoryCall[];\n readonly #meta: MigrationMeta;\n readonly #spaceId: string;\n readonly #lowerer: ExecuteRequestLowerer | undefined;\n #operationsCache:\n | readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[]\n | undefined;\n\n constructor(\n calls: readonly OpFactoryCall[],\n meta: MigrationMeta,\n spaceId: string,\n lowerer?: ExecuteRequestLowerer,\n ) {\n super();\n this.#calls = calls;\n this.#meta = meta;\n this.#spaceId = spaceId;\n this.#lowerer = lowerer;\n }\n\n override get operations(): readonly (\n | SqlMigrationPlanOperation<PostgresPlanTargetDetails>\n | Promise<SqlMigrationPlanOperation<PostgresPlanTargetDetails>>\n )[] {\n this.#operationsCache ??= renderOps(this.#calls, this.#lowerer);\n return this.#operationsCache;\n }\n\n override describe(): MigrationMeta {\n return this.#meta;\n }\n\n /**\n * Contract space this planner-produced plan applies to. Threaded\n * from the planner options so the runner keys the marker row by\n * the right space when executing the plan.\n */\n get spaceId(): string {\n return this.#spaceId;\n }\n\n renderTypeScript(): string {\n return renderCallsToTypeScript(this.#calls, { from: this.#meta.from, to: this.#meta.to });\n }\n}\n"],"mappings":";;;;AAqCA,IAAa,wCAAb,cACU,kBAEV;CACE;CACA;CACA;CACA;CACA;CAOA,YACE,OACA,MACA,SACA,SACA;EACA,MAAM;EACN,KAAKA,SAAS;EACd,KAAKC,QAAQ;EACb,KAAKC,WAAW;EAChB,KAAKC,WAAW;CAClB;CAEA,IAAa,aAGT;EACF,KAAKC,qBAAqB,UAAU,KAAKJ,QAAQ,KAAKG,QAAQ;EAC9D,OAAO,KAAKC;CACd;CAEA,WAAmC;EACjC,OAAO,KAAKH;CACd;;;;;;CAOA,IAAI,UAAkB;EACpB,OAAO,KAAKC;CACd;CAEA,mBAA2B;EACzB,OAAO,wBAAwB,KAAKF,QAAQ;GAAE,MAAM,KAAKC,MAAM;GAAM,IAAI,KAAKA,MAAM;EAAG,CAAC;CAC1F;AACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-
|
|
1
|
+
import { t as TypeScriptRenderablePostgresMigration } from "./planner-produced-postgres-migration-Cji5vxUf.mjs";
|
|
2
2
|
export { TypeScriptRenderablePostgresMigration };
|
package/dist/planner.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as createPostgresMigrationPlanner } from "./planner-
|
|
1
|
+
import { t as createPostgresMigrationPlanner } from "./planner-Bs_baQax.mjs";
|
|
2
2
|
export { createPostgresMigrationPlanner };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as SetNotNullCall, D as installExtension, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, y as DropNotNullCall } from "./op-factory-call-
|
|
1
|
+
import { C as SetNotNullCall, D as installExtension, S as SetDefaultCall, _ as DropDefaultCall, b as DropTableCall, c as AlterColumnTypeCall, d as CreateSchemaCall, f as CreateTableCall, g as DropConstraintCall, h as DropColumnCall, m as DropCheckConstraintCall, n as AddColumnCall, o as AddPrimaryKeyCall, r as AddForeignKeyCall, s as AddUniqueCall, t as AddCheckConstraintCall, u as CreateIndexCall, v as DropIndexCall, y as DropNotNullCall } from "./op-factory-call-D_p5vxwt.mjs";
|
|
2
2
|
import { t as errorPostgresMigrationStackMissing } from "./errors-CUk87ByX.mjs";
|
|
3
3
|
import { t as dataTransform } from "./data-transform-BOWpliq8.mjs";
|
|
4
4
|
import { Migration } from "@prisma-next/family-sql/migration";
|
|
@@ -142,4 +142,4 @@ var PostgresMigration = class extends Migration {
|
|
|
142
142
|
//#endregion
|
|
143
143
|
export { PostgresMigration as t };
|
|
144
144
|
|
|
145
|
-
//# sourceMappingURL=postgres-migration-
|
|
145
|
+
//# sourceMappingURL=postgres-migration-B5jKrXv3.mjs.map
|