@prisma-next/target-postgres 0.9.0 → 0.10.0-dev.2
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/{codec-ids-RvYfmUmi.d.mts → codec-ids-D9fJ4HP5.d.mts} +1 -1
- package/dist/{codec-ids-RvYfmUmi.d.mts.map → codec-ids-D9fJ4HP5.d.mts.map} +1 -1
- package/dist/codec-ids.d.mts +1 -1
- package/dist/{codec-types-667FxIW8.d.mts → codec-types-CRlHq7Cz.d.mts} +2 -2
- package/dist/{codec-types-667FxIW8.d.mts.map → codec-types-CRlHq7Cz.d.mts.map} +1 -1
- package/dist/codec-types.d.mts +1 -1
- package/dist/{codecs-DXeDABSO.d.mts → codecs-Dud5KDNk.d.mts} +2 -2
- package/dist/{codecs-DXeDABSO.d.mts.map → codecs-Dud5KDNk.d.mts.map} +1 -1
- package/dist/codecs.d.mts +1 -1
- package/dist/control.d.mts +1 -1
- package/dist/control.mjs +5 -5
- package/dist/{data-transform-COkGR6Ns.mjs → data-transform-CdtGUWp2.mjs} +1 -1
- package/dist/{data-transform-COkGR6Ns.mjs.map → data-transform-CdtGUWp2.mjs.map} +1 -1
- package/dist/{data-transform-B6p02mFJ.d.mts → data-transform-bmOKkygi.d.mts} +2 -2
- package/dist/{data-transform-B6p02mFJ.d.mts.map → data-transform-bmOKkygi.d.mts.map} +1 -1
- package/dist/data-transform.d.mts +1 -1
- package/dist/data-transform.mjs +1 -1
- package/dist/descriptor-meta-zrZzWmJF.mjs +91 -0
- package/dist/{descriptor-meta-DFUCClk_.mjs.map → descriptor-meta-zrZzWmJF.mjs.map} +1 -1
- package/dist/enum-planning.d.mts +1 -1
- package/dist/{errors-BiOloWUh.mjs → errors--zafB5_n.mjs} +1 -1
- package/dist/{errors-BiOloWUh.mjs.map → errors--zafB5_n.mjs.map} +1 -1
- package/dist/errors.mjs +1 -1
- package/dist/{issue-planner-BhWVYyE1.mjs → issue-planner-qalHRCI2.mjs} +179 -77
- package/dist/issue-planner-qalHRCI2.mjs.map +1 -0
- package/dist/issue-planner.d.mts +2 -2
- package/dist/issue-planner.d.mts.map +1 -1
- package/dist/issue-planner.mjs +1 -1
- package/dist/migration.d.mts +3 -3
- package/dist/migration.mjs +3 -3
- package/dist/{op-factory-call-c1zELk3U.d.mts → op-factory-call-Drccm_JD.d.mts} +3 -3
- package/dist/{op-factory-call-c1zELk3U.d.mts.map → op-factory-call-Drccm_JD.d.mts.map} +1 -1
- package/dist/{op-factory-call-DerP9BoT.mjs → op-factory-call-Zsrdty3k.mjs} +2 -2
- package/dist/{op-factory-call-DerP9BoT.mjs.map → op-factory-call-Zsrdty3k.mjs.map} +1 -1
- package/dist/op-factory-call.d.mts +1 -1
- package/dist/op-factory-call.mjs +1 -1
- package/dist/pack.d.mts +2 -2
- package/dist/pack.mjs +1 -1
- package/dist/{planner-DnzPpv1j.mjs → planner-C8yhbXOq.mjs} +84 -5
- package/dist/planner-C8yhbXOq.mjs.map +1 -0
- package/dist/{planner-ddl-builders-5QIyhBUF.mjs → planner-ddl-builders-DINYrbJ3.mjs} +4 -4
- package/dist/{planner-ddl-builders-5QIyhBUF.mjs.map → planner-ddl-builders-DINYrbJ3.mjs.map} +1 -1
- package/dist/planner-ddl-builders.d.mts +1 -1
- package/dist/planner-ddl-builders.mjs +1 -1
- package/dist/{planner-identity-values-BUYNOCwb.mjs → planner-identity-values-ojX-6cPV.mjs} +1 -1
- package/dist/{planner-identity-values-BUYNOCwb.mjs.map → planner-identity-values-ojX-6cPV.mjs.map} +1 -1
- package/dist/planner-identity-values.mjs +1 -1
- package/dist/{planner-produced-postgres-migration-FYsKh26I.mjs → planner-produced-postgres-migration-BqGLw7VT.mjs} +4 -4
- package/dist/{planner-produced-postgres-migration-FYsKh26I.mjs.map → planner-produced-postgres-migration-BqGLw7VT.mjs.map} +1 -1
- package/dist/{planner-produced-postgres-migration-D34ftfEK.d.mts → planner-produced-postgres-migration-c9lpjPv1.d.mts} +3 -3
- package/dist/{planner-produced-postgres-migration-D34ftfEK.d.mts.map → planner-produced-postgres-migration-c9lpjPv1.d.mts.map} +1 -1
- package/dist/planner-produced-postgres-migration.d.mts +1 -1
- package/dist/planner-produced-postgres-migration.mjs +1 -1
- package/dist/planner-schema-lookup-BGyukuzG.mjs +57 -0
- package/dist/planner-schema-lookup-BGyukuzG.mjs.map +1 -0
- package/dist/planner-schema-lookup.d.mts.map +1 -1
- package/dist/planner-schema-lookup.mjs +1 -1
- package/dist/{planner-sql-checks-Cd016Ycs.mjs → planner-sql-checks-BM4sD6Xc.mjs} +28 -11
- package/dist/planner-sql-checks-BM4sD6Xc.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts +11 -0
- package/dist/planner-sql-checks.d.mts.map +1 -1
- package/dist/planner-sql-checks.mjs +1 -1
- package/dist/{planner-target-details-iYJwzFHP.d.mts → planner-target-details-CIj61DUj.d.mts} +1 -1
- package/dist/{planner-target-details-iYJwzFHP.d.mts.map → planner-target-details-CIj61DUj.d.mts.map} +1 -1
- package/dist/planner-target-details.d.mts +1 -1
- package/dist/planner.d.mts +1 -1
- package/dist/planner.d.mts.map +1 -1
- package/dist/planner.mjs +1 -1
- package/dist/postgres-contract-serializer-CcZO9ukP.mjs +83 -0
- package/dist/postgres-contract-serializer-CcZO9ukP.mjs.map +1 -0
- package/dist/{postgres-enum-type-CrKq8au9.d.mts → postgres-enum-type-CNhPTDhy.d.mts} +1 -1
- package/dist/{postgres-enum-type-CrKq8au9.d.mts.map → postgres-enum-type-CNhPTDhy.d.mts.map} +1 -1
- package/dist/{postgres-migration-q4oWyNJE.mjs → postgres-migration-C5os-tkl.mjs} +3 -3
- package/dist/{postgres-migration-q4oWyNJE.mjs.map → postgres-migration-C5os-tkl.mjs.map} +1 -1
- package/dist/{postgres-migration-CiQzhcMe.d.mts → postgres-migration-jvsKgUDM.d.mts} +3 -3
- package/dist/{postgres-migration-CiQzhcMe.d.mts.map → postgres-migration-jvsKgUDM.d.mts.map} +1 -1
- package/dist/postgres-schema-BosNxhWq.mjs +163 -0
- package/dist/postgres-schema-BosNxhWq.mjs.map +1 -0
- package/dist/{render-ops-CkiuHSNj.mjs → render-ops-BC2PtCkj.mjs} +1 -1
- package/dist/{render-ops-CkiuHSNj.mjs.map → render-ops-BC2PtCkj.mjs.map} +1 -1
- package/dist/render-ops.d.mts +1 -1
- package/dist/render-ops.mjs +1 -1
- package/dist/{render-typescript-C9XWI8Ld.mjs → render-typescript-nRHbqLbI.mjs} +1 -1
- package/dist/{render-typescript-C9XWI8Ld.mjs.map → render-typescript-nRHbqLbI.mjs.map} +1 -1
- package/dist/render-typescript.mjs +1 -1
- package/dist/runtime.d.mts +7 -17
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +2 -2
- package/dist/{shared-DLYdmYo-.d.mts → shared-ByhSooBS.d.mts} +6 -4
- package/dist/shared-ByhSooBS.d.mts.map +1 -0
- package/dist/{statement-builders-BSIQMClE.mjs → statement-builders-vImtdfmM.mjs} +1 -1
- package/dist/{statement-builders-BSIQMClE.mjs.map → statement-builders-vImtdfmM.mjs.map} +1 -1
- package/dist/statement-builders.mjs +1 -1
- package/dist/{tables-Ce_Q0I8B.mjs → tables-DZ-5Yxi0.mjs} +3 -3
- package/dist/tables-DZ-5Yxi0.mjs.map +1 -0
- package/dist/{types-Dq74Z3eu.d.mts → types-D-XIpzHA.d.mts} +1 -1
- package/dist/types-D-XIpzHA.d.mts.map +1 -0
- package/dist/types.d.mts +125 -3
- package/dist/types.d.mts.map +1 -0
- package/dist/types.mjs +2 -1
- package/package.json +17 -17
- package/src/core/migrations/issue-planner.ts +131 -41
- package/src/core/migrations/operations/constraints.ts +1 -1
- package/src/core/migrations/operations/shared.ts +4 -2
- package/src/core/migrations/planner-ddl-builders.ts +2 -2
- package/src/core/migrations/planner-schema-lookup.ts +30 -6
- package/src/core/migrations/planner-sql-checks.ts +29 -11
- package/src/core/migrations/planner-strategies.ts +138 -43
- package/src/core/migrations/planner.ts +14 -1
- package/src/core/migrations/verify-postgres-namespaces.ts +87 -0
- package/src/core/postgres-contract-serializer.ts +139 -60
- package/src/core/postgres-schema.ts +208 -0
- package/src/exports/types.ts +5 -0
- package/dist/descriptor-meta-DFUCClk_.mjs +0 -124
- package/dist/issue-planner-BhWVYyE1.mjs.map +0 -1
- package/dist/planner-DnzPpv1j.mjs.map +0 -1
- package/dist/planner-schema-lookup--u9whY_Y.mjs +0 -29
- package/dist/planner-schema-lookup--u9whY_Y.mjs.map +0 -1
- package/dist/planner-sql-checks-Cd016Ycs.mjs.map +0 -1
- package/dist/postgres-contract-serializer-D5VJk6lo.mjs +0 -61
- package/dist/postgres-contract-serializer-D5VJk6lo.mjs.map +0 -1
- package/dist/shared-DLYdmYo-.d.mts.map +0 -1
- package/dist/tables-Ce_Q0I8B.mjs.map +0 -1
- package/dist/types-Dq74Z3eu.d.mts.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"issue-planner-BhWVYyE1.mjs","names":[],"sources":["../src/core/migrations/planner-target-details.ts","../src/core/migrations/planner-recipes.ts","../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"sourcesContent":["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\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 {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { quoteIdentifier } from '../sql-utils';\nimport { buildAddColumnSql } from './planner-ddl-builders';\nimport {\n columnExistsCheck,\n columnHasNoDefaultCheck,\n columnNullabilityCheck,\n qualifyTableName,\n} 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 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 | PostgresEnumStorageEntry>;\n readonly temporaryDefault: string;\n}): SqlMigrationPlanOperation<PostgresPlanTargetDetails> {\n const { schema, tableName, columnName, column, codecHooks, storageTypes, temporaryDefault } =\n options;\n const qualified = qualifyTableName(schema, tableName);\n\n return {\n ...buildAddColumnOperationIdentity(schema, tableName, columnName),\n operationClass: 'additive',\n precheck: [\n {\n description: `ensure column \"${columnName}\" is missing`,\n sql: columnExistsCheck({ schema, table: tableName, column: columnName, exists: false }),\n },\n ],\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 {\n description: `verify column \"${columnName}\" exists`,\n sql: columnExistsCheck({ schema, table: tableName, column: columnName }),\n },\n {\n description: `verify column \"${columnName}\" is NOT NULL`,\n sql: columnNullabilityCheck({\n schema,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n },\n {\n description: `verify column \"${columnName}\" has no default after temporary default removal`,\n sql: columnHasNoDefaultCheck({ schema, table: tableName, column: columnName }),\n },\n ],\n };\n}\n","/**\n * Migration strategies.\n *\n * Each strategy examines the issue list, consumes issues it handles, and\n * returns the `PostgresOpFactoryCall[]` to address them. The issue planner\n * runs each strategy in order and routes whatever's left through\n * `mapIssueToCall`.\n *\n * The full ordered list is exported as `postgresPlannerStrategies` and is\n * used unchanged by both `migration plan` and `db update` / `db init`. The\n * two journeys differ only in `policy.allowedOperationClasses`:\n *\n * - When `'data'` is in the policy, data-safe strategies (NOT NULL backfill,\n * nullability tightening, unsafe type changes, enum shrink/rebuild) emit\n * `DataTransformCall` placeholders that the user fills in.\n * - When `'data'` is excluded, those strategies short-circuit so the\n * downstream walk-schema strategies (codec-hook type ops and temp-default\n * backfill) and `mapIssueToCall` defaults emit direct DDL instead.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n type SqlStorage,\n type StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport { PostgresEnumType } from '../postgres-enum-type';\nimport { determineEnumDiff, readExistingEnumValues } from './enum-planning';\nimport {\n AddColumnCall,\n AddEnumValuesCall,\n AlterColumnTypeCall,\n CreateEnumTypeCall,\n DataTransformCall,\n DropEnumTypeCall,\n type PostgresOpFactoryCall,\n RawSqlCall,\n RenameTypeCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport {\n buildAddColumnSql,\n buildColumnDefaultSql,\n buildColumnTypeSql,\n} from './planner-ddl-builders';\nimport { resolveIdentityValue } from './planner-identity-values';\nimport {\n buildAddColumnOperationIdentity,\n buildAddNotNullColumnWithTemporaryDefaultOperation,\n} from './planner-recipes';\nimport { buildSchemaLookupMap, hasForeignKey, hasUniqueConstraint } from './planner-schema-lookup';\nimport {\n buildExpectedFormatType,\n columnExistsCheck,\n columnNullabilityCheck,\n qualifyTableName,\n tableIsEmptyCheck,\n} from './planner-sql-checks';\nimport { buildTargetDetails, type PostgresPlanTargetDetails } from './planner-target-details';\n\nconst REBUILD_SUFFIX = '__prisma_next_new';\n\n// ============================================================================\n// Strategy types\n// ============================================================================\n\n/**\n * Context passed to each migration strategy.\n *\n * Strategies read the source (`fromContract`), target (`toContract`), current\n * database state (`schema`), operation policy (`policy`), and component list\n * (`frameworkComponents`) to make planning decisions. `fromContract` is null\n * when no prior contract is available (e.g. `db update`, where the current\n * DB state is approximated via `schema`).\n */\nexport interface StrategyContext {\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly schemaName: string;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;\n readonly schema: SqlSchemaIR;\n readonly policy: MigrationOperationPolicy;\n readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n}\n\n// ============================================================================\n// Call strategies (for issue planner)\n// ============================================================================\n\nexport type CallMigrationStrategy = (\n issues: readonly SchemaIssue[],\n context: StrategyContext,\n) =>\n | {\n kind: 'match';\n issues: readonly SchemaIssue[];\n calls: readonly PostgresOpFactoryCall[];\n /**\n * `true` for strategies that emit cohesive sequential recipes whose\n * calls must stay contiguous and in the returned order — e.g.\n * `nativeEnumPlanCallStrategy` (createEnumType → alterColumnType →\n * dropEnumType → renameType, optionally prefixed by a\n * `DataTransformCall` placeholder), `notNullBackfillCallStrategy`\n * (addColumn → dataTransform → setNotNull). Defaults to `false`,\n * which lets `planIssues` hoist individual calls into their DDL\n * sequencing bucket.\n */\n recipe?: boolean;\n }\n | { kind: 'no_match' };\n\nfunction buildColumnSpec(\n table: string,\n column: string,\n ctx: StrategyContext,\n overrides?: { nullable?: boolean },\n) {\n const col = ctx.toContract.storage.tables[table]?.columns[column];\n if (!col) throw new Error(`Column \"${table}\".\"${column}\" not found in destination contract`);\n const mutableHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableTypes = ctx.storageTypes as Record<\n string,\n StorageTypeInstance | PostgresEnumStorageEntry\n >;\n return {\n name: column,\n typeSql: buildColumnTypeSql(col, mutableHooks, mutableTypes),\n defaultSql: buildColumnDefaultSql(col.default, col),\n nullable: overrides?.nullable ?? col.nullable,\n };\n}\n\nfunction buildAlterTypeOptions(\n table: string,\n column: string,\n ctx: StrategyContext,\n using?: string,\n) {\n const col = ctx.toContract.storage.tables[table]?.columns[column];\n if (!col) throw new Error(`Column \"${table}\".\"${column}\" not found in destination contract`);\n const mutableHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableTypes = ctx.storageTypes as Record<\n string,\n StorageTypeInstance | PostgresEnumStorageEntry\n >;\n const qualifiedTargetType = buildColumnTypeSql(col, mutableHooks, mutableTypes, false);\n const formatTypeExpected = buildExpectedFormatType(col, mutableHooks, mutableTypes);\n return {\n qualifiedTargetType,\n formatTypeExpected,\n rawTargetTypeForLabel: qualifiedTargetType,\n ...(using !== undefined ? { using } : {}),\n };\n}\n\nexport const notNullBackfillCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // `DataTransformCall` is operation class `'data'`. When the policy excludes\n // it (`db update` / `db init`), skip so `notNullAddColumnCallStrategy`\n // (temp-default backfill) or `mapIssueToCall` can take the issue.\n if (!ctx.policy.allowedOperationClasses.includes('data')) return { kind: 'no_match' };\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'missing_column' || !issue.table || !issue.column) continue;\n\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column) continue;\n if (column.nullable === true || column.default !== undefined) continue;\n\n matched.push(issue);\n const spec = buildColumnSpec(issue.table, issue.column, ctx, { nullable: true });\n calls.push(\n new AddColumnCall(ctx.schemaName, issue.table, spec),\n new DataTransformCall(\n `backfill-${issue.table}-${issue.column}`,\n `backfill-${issue.table}-${issue.column}:check`,\n `backfill-${issue.table}-${issue.column}:run`,\n ),\n new SetNotNullCall(ctx.schemaName, issue.table, issue.column),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\nconst SAFE_WIDENINGS = new Set(['int2→int4', 'int2→int8', 'int4→int8', 'float4→float8']);\n\nexport const typeChangeCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // For unsafe widenings this strategy emits a `DataTransformCall` placeholder\n // (operation class `'data'`); when the policy excludes `'data'`\n // (`db update` / `db init`), skip those issues so `mapIssueToCall` can\n // emit a direct `ALTER COLUMN TYPE`. Safe widenings still flow through\n // here because the resulting `AlterColumnTypeCall` is `widening`-class.\n const dataAllowed = ctx.policy.allowedOperationClasses.includes('data');\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'type_mismatch') continue;\n if (!issue.table || !issue.column) continue;\n const fromColumn = ctx.fromContract?.storage.tables[issue.table]?.columns[issue.column];\n const toColumn = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!fromColumn || !toColumn) continue;\n const fromType = fromColumn.nativeType;\n const toType = toColumn.nativeType;\n if (fromType === toType) continue;\n const isSafeWidening = SAFE_WIDENINGS.has(`${fromType}→${toType}`);\n if (!isSafeWidening && !dataAllowed) continue;\n matched.push(issue);\n const alterOpts = buildAlterTypeOptions(issue.table, issue.column, ctx);\n if (isSafeWidening) {\n calls.push(new AlterColumnTypeCall(ctx.schemaName, issue.table, issue.column, alterOpts));\n } else {\n calls.push(\n new DataTransformCall(\n `typechange-${issue.table}-${issue.column}`,\n `typechange-${issue.table}-${issue.column}:check`,\n `typechange-${issue.table}-${issue.column}:run`,\n ),\n new AlterColumnTypeCall(ctx.schemaName, issue.table, issue.column, alterOpts),\n );\n }\n }\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\nexport const nullableTighteningCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // `DataTransformCall` is operation class `'data'`. When the policy excludes\n // it (`db update` / `db init`), skip so `mapIssueToCall` emits a direct\n // `SET NOT NULL` instead.\n if (!ctx.policy.allowedOperationClasses.includes('data')) return { kind: 'no_match' };\n\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n for (const issue of issues) {\n if (issue.kind !== 'nullability_mismatch' || !issue.table || !issue.column) continue;\n\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column) continue;\n if (column.nullable === true) continue;\n\n matched.push(issue);\n calls.push(\n new DataTransformCall(\n `handle-nulls-${issue.table}-${issue.column}`,\n `handle-nulls-${issue.table}-${issue.column}:check`,\n `handle-nulls-${issue.table}-${issue.column}:run`,\n ),\n new SetNotNullCall(ctx.schemaName, issue.table, issue.column),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n recipe: true,\n };\n};\n\nfunction enumRebuildCallRecipe(\n typeName: string,\n ctx: StrategyContext,\n): readonly PostgresOpFactoryCall[] {\n const toType = ctx.toContract.storage.types?.[typeName];\n if (!toType) return [];\n const isEnum = isPostgresEnumStorageEntry(toType);\n const nativeType = toType.nativeType;\n const desiredValues: readonly string[] = isEnum\n ? toType.values\n : (((toType as StorageTypeInstance).typeParams['values'] ?? []) as readonly string[]);\n const tempName = `${nativeType}${REBUILD_SUFFIX}`;\n\n const columnRefs: { table: string; column: string }[] = [];\n for (const [tableName, table] of Object.entries(ctx.toContract.storage.tables)) {\n for (const [columnName, column] of Object.entries(table.columns)) {\n if (column.typeRef === typeName) {\n columnRefs.push({ table: tableName, column: columnName });\n }\n }\n }\n\n return [\n new CreateEnumTypeCall(ctx.schemaName, tempName, desiredValues),\n ...columnRefs.map((ref) => {\n const using = `${ref.column}::text::${tempName}`;\n return new AlterColumnTypeCall(ctx.schemaName, ref.table, ref.column, {\n qualifiedTargetType: tempName,\n formatTypeExpected: tempName,\n rawTargetTypeForLabel: tempName,\n using,\n });\n }),\n new DropEnumTypeCall(ctx.schemaName, nativeType),\n new RenameTypeCall(ctx.schemaName, tempName, nativeType),\n ];\n}\n\n// ============================================================================\n// Native enum planner strategy\n// ============================================================================\n\n/**\n * Single planner strategy for `PostgresEnumType` instances. Walks\n * `toContract.storage.types` directly (no codec-hook dispatch) and\n * resolves existing values via `readExistingEnumValues`, the same\n * Postgres bridging adapter the verifier uses.\n *\n * Per-enum dispatch:\n *\n * - No existing type → `CreateEnumTypeCall` with the contract's desired\n * values.\n * - Diff is `unchanged` → no calls emitted (consumes the matching\n * `enum_values_changed` issue if present).\n * - Diff is `add_values` → `AddEnumValuesCall` with the new labels.\n * - Diff is `rebuild` → the create-temp / migrate-columns /\n * drop-original / rename rebuild recipe. When\n * `policy.allowedOperationClasses` includes `'data'` and the rebuild\n * removes labels (`removedValues.length > 0`), prepend a\n * `DataTransformCall` placeholder so the user can author the value\n * remap before the destructive recipe runs. Without `'data'` in the\n * policy (`db update` / `db init`), the rebuild's PG `USING ::text`\n * cast surfaces any value-removal data loss as a runtime error rather\n * than silent loss.\n *\n * Returns `recipe: true` only when a rebuild recipe was emitted (its\n * `createEnumType(temp) → alterColumnType → dropEnumType(orig) →\n * renameType` sequence mixes `dep`-class and `alter`-class calls that\n * would mis-order if the planner hoisted them into its DDL sequencing\n * buckets). For the create-only and add-values paths the strategy\n * returns `recipe: false` so the planner hoists `CreateEnumTypeCall`\n * into the `dep` bucket — i.e. `CREATE TYPE` runs before any\n * `CreateTableCall` that references the new enum.\n */\nexport const nativeEnumPlanCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const enumTypes = collectPostgresEnumTypes(ctx.toContract.storage.types);\n if (enumTypes.size === 0) return { kind: 'no_match' };\n\n const dataAllowed = ctx.policy.allowedOperationClasses.includes('data');\n\n const calls: PostgresOpFactoryCall[] = [];\n const handledTypeNames = new Set<string>();\n const introducedTypeNames = new Set<string>();\n const rebuiltTypeNames = new Set<string>();\n let emittedRebuildRecipe = false;\n\n for (const [typeName, enumType] of enumTypes) {\n const desired = enumType.values;\n const existing = readExistingEnumValues(ctx.schema, enumType.nativeType);\n if (!existing) {\n calls.push(new CreateEnumTypeCall(ctx.schemaName, typeName, desired, enumType.nativeType));\n handledTypeNames.add(typeName);\n introducedTypeNames.add(typeName);\n continue;\n }\n const diff = determineEnumDiff(existing, desired);\n if (diff.kind === 'unchanged') {\n handledTypeNames.add(typeName);\n continue;\n }\n if (diff.kind === 'add_values') {\n calls.push(new AddEnumValuesCall(ctx.schemaName, typeName, enumType.nativeType, diff.values));\n handledTypeNames.add(typeName);\n continue;\n }\n if (dataAllowed && diff.removedValues.length > 0) {\n calls.push(\n new DataTransformCall(\n `migrate-${typeName}-values`,\n `migrate-${typeName}-values:check`,\n `migrate-${typeName}-values:run`,\n ),\n );\n }\n calls.push(...enumRebuildCallRecipe(typeName, ctx));\n emittedRebuildRecipe = true;\n handledTypeNames.add(typeName);\n rebuiltTypeNames.add(typeName);\n }\n\n // The strategy emits a single `recipe` flag for the entire pass,\n // which routes every emitted call to either the contiguous recipe\n // slot (rebuild path) or the `dep` bucket (introduce / add-values\n // path). A plan that needs both shapes simultaneously cannot be\n // expressed today — the introduced `CreateEnumTypeCall` would land\n // in the recipe slot and any `CreateTableCall` referencing the new\n // enum would fail at runtime with a confusing `type \"X\" does not\n // exist` error. Surface the unrepresentable case here as a\n // planner-time error so the failure mode is loud, not silent.\n if (introducedTypeNames.size > 0 && rebuiltTypeNames.size > 0) {\n throw new Error(\n `nativeEnumPlanCallStrategy: cannot emit both a brand-new enum and a rebuild on a different enum in the same plan; the single recipe flag cannot route them to different buckets. Introduced: [${[...introducedTypeNames].sort().join(', ')}]; rebuilt: [${[...rebuiltTypeNames].sort().join(', ')}]. Split the strategy or grow the \\`match\\` return type before this case lands.`,\n );\n }\n\n const remaining = issues.filter(\n (issue) =>\n !(\n (issue.kind === 'type_missing' || issue.kind === 'enum_values_changed') &&\n issue.typeName &&\n handledTypeNames.has(issue.typeName)\n ),\n );\n\n if (calls.length === 0 && remaining.length === issues.length) {\n return { kind: 'no_match' };\n }\n // `recipe: true` is required for the rebuild path — its\n // `createEnumType(temp) → alterColumnType → dropEnumType(orig) →\n // renameType` mixes `dep`-class and `alter`-class calls that would\n // mis-order if the planner hoisted them into its DDL sequencing\n // buckets. For the type_missing / add_values paths we want the\n // opposite: hoisted into the `dep` bucket so a brand-new\n // `CreateEnumTypeCall` runs *before* the `CreateTableCall` that\n // references it. The two cases never co-occur in the same plan\n // (introducing a new enum type and rebuilding an existing one in\n // one shot would require both buckets — a shape today's interface\n // does not surface; if that combination ever needs to land we'd\n // split this strategy or grow the `match` return type).\n return { kind: 'match', issues: remaining, calls, recipe: emittedRebuildRecipe };\n};\n\nfunction collectPostgresEnumTypes(\n storageTypes: SqlStorage['types'],\n): ReadonlyMap<string, PostgresEnumType> {\n const result = new Map<string, PostgresEnumType>();\n for (const [name, instance] of Object.entries(storageTypes ?? {}).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n if (instance instanceof PostgresEnumType) {\n result.set(name, instance);\n }\n }\n return result;\n}\n\n/**\n * Dispatches non-enum codec-typed storage types through their codec's\n * `planTypeOperations` hook (the authoritative source for codec-driven DDL\n * such as custom type creation). Enum dispatch lives in\n * `nativeEnumPlanCallStrategy` and no longer relies on codec hooks.\n */\nexport const storageTypePlanCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const storageTypes = ctx.toContract.storage.types ?? {};\n if (Object.keys(storageTypes).length === 0) return { kind: 'no_match' };\n\n const calls: PostgresOpFactoryCall[] = [];\n const handledTypeNames = new Set<string>();\n\n for (const [typeName, typeInstance] of Object.entries(storageTypes).sort(([a], [b]) =>\n a.localeCompare(b),\n )) {\n // Enums walk natively in `nativeEnumPlanCallStrategy`; codec-hook\n // dispatch here is reserved for genuinely codec-typed entries\n // (decimal, varchar, pgvector, …).\n if (isPostgresEnumStorageEntry(typeInstance)) continue;\n const codecInstance = typeInstance as StorageTypeInstance;\n const hook = ctx.codecHooks.get(codecInstance.codecId);\n if (!hook?.planTypeOperations) continue;\n const planResult = hook.planTypeOperations({\n typeName,\n typeInstance: codecInstance,\n contract: ctx.toContract,\n schema: ctx.schema,\n schemaName: ctx.schemaName,\n policy: ctx.policy,\n });\n if (!planResult) continue;\n if (planResult.operations.length === 0) {\n handledTypeNames.add(typeName);\n continue;\n }\n handledTypeNames.add(typeName);\n for (const op of planResult.operations) {\n calls.push(\n new RawSqlCall({\n ...op,\n target: {\n id: op.target.id,\n details: buildTargetDetails('type', typeName, ctx.schemaName),\n },\n } as SqlMigrationPlanOperation<PostgresPlanTargetDetails>),\n );\n }\n }\n\n const remaining = issues.filter(\n (issue) =>\n !(\n (issue.kind === 'type_missing' || issue.kind === 'enum_values_changed') &&\n issue.typeName &&\n handledTypeNames.has(issue.typeName)\n ),\n );\n\n if (calls.length === 0 && remaining.length === issues.length) {\n return { kind: 'no_match' };\n }\n\n return { kind: 'match', issues: remaining, calls };\n};\n\n/**\n * Handles `missing_column` issues for NOT NULL columns without a contract\n * default. Replaces the walk-schema `buildAddColumnItem` non-default branches.\n *\n * Two shapes:\n * - Shared-temp-default safe: emit a single atomic composite op (add\n * nullable → backfill identity value → `SET NOT NULL` → `DROP DEFAULT`).\n * - Empty-table guarded: emit a hand-built op with a `tableIsEmptyCheck`\n * precheck so the failure message is \"table is not empty\" rather than the\n * raw PG NOT NULL violation.\n *\n * \"Normal\" missing_column cases (nullable or has a contract default) are left\n * for `mapIssueToCall`'s default `AddColumnCall` emission.\n */\nexport const notNullAddColumnCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const matched: SchemaIssue[] = [];\n const calls: PostgresOpFactoryCall[] = [];\n\n const schemaLookups = buildSchemaLookupMap(ctx.schema);\n\n const mutableCodecHooks = ctx.codecHooks as Map<string, CodecControlHooks>;\n const mutableStorageTypes = ctx.storageTypes as Record<\n string,\n StorageTypeInstance | PostgresEnumType\n >;\n\n for (const issue of issues) {\n if (issue.kind !== 'missing_column' || !issue.table || !issue.column) continue;\n const contractTable = ctx.toContract.storage.tables[issue.table];\n const column = contractTable?.columns[issue.column];\n if (!column) continue;\n\n const notNull = column.nullable !== true;\n const hasDefault = column.default !== undefined;\n if (!notNull || hasDefault) continue;\n\n const schemaTable = ctx.schema.tables[issue.table];\n if (!schemaTable) continue;\n\n const temporaryDefault = resolveIdentityValue(column, mutableCodecHooks, mutableStorageTypes);\n const schemaLookup = schemaLookups.get(issue.table);\n const canUseSharedTempDefault =\n temporaryDefault !== null &&\n canUseSharedTemporaryDefaultStrategy({\n table: contractTable,\n schemaTable,\n schemaLookup,\n columnName: issue.column,\n });\n\n matched.push(issue);\n\n if (canUseSharedTempDefault && temporaryDefault !== null) {\n calls.push(\n new RawSqlCall(\n buildAddNotNullColumnWithTemporaryDefaultOperation({\n schema: ctx.schemaName,\n tableName: issue.table,\n columnName: issue.column,\n column,\n codecHooks: mutableCodecHooks,\n storageTypes: mutableStorageTypes,\n temporaryDefault,\n }),\n ),\n );\n continue;\n }\n\n const qualified = qualifyTableName(ctx.schemaName, issue.table);\n calls.push(\n new RawSqlCall({\n ...buildAddColumnOperationIdentity(ctx.schemaName, issue.table, issue.column),\n operationClass: 'additive',\n precheck: [\n {\n description: `ensure column \"${issue.column}\" is missing`,\n sql: columnExistsCheck({\n schema: ctx.schemaName,\n table: issue.table,\n column: issue.column,\n exists: false,\n }),\n },\n {\n description: `ensure table \"${issue.table}\" is empty before adding NOT NULL column without default`,\n sql: tableIsEmptyCheck(qualified),\n },\n ],\n execute: [\n {\n description: `add column \"${issue.column}\"`,\n sql: buildAddColumnSql(\n qualified,\n issue.column,\n column,\n mutableCodecHooks,\n undefined,\n mutableStorageTypes,\n ),\n },\n ],\n postcheck: [\n {\n description: `verify column \"${issue.column}\" exists`,\n sql: columnExistsCheck({\n schema: ctx.schemaName,\n table: issue.table,\n column: issue.column,\n }),\n },\n {\n description: `verify column \"${issue.column}\" is NOT NULL`,\n sql: columnNullabilityCheck({\n schema: ctx.schemaName,\n table: issue.table,\n column: issue.column,\n nullable: false,\n }),\n },\n ],\n }),\n );\n }\n\n if (matched.length === 0) return { kind: 'no_match' };\n return {\n kind: 'match',\n issues: issues.filter((i) => !matched.includes(i)),\n calls,\n };\n};\n\n// ============================================================================\n// Strategy helpers\n// ============================================================================\n\nfunction canUseSharedTemporaryDefaultStrategy(options: {\n readonly table: NonNullable<Contract<SqlStorage>['storage']['tables'][string]>;\n readonly schemaTable: SqlSchemaIR['tables'][string];\n readonly schemaLookup: ReturnType<typeof buildSchemaLookupMap> extends ReadonlyMap<\n string,\n infer V\n >\n ? V | undefined\n : never;\n readonly columnName: string;\n}): boolean {\n const { table, schemaTable, schemaLookup, columnName } = options;\n\n if (table.primaryKey?.columns.includes(columnName) && !schemaTable.primaryKey) {\n return false;\n }\n\n for (const unique of table.uniques) {\n if (!unique.columns.includes(columnName)) continue;\n if (!schemaLookup || !hasUniqueConstraint(schemaLookup, unique.columns)) return false;\n }\n\n for (const foreignKey of table.foreignKeys) {\n if (foreignKey.constraint === false || !foreignKey.columns.includes(columnName)) continue;\n if (!schemaLookup || !hasForeignKey(schemaLookup, foreignKey)) return false;\n }\n\n return true;\n}\n\n/**\n * Ordered list of Postgres planner strategies, shared by `migration plan`\n * and `db update` / `db init`. The issue planner runs each strategy in\n * order, letting it consume any issues it handles, and routes whatever's\n * left through `mapIssueToCall`. Behavior diverges purely on\n * `policy.allowedOperationClasses`:\n *\n * - When `'data'` is allowed (`migration plan`), the data-safe strategies\n * (`notNullBackfillCallStrategy`, `typeChangeCallStrategy`,\n * `nullableTighteningCallStrategy`) and the enum walk\n * (`nativeEnumPlanCallStrategy`) consume their matching issues and emit\n * `DataTransformCall` placeholders or recipe ops.\n *\n * - When `'data'` is not allowed (`db update` / `db init`), the\n * placeholder-emitting strategies short-circuit to `no_match`, leaving\n * the issue for the downstream walk-schema strategies\n * (`storageTypePlanCallStrategy`, `notNullAddColumnCallStrategy`) or the\n * `mapIssueToCall` default to handle with direct DDL.\n * `nativeEnumPlanCallStrategy` runs in both modes; under `db update` /\n * `db init` it emits the rebuild recipe without the data-transform\n * placeholder so value-removal data loss surfaces as a runtime cast\n * error rather than silent loss.\n *\n * Enum dispatch is unified into a single strategy: the\n * `nativeEnumPlanCallStrategy` decides per-emission whether to emit a\n * rebuild recipe (`recipe: true`, contiguous slot) or hoist the call\n * into the `dep` bucket (`recipe: false`, so a brand-new\n * `CreateEnumTypeCall` runs before any `CreateTableCall` referencing\n * it). Codec-typed entries continue through `storageTypePlanCallStrategy`.\n */\nexport const postgresPlannerStrategies: readonly CallMigrationStrategy[] = [\n notNullBackfillCallStrategy,\n typeChangeCallStrategy,\n nullableTighteningCallStrategy,\n nativeEnumPlanCallStrategy,\n storageTypePlanCallStrategy,\n notNullAddColumnCallStrategy,\n];\n","/**\n * Postgres migration planner.\n *\n * Takes schema issues (from verifySqlSchema) and emits migration IR\n * (`PostgresOpFactoryCall[]`). Strategies consume issues they recognize and\n * produce specialized call sequences (e.g. NOT NULL backfill →\n * addColumn(nullable) + dataTransform + setNotNull); remaining issues flow\n * through `mapIssueToCall` for the default case.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n MigrationOperationPolicy,\n SqlPlannerConflict,\n SqlPlannerConflictLocation,\n} from '@prisma-next/family-sql/control';\nimport { arraysEqual } from '@prisma-next/family-sql/schema-verify';\nimport type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\n PostgresEnumStorageEntry,\n SqlStorage,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\nimport type { Result } from '@prisma-next/utils/result';\nimport { notOk, ok } from '@prisma-next/utils/result';\nimport { PostgresEnumType } from '../postgres-enum-type';\nimport {\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n CreateEnumTypeCall,\n CreateIndexCall,\n CreateTableCall,\n DropColumnCall,\n DropConstraintCall,\n DropDefaultCall,\n DropIndexCall,\n DropNotNullCall,\n DropTableCall,\n type PostgresOpFactoryCall,\n SetDefaultCall,\n SetNotNullCall,\n} from './op-factory-call';\nimport type { ColumnSpec, ForeignKeySpec } from './operations/shared';\nimport { buildColumnDefaultSql, buildColumnTypeSql } from './planner-ddl-builders';\nimport { buildExpectedFormatType } from './planner-sql-checks';\nimport {\n type CallMigrationStrategy,\n postgresPlannerStrategies,\n type StrategyContext,\n} from './planner-strategies';\n\nexport type { CallMigrationStrategy, StrategyContext };\n\n// ============================================================================\n// Issue kind ordering (dependency order)\n// ============================================================================\n\nconst ISSUE_KIND_ORDER: Record<string, number> = {\n // Types first\n type_missing: 2,\n type_values_mismatch: 3,\n enum_values_changed: 3,\n\n // Drops (reconciliation — clear the way for creates)\n // FKs dropped first (they depend on other constraints)\n extra_foreign_key: 10,\n extra_unique_constraint: 11,\n extra_primary_key: 12,\n extra_index: 13,\n extra_default: 14,\n extra_column: 15,\n extra_table: 16,\n\n // Tables before columns\n missing_table: 20,\n\n // Columns before constraints\n missing_column: 30,\n\n // Reconciliation alters (on existing objects)\n type_mismatch: 40,\n nullability_mismatch: 41,\n default_missing: 42,\n default_mismatch: 43,\n\n // Constraints after columns exist\n primary_key_mismatch: 50,\n unique_constraint_mismatch: 51,\n index_mismatch: 52,\n foreign_key_mismatch: 60,\n};\n\nfunction issueOrder(issue: SchemaIssue): number {\n return ISSUE_KIND_ORDER[issue.kind] ?? 99;\n}\n\n// ============================================================================\n// Conflict helpers\n// ============================================================================\n\nfunction issueConflict(\n kind: SqlPlannerConflict['kind'],\n summary: string,\n location?: SqlPlannerConflict['location'],\n): SqlPlannerConflict {\n return {\n kind,\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nfunction isMissing(issue: SchemaIssue): boolean {\n if (issue.kind === 'enum_values_changed') return false;\n return issue.actual === undefined;\n}\n\n// ============================================================================\n// Issue planner\n// ============================================================================\n\nexport interface IssuePlannerOptions {\n readonly issues: readonly SchemaIssue[];\n readonly toContract: Contract<SqlStorage>;\n readonly fromContract: Contract<SqlStorage> | null;\n readonly schemaName: string;\n readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;\n readonly storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>;\n /**\n * Current database schema IR. Strategies read this to detect whether a\n * structure already exists (e.g. `buildSchemaLookupMap` for shared-temp-\n * default safety, extension dependency checks). Defaults to an empty schema\n * when omitted so the planner can still run over \"fresh DB\" contract\n * snapshots.\n */\n readonly schema?: SqlSchemaIR;\n /**\n * Operation-class policy. `planIssues` filters calls whose `operationClass`\n * is not in `policy.allowedOperationClasses` and surfaces them as conflicts\n * instead of emitting disallowed DDL. Defaults to additive-only.\n */\n readonly policy?: MigrationOperationPolicy;\n /**\n * Framework components participating in this composition. Available to\n * future strategies that may consult component metadata at plan time.\n */\n readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;\n readonly strategies?: readonly CallMigrationStrategy[];\n}\n\nexport interface IssuePlannerValue {\n readonly calls: readonly PostgresOpFactoryCall[];\n}\n\nfunction toColumnSpec(\n name: string,\n column: StorageColumn,\n codecHooks: ReadonlyMap<string, CodecControlHooks>,\n storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>,\n): ColumnSpec {\n return {\n name,\n typeSql: buildColumnTypeSql(\n column,\n codecHooks as Map<string, CodecControlHooks>,\n storageTypes as Record<string, StorageTypeInstance | PostgresEnumStorageEntry>,\n ),\n defaultSql: buildColumnDefaultSql(column.default, column),\n nullable: column.nullable,\n };\n}\n\nfunction mapIssueToCall(\n issue: SchemaIssue,\n ctx: StrategyContext,\n): Result<readonly PostgresOpFactoryCall[], SqlPlannerConflict> {\n const { schemaName, codecHooks, storageTypes } = ctx;\n\n switch (issue.kind) {\n case 'missing_table': {\n if (!issue.table)\n return notOk(\n issueConflict('unsupportedOperation', 'Missing table issue has no table name'),\n );\n const contractTable = ctx.toContract.storage.tables[issue.table];\n if (!contractTable) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Table \"${issue.table}\" reported missing but not found in destination contract`,\n ),\n );\n }\n const columns: ColumnSpec[] = Object.entries(contractTable.columns).map(([name, column]) =>\n toColumnSpec(name, column, codecHooks, storageTypes),\n );\n const primaryKey = contractTable.primaryKey\n ? { columns: contractTable.primaryKey.columns }\n : undefined;\n const calls: PostgresOpFactoryCall[] = [\n new CreateTableCall(schemaName, issue.table, columns, primaryKey),\n ];\n for (const index of contractTable.indexes) {\n const indexName = index.name ?? `${issue.table}_${index.columns.join('_')}_idx`;\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (index.type !== undefined) extras.type = index.type;\n if (index.options !== undefined) extras.options = index.options;\n calls.push(\n new CreateIndexCall(schemaName, issue.table, indexName, [...index.columns], extras),\n );\n }\n const explicitIndexColumnSets = new Set(\n contractTable.indexes.map((idx) => idx.columns.join(',')),\n );\n for (const fk of contractTable.foreignKeys) {\n if (fk.constraint) {\n const fkName = fk.name ?? `${issue.table}_${fk.columns.join('_')}_fkey`;\n const fkSpec: ForeignKeySpec = {\n name: fkName,\n columns: fk.columns,\n references: { table: fk.references.table, columns: fk.references.columns },\n ...(fk.onDelete !== undefined && { onDelete: fk.onDelete }),\n ...(fk.onUpdate !== undefined && { onUpdate: fk.onUpdate }),\n };\n calls.push(new AddForeignKeyCall(schemaName, issue.table, fkSpec));\n }\n if (fk.index && !explicitIndexColumnSets.has(fk.columns.join(','))) {\n const indexName = `${issue.table}_${fk.columns.join('_')}_idx`;\n calls.push(new CreateIndexCall(schemaName, issue.table, indexName, [...fk.columns]));\n }\n }\n for (const unique of contractTable.uniques) {\n const constraintName = unique.name ?? `${issue.table}_${unique.columns.join('_')}_key`;\n calls.push(new AddUniqueCall(schemaName, issue.table, constraintName, [...unique.columns]));\n }\n return ok(calls);\n }\n\n case 'missing_column':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Missing column issue has no table/column name'),\n );\n {\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n return ok([\n new AddColumnCall(\n schemaName,\n issue.table,\n toColumnSpec(issue.column, column, codecHooks, storageTypes),\n ),\n ]);\n }\n\n case 'default_missing':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Default missing issue has no table/column name'),\n );\n {\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column?.default) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Column \"${issue.table}\".\"${issue.column}\" has no default in contract`,\n ),\n );\n }\n const defaultSql = buildColumnDefaultSql(column.default, column);\n if (!defaultSql) return ok([]);\n return ok([new SetDefaultCall(schemaName, issue.table, issue.column, defaultSql)]);\n }\n\n case 'extra_table':\n if (!issue.table)\n return notOk(issueConflict('unsupportedOperation', 'Extra table issue has no table name'));\n return ok([new DropTableCall(schemaName, issue.table)]);\n\n case 'extra_column':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra column issue has no table/column name'),\n );\n return ok([new DropColumnCall(schemaName, issue.table, issue.column)]);\n\n case 'extra_index':\n if (!issue.table || !issue.indexOrConstraint)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra index issue has no table/index name'),\n );\n return ok([new DropIndexCall(schemaName, issue.table, issue.indexOrConstraint)]);\n\n case 'extra_unique_constraint':\n case 'extra_foreign_key':\n case 'extra_primary_key': {\n if (!issue.table)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Extra constraint issue has no table/constraint name',\n ),\n );\n // `extra_primary_key` issues don't carry a constraint name — the\n // verifier only has the table. Fall back to `<table>_pkey`, matching\n // Postgres' default PK constraint naming and the old reconciliation\n // planner's behavior.\n const constraintName =\n issue.indexOrConstraint ??\n (issue.kind === 'extra_primary_key' ? `${issue.table}_pkey` : undefined);\n if (!constraintName)\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n 'Extra constraint issue has no table/constraint name',\n ),\n );\n const kindMap = {\n extra_unique_constraint: 'unique' as const,\n extra_foreign_key: 'foreignKey' as const,\n extra_primary_key: 'primaryKey' as const,\n };\n return ok([\n new DropConstraintCall(schemaName, issue.table, constraintName, kindMap[issue.kind]),\n ]);\n }\n\n case 'extra_default':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Extra default issue has no table/column name'),\n );\n return ok([new DropDefaultCall(schemaName, issue.table, issue.column)]);\n\n case 'nullability_mismatch': {\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('nullabilityConflict', 'Nullability mismatch has no table/column name'),\n );\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column)\n return notOk(\n issueConflict(\n 'nullabilityConflict',\n `Column \"${issue.table}\".\"${issue.column}\" not found in destination contract`,\n ),\n );\n return ok(\n column.nullable\n ? [new DropNotNullCall(schemaName, issue.table, issue.column)]\n : [new SetNotNullCall(schemaName, issue.table, issue.column)],\n );\n }\n\n case 'type_mismatch':\n if (!issue.table || !issue.column)\n return notOk(issueConflict('typeMismatch', 'Type mismatch has no table/column name'));\n {\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column)\n return notOk(\n issueConflict(\n 'typeMismatch',\n `Column \"${issue.table}\".\"${issue.column}\" not in destination contract`,\n ),\n );\n const hooksMap = codecHooks as Map<string, CodecControlHooks>;\n const typesMap = storageTypes as Record<\n string,\n StorageTypeInstance | PostgresEnumStorageEntry\n >;\n const qualifiedTargetType = buildColumnTypeSql(column, hooksMap, typesMap, false);\n const formatTypeExpected = buildExpectedFormatType(column, hooksMap, typesMap);\n return ok([\n new AlterColumnTypeCall(schemaName, issue.table, issue.column, {\n qualifiedTargetType,\n formatTypeExpected,\n rawTargetTypeForLabel: qualifiedTargetType,\n }),\n ]);\n }\n\n case 'default_mismatch':\n if (!issue.table || !issue.column)\n return notOk(\n issueConflict('unsupportedOperation', 'Default mismatch has no table/column name'),\n );\n {\n const column = ctx.toContract.storage.tables[issue.table]?.columns[issue.column];\n if (!column?.default) return ok([]);\n const defaultSql = buildColumnDefaultSql(column.default, column);\n if (!defaultSql) return ok([]);\n return ok([\n new SetDefaultCall(schemaName, issue.table, issue.column, defaultSql, 'widening'),\n ]);\n }\n\n case 'primary_key_mismatch':\n if (!issue.table)\n return notOk(issueConflict('indexIncompatible', 'Primary key issue has no table name'));\n if (isMissing(issue)) {\n const pk = ctx.toContract.storage.tables[issue.table]?.primaryKey;\n if (!pk)\n return notOk(\n issueConflict('indexIncompatible', `No primary key in contract for \"${issue.table}\"`),\n );\n const constraintName = pk.name ?? `${issue.table}_pkey`;\n return ok([new AddPrimaryKeyCall(schemaName, issue.table, constraintName, pk.columns)]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Primary key on \"${issue.table}\" has different columns (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'unique_constraint_mismatch':\n if (!issue.table)\n return notOk(\n issueConflict('indexIncompatible', 'Unique constraint issue has no table name'),\n );\n if (isMissing(issue) && issue.expected) {\n const columns = issue.expected.split(', ');\n const constraintName = `${issue.table}_${columns.join('_')}_key`;\n return ok([new AddUniqueCall(schemaName, issue.table, constraintName, columns)]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Unique constraint on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'index_mismatch':\n if (!issue.table)\n return notOk(issueConflict('indexIncompatible', 'Index issue has no table name'));\n if (isMissing(issue) && issue.expected) {\n const columns = issue.expected.split(', ');\n const contractIndex = ctx.toContract.storage.tables[issue.table]?.indexes.find((idx) =>\n arraysEqual(idx.columns, columns),\n );\n const indexName = contractIndex?.name ?? `${issue.table}_${columns.join('_')}_idx`;\n const extras: { type?: string; options?: Record<string, unknown> } = {};\n if (contractIndex?.type !== undefined) extras.type = contractIndex.type;\n if (contractIndex?.options !== undefined) extras.options = contractIndex.options;\n return ok([new CreateIndexCall(schemaName, issue.table, indexName, columns, extras)]);\n }\n return notOk(\n issueConflict(\n 'indexIncompatible',\n `Index on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'foreign_key_mismatch':\n if (!issue.table)\n return notOk(issueConflict('foreignKeyConflict', 'Foreign key issue has no table name'));\n if (isMissing(issue) && issue.expected) {\n const arrowIdx = issue.expected.indexOf(' -> ');\n if (arrowIdx >= 0) {\n const columns = issue.expected.slice(0, arrowIdx).split(', ');\n const fkName = `${issue.table}_${columns.join('_')}_fkey`;\n const fk = ctx.toContract.storage.tables[issue.table]?.foreignKeys.find(\n (k) => k.columns.join(', ') === columns.join(', '),\n );\n if (fk) {\n const fkSpec: ForeignKeySpec = {\n name: fkName,\n columns: fk.columns,\n references: { table: fk.references.table, columns: fk.references.columns },\n ...(fk.onDelete !== undefined && { onDelete: fk.onDelete }),\n ...(fk.onUpdate !== undefined && { onUpdate: fk.onUpdate }),\n };\n return ok([new AddForeignKeyCall(schemaName, issue.table, fkSpec)]);\n }\n return notOk(\n issueConflict(\n 'foreignKeyConflict',\n `Foreign key on \"${issue.table}\" (${columns.join(', ')}) not found in destination contract`,\n { table: issue.table },\n ),\n );\n }\n }\n return notOk(\n issueConflict(\n 'foreignKeyConflict',\n `Foreign key on \"${issue.table}\" differs (expected: ${issue.expected}, actual: ${issue.actual})`,\n { table: issue.table },\n ),\n );\n\n case 'type_missing': {\n if (!issue.typeName)\n return notOk(issueConflict('unsupportedOperation', 'Type missing issue has no typeName'));\n const typeInstance = ctx.toContract.storage.types?.[issue.typeName];\n if (!typeInstance) {\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName}\" reported missing but not found in destination contract`,\n ),\n );\n }\n if (typeInstance instanceof PostgresEnumType) {\n return ok([\n new CreateEnumTypeCall(\n schemaName,\n issue.typeName,\n typeInstance.values,\n typeInstance.nativeType,\n ),\n ]);\n }\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName}\" uses codec \"${typeInstance.codecId}\" — only enum types are supported`,\n ),\n );\n }\n\n case 'type_values_mismatch':\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Type \"${issue.typeName ?? 'unknown'}\" values differ — type alteration not yet supported`,\n ),\n );\n\n default:\n return notOk(\n issueConflict(\n 'unsupportedOperation',\n `Unhandled issue kind: ${(issue as SchemaIssue).kind}`,\n ),\n );\n }\n}\n\n/**\n * Classifies calls into dependency order categories for correct DDL sequencing.\n */\ntype CallCategory =\n | 'dep'\n | 'drop'\n | 'table'\n | 'column'\n | 'alter'\n | 'primaryKey'\n | 'unique'\n | 'index'\n | 'foreignKey';\n\n/**\n * Classifies calls into DDL sequencing buckets. The order matches the\n * legacy walk-schema planner's emission order so `db init` and `db update`\n * produce byte-identical plans for the shared shape (deps → drops → tables\n * → columns → alters → PKs → uniques → indexes → FKs).\n */\nfunction classifyCall(call: PostgresOpFactoryCall): CallCategory {\n switch (call.factoryName) {\n case 'createExtension':\n case 'createSchema':\n case 'createEnumType':\n case 'addEnumValues':\n case 'dropEnumType':\n case 'renameType':\n return 'dep';\n case 'dropTable':\n case 'dropColumn':\n case 'dropConstraint':\n case 'dropIndex':\n case 'dropDefault':\n return 'drop';\n case 'createTable':\n return 'table';\n case 'addColumn':\n return 'column';\n case 'alterColumnType':\n case 'setNotNull':\n case 'dropNotNull':\n case 'setDefault':\n return 'alter';\n case 'addPrimaryKey':\n return 'primaryKey';\n case 'addUnique':\n return 'unique';\n case 'createIndex':\n return 'index';\n case 'addForeignKey':\n return 'foreignKey';\n case 'rawSql': {\n // Type ops lifted through `RawSqlCall` by `storageTypePlanCallStrategy`\n // to preserve the codec-emitted label and precheck/postcheck.\n // Classification falls back to inspecting the underlying op's target\n // details (`objectType: 'type'`).\n const op = (\n call as {\n op?: {\n target?: { details?: { objectType?: string } };\n };\n }\n ).op;\n const objectType = op?.target?.details?.objectType;\n if (objectType === 'type') return 'dep';\n return 'alter';\n }\n default:\n return 'alter';\n }\n}\n\n/** Stable lexical key used to order issues within the same kind bucket. */\nfunction issueKey(issue: SchemaIssue): string {\n const table = 'table' in issue && typeof issue.table === 'string' ? issue.table : '';\n const column = 'column' in issue && typeof issue.column === 'string' ? issue.column : '';\n const name =\n 'indexOrConstraint' in issue && typeof issue.indexOrConstraint === 'string'\n ? issue.indexOrConstraint\n : '';\n return `${table}\\u0000${column}\\u0000${name}`;\n}\n\n// When no policy is explicitly supplied (test-only path; production callers\n// always pass one), allow every class so strategies that gate on\n// `'data'` (data-safe placeholders) still fire — the test is treated as\n// trusted. Filtering of actual emitted calls only runs when a policy was\n// explicitly provided (see `policyProvided` below).\nconst DEFAULT_POLICY: MigrationOperationPolicy = {\n allowedOperationClasses: ['additive', 'widening', 'destructive', 'data'],\n};\n\nfunction emptySchemaIR(): SqlSchemaIR {\n return { tables: {} };\n}\n\nfunction conflictKindForCall(call: PostgresOpFactoryCall): SqlPlannerConflict['kind'] {\n switch (call.factoryName) {\n case 'alterColumnType':\n return 'typeMismatch';\n case 'setNotNull':\n case 'dropNotNull':\n return 'nullabilityConflict';\n case 'addForeignKey':\n case 'dropConstraint':\n return 'foreignKeyConflict';\n case 'createIndex':\n case 'dropIndex':\n return 'indexIncompatible';\n default:\n return 'missingButNonAdditive';\n }\n}\n\nfunction locationForCall(call: PostgresOpFactoryCall): SqlPlannerConflict['location'] | undefined {\n // Most Postgres call classes expose `tableName`/`columnName`/`indexName`/\n // `constraintName` as readonly fields. We avoid `toOp()` here because a\n // `DataTransformCall` intentionally throws from `toOp`.\n const anyCall = call as unknown as {\n tableName?: string;\n columnName?: string;\n indexName?: string;\n constraintName?: string;\n typeName?: string;\n };\n const location: {\n table?: string;\n column?: string;\n index?: string;\n constraint?: string;\n type?: string;\n } = {};\n if (anyCall.tableName) location.table = anyCall.tableName;\n if (anyCall.columnName) location.column = anyCall.columnName;\n if (anyCall.indexName) location.index = anyCall.indexName;\n if (anyCall.constraintName) location.constraint = anyCall.constraintName;\n if (anyCall.typeName) location.type = anyCall.typeName;\n return Object.keys(location).length > 0 ? (location as SqlPlannerConflictLocation) : undefined;\n}\n\nfunction conflictForDisallowedCall(\n call: PostgresOpFactoryCall,\n allowed: readonly string[],\n): SqlPlannerConflict {\n const summary = `Operation \"${call.label}\" requires class \"${call.operationClass}\", but policy allows only: ${allowed.join(', ')}`;\n const location = locationForCall(call);\n return {\n kind: conflictKindForCall(call),\n summary,\n why: 'Use `migration new` to author a custom migration for this change.',\n ...(location ? { location } : {}),\n };\n}\n\nexport function planIssues(\n options: IssuePlannerOptions,\n): Result<IssuePlannerValue, readonly SqlPlannerConflict[]> {\n // When no policy is supplied, `planIssues` treats the call as trusted (the\n // caller — typically a test — has already vetted the issues). Only explicit\n // policies gate operation classes into conflicts.\n // `PostgresMigrationPlanner` always passes an explicit policy.\n const policyProvided = options.policy !== undefined;\n const policy = options.policy ?? DEFAULT_POLICY;\n const schema = options.schema ?? emptySchemaIR();\n const frameworkComponents = options.frameworkComponents ?? [];\n\n const context: StrategyContext = {\n toContract: options.toContract,\n fromContract: options.fromContract,\n schemaName: options.schemaName,\n codecHooks: options.codecHooks,\n storageTypes: options.storageTypes,\n schema,\n policy,\n frameworkComponents,\n };\n\n const strategies = options.strategies ?? postgresPlannerStrategies;\n\n let remaining = options.issues;\n const recipeCalls: PostgresOpFactoryCall[] = [];\n const bucketablePatternCalls: PostgresOpFactoryCall[] = [];\n\n for (const strategy of strategies) {\n const result = strategy(remaining, context);\n if (result.kind === 'match') {\n remaining = result.issues;\n if (result.recipe) {\n recipeCalls.push(...result.calls);\n } else {\n bucketablePatternCalls.push(...result.calls);\n }\n }\n }\n\n const sorted = [...remaining].sort((a, b) => {\n const kindDelta = issueOrder(a) - issueOrder(b);\n if (kindDelta !== 0) return kindDelta;\n const keyA = issueKey(a);\n const keyB = issueKey(b);\n return keyA < keyB ? -1 : keyA > keyB ? 1 : 0;\n });\n\n const defaultCalls: PostgresOpFactoryCall[] = [];\n const conflicts: SqlPlannerConflict[] = [];\n\n for (const issue of sorted) {\n const result = mapIssueToCall(issue, context);\n if (result.ok) {\n defaultCalls.push(...result.value);\n } else {\n conflicts.push(result.failure);\n }\n }\n\n // Policy gating: drop calls whose operation class is not allowed and\n // surface a conflict describing the disallowed op. Applies to both strategy\n // output and default-mapped output. Only active when the caller explicitly\n // supplied a policy — direct unit-test invocations (which pass no policy)\n // stay as pass-through and keep destructive recipe steps intact.\n const allowed = policy.allowedOperationClasses;\n let gatedDefault = defaultCalls;\n let gatedRecipe = recipeCalls;\n let gatedBucketable = bucketablePatternCalls;\n if (policyProvided) {\n const keepIfAllowed = (bucket: PostgresOpFactoryCall[]) => (call: PostgresOpFactoryCall) => {\n if (allowed.includes(call.operationClass)) {\n bucket.push(call);\n return;\n }\n conflicts.push(conflictForDisallowedCall(call, allowed));\n };\n const gatedDefaultBucket: PostgresOpFactoryCall[] = [];\n const gatedRecipeBucket: PostgresOpFactoryCall[] = [];\n const gatedBucketableBucket: PostgresOpFactoryCall[] = [];\n defaultCalls.forEach(keepIfAllowed(gatedDefaultBucket));\n recipeCalls.forEach(keepIfAllowed(gatedRecipeBucket));\n bucketablePatternCalls.forEach(keepIfAllowed(gatedBucketableBucket));\n gatedDefault = gatedDefaultBucket;\n gatedRecipe = gatedRecipeBucket;\n gatedBucketable = gatedBucketableBucket;\n }\n\n if (conflicts.length > 0) {\n return notOk(conflicts);\n }\n\n // Recipe strategies (`nativeEnumPlanCallStrategy`,\n // `notNullBackfillCallStrategy`, etc.) emit a cohesive sequence that must\n // stay contiguous. They are inserted at a single pattern slot. Non-recipe\n // pattern strategies (`dependencyInstallCallStrategy`,\n // `storageTypePlanCallStrategy`, `notNullAddColumnCallStrategy`) produce\n // individually classifiable calls that slot into DDL buckets alongside\n // default-mapped calls.\n const combinedBucketable = [...gatedDefault, ...gatedBucketable];\n const byCategory = (cat: CallCategory) =>\n combinedBucketable.filter((c) => classifyCall(c) === cat);\n\n const calls: PostgresOpFactoryCall[] = [\n ...byCategory('dep'),\n ...byCategory('drop'),\n ...byCategory('table'),\n ...byCategory('column'),\n ...gatedRecipe,\n ...byCategory('alter'),\n ...byCategory('primaryKey'),\n ...byCategory('unique'),\n ...byCategory('index'),\n ...byCategory('foreignKey'),\n ];\n\n return ok({ calls });\n}\n"],"mappings":";;;;;;;;;;;;;AAmBA,SAAgB,mBACd,YACA,MACA,QACA,OAC2B;CAC3B,OAAO;EACL;EACA;EACA;EACA,GAAG,UAAU,SAAS,MAAM;EAC7B;;;;ACdH,SAAgB,gCACd,QACA,WACA,YAIA;CACA,OAAO;EACL,IAAI,UAAU,UAAU,GAAG;EAC3B,OAAO,cAAc,WAAW,MAAM;EACtC,SAAS,eAAe,WAAW,YAAY;EAC/C,QAAQ;GACN,IAAI;GACJ,SAAS,mBAAmB,SAAS,WAAW,OAAO;GACxD;EACF;;AAGH,SAAgB,mDAAmD,SAQV;CACvD,MAAM,EAAE,QAAQ,WAAW,YAAY,QAAQ,YAAY,cAAc,qBACvE;CACF,MAAM,YAAY,iBAAiB,QAAQ,UAAU;CAErD,OAAO;EACL,GAAG,gCAAgC,QAAQ,WAAW,WAAW;EACjE,gBAAgB;EAChB,UAAU,CACR;G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,GAAG,cAAc,GAAG,gBAAgB;CAChE,MAAM,cAAc,QAClB,mBAAmB,QAAQ,MAAM,aAAa,EAAE,KAAK,IAAI;CAe3D,OAAO,GAAG,EAAE,OAAA;EAZV,GAAG,WAAW,MAAM;EACpB,GAAG,WAAW,OAAO;EACrB,GAAG,WAAW,QAAQ;EACtB,GAAG,WAAW,SAAS;EACvB,GAAG;EACH,GAAG,WAAW,QAAQ;EACtB,GAAG,WAAW,aAAa;EAC3B,GAAG,WAAW,SAAS;EACvB,GAAG,WAAW,QAAQ;EACtB,GAAG,WAAW,aAAa;EAGZ,EAAE,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-DnzPpv1j.mjs","names":[],"sources":["../src/core/migrations/planner.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport type {\n MigrationOperationPolicy,\n SqlMigrationPlannerPlanOptions,\n SqlPlannerFailureResult,\n} from '@prisma-next/family-sql/control';\nimport {\n extractCodecControlHooks,\n planFieldEventOperations,\n plannerFailure,\n} from '@prisma-next/family-sql/control';\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 { parsePostgresDefault } from '../default-normalizer';\nimport { normalizeSchemaNativeType } from '../native-type-normalizer';\nimport { readExistingEnumValues } from './enum-planning';\nimport { planIssues } from './issue-planner';\nimport { TypeScriptRenderablePostgresMigration } from './planner-produced-postgres-migration';\nimport { postgresPlannerStrategies } from './planner-strategies';\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\ninterface PlannerConfig {\n readonly defaultSchema: string;\n}\n\nconst DEFAULT_PLANNER_CONFIG: PlannerConfig = {\n defaultSchema: 'public',\n};\n\nexport function createPostgresMigrationPlanner(\n config: Partial<PlannerConfig> = {},\n): PostgresMigrationPlanner {\n return new PostgresMigrationPlanner({\n ...DEFAULT_PLANNER_CONFIG,\n ...config,\n });\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 | { readonly kind: 'success'; readonly plan: TypeScriptRenderablePostgresMigration }\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 constructor(private readonly config: PlannerConfig) {}\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 );\n }\n\n private planSql(options: SqlMigrationPlannerPlanOptions): PostgresPlanResult {\n const schemaName = options.schemaName ?? this.config.defaultSchema;\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 const result = planIssues({\n issues: schemaIssues,\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-emitted calls already conform to `OpFactoryCall` — render +\n // toOp + importRequirements ride directly through the same emit path\n // as structural ops, no `RawSqlCall` wrap.\n const calls = [...result.value.calls, ...fieldEventOps];\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 ),\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 resolveExistingEnumValues: (schema, enumType) =>\n readExistingEnumValues(schema, enumType.nativeType),\n };\n const verifyResult = verifySqlSchema(verifyOptions);\n return verifyResult.schema.issues;\n }\n}\n"],"mappings":";;;;;;;;AA4CA,MAAM,yBAAwC,EAC5C,eAAe,UAChB;AAED,SAAgB,+BACd,SAAi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AO,eAAe,CACpB;GACE,MAAM;GACN,SAAS;GACT,KAAK;GACN,CACF,CAAC;EAEJ,OAAO;;CAGT,oBAA4B,SAA+D;EAIzF,MAAM,UAAU,QAAQ,OAAO;EAC/B,MAAM,SAAS,QAAQ,SAAS,WAAW,IAAI,QAAQ,SAAS,cAAc;EAa9E,OADqB,gBAAgB;GAVnC,UAAU,QAAQ;GAClB,QAAQ,QAAQ;GAChB;GACA,sCAAsB,IAAI,KAAK;GAC/B,qBAAqB,QAAQ;GAC7B,kBAAkB;GAClB,qBAAqB;GACrB,4BAA4B,QAAQ,aAClC,uBAAuB,QAAQ,SAAS,WAAW;GAEL,CAC/B,CAAC,OAAO"}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
//#region src/core/migrations/planner-schema-lookup.ts
|
|
2
|
-
function buildSchemaLookupMap(schema) {
|
|
3
|
-
const map = /* @__PURE__ */ new Map();
|
|
4
|
-
for (const [tableName, table] of Object.entries(schema.tables)) map.set(tableName, buildSchemaTableLookup(table));
|
|
5
|
-
return map;
|
|
6
|
-
}
|
|
7
|
-
function buildSchemaTableLookup(table) {
|
|
8
|
-
return {
|
|
9
|
-
uniqueKeys: new Set(table.uniques.map((u) => u.columns.join(","))),
|
|
10
|
-
indexKeys: new Set(table.indexes.map((i) => i.columns.join(","))),
|
|
11
|
-
uniqueIndexKeys: new Set(table.indexes.filter((i) => i.unique).map((i) => i.columns.join(","))),
|
|
12
|
-
fkKeys: new Set(table.foreignKeys.map((fk) => `${fk.columns.join(",")}|${fk.referencedTable}|${fk.referencedColumns.join(",")}`))
|
|
13
|
-
};
|
|
14
|
-
}
|
|
15
|
-
function hasUniqueConstraint(lookup, columns) {
|
|
16
|
-
const key = columns.join(",");
|
|
17
|
-
return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);
|
|
18
|
-
}
|
|
19
|
-
function hasIndex(lookup, columns) {
|
|
20
|
-
const key = columns.join(",");
|
|
21
|
-
return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);
|
|
22
|
-
}
|
|
23
|
-
function hasForeignKey(lookup, fk) {
|
|
24
|
-
return lookup.fkKeys.has(`${fk.columns.join(",")}|${fk.references.table}|${fk.references.columns.join(",")}`);
|
|
25
|
-
}
|
|
26
|
-
//#endregion
|
|
27
|
-
export { hasUniqueConstraint as i, hasForeignKey as n, hasIndex as r, buildSchemaLookupMap as t };
|
|
28
|
-
|
|
29
|
-
//# sourceMappingURL=planner-schema-lookup--u9whY_Y.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-schema-lookup--u9whY_Y.mjs","names":[],"sources":["../src/core/migrations/planner-schema-lookup.ts"],"sourcesContent":["import type { ForeignKey } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\n\n/**\n * Pre-computed lookup sets for a schema table's constraints.\n * Converts O(n*m) linear scans to O(1) Set lookups per constraint check.\n */\nexport interface SchemaTableLookup {\n readonly uniqueKeys: Set<string>;\n readonly indexKeys: Set<string>;\n readonly uniqueIndexKeys: Set<string>;\n readonly fkKeys: Set<string>;\n}\n\nexport function buildSchemaLookupMap(schema: SqlSchemaIR): ReadonlyMap<string, SchemaTableLookup> {\n const map = new Map<string, SchemaTableLookup>();\n for (const [tableName, table] of Object.entries(schema.tables)) {\n map.set(tableName, buildSchemaTableLookup(table));\n }\n return map;\n}\n\nfunction buildSchemaTableLookup(table: SqlSchemaIR['tables'][string]): SchemaTableLookup {\n const uniqueKeys = new Set(table.uniques.map((u) => u.columns.join(',')));\n const indexKeys = new Set(table.indexes.map((i) => i.columns.join(',')));\n const uniqueIndexKeys = new Set(\n table.indexes.filter((i) => i.unique).map((i) => i.columns.join(',')),\n );\n const fkKeys = new Set(\n table.foreignKeys.map(\n (fk) => `${fk.columns.join(',')}|${fk.referencedTable}|${fk.referencedColumns.join(',')}`,\n ),\n );\n return { uniqueKeys, indexKeys, uniqueIndexKeys, fkKeys };\n}\n\nexport function hasUniqueConstraint(\n lookup: SchemaTableLookup,\n columns: readonly string[],\n): boolean {\n const key = columns.join(',');\n return lookup.uniqueKeys.has(key) || lookup.uniqueIndexKeys.has(key);\n}\n\nexport function hasIndex(lookup: SchemaTableLookup, columns: readonly string[]): boolean {\n const key = columns.join(',');\n return lookup.indexKeys.has(key) || lookup.uniqueKeys.has(key);\n}\n\nexport function hasForeignKey(lookup: SchemaTableLookup, fk: ForeignKey): boolean {\n return lookup.fkKeys.has(\n `${fk.columns.join(',')}|${fk.references.table}|${fk.references.columns.join(',')}`,\n );\n}\n"],"mappings":";AAcA,SAAgB,qBAAqB,QAA6D;CAChG,MAAM,sBAAM,IAAI,KAAgC;CAChD,KAAK,MAAM,CAAC,WAAW,UAAU,OAAO,QAAQ,OAAO,OAAO,EAC5D,IAAI,IAAI,WAAW,uBAAuB,MAAM,CAAC;CAEnD,OAAO;;AAGT,SAAS,uBAAuB,OAAyD;CAWvF,OAAO;EAAE,YAAA,IAVc,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAUrD;EAAE,WAAA,IATC,IAAI,MAAM,QAAQ,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CASzC;EAAE,iBAAA,IARJ,IAC1B,MAAM,QAAQ,QAAQ,MAAM,EAAE,OAAO,CAAC,KAAK,MAAM,EAAE,QAAQ,KAAK,IAAI,CAAC,CAOxB;EAAE,QAAA,IAL9B,IACjB,MAAM,YAAY,KACf,OAAO,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,gBAAgB,GAAG,GAAG,kBAAkB,KAAK,IAAI,GACxF,CAEoD;EAAE;;AAG3D,SAAgB,oBACd,QACA,SACS;CACT,MAAM,MAAM,QAAQ,KAAK,IAAI;CAC7B,OAAO,OAAO,WAAW,IAAI,IAAI,IAAI,OAAO,gBAAgB,IAAI,IAAI;;AAGtE,SAAgB,SAAS,QAA2B,SAAqC;CACvF,MAAM,MAAM,QAAQ,KAAK,IAAI;CAC7B,OAAO,OAAO,UAAU,IAAI,IAAI,IAAI,OAAO,WAAW,IAAI,IAAI;;AAGhE,SAAgB,cAAc,QAA2B,IAAyB;CAChF,OAAO,OAAO,OAAO,IACnB,GAAG,GAAG,QAAQ,KAAK,IAAI,CAAC,GAAG,GAAG,WAAW,MAAM,GAAG,GAAG,WAAW,QAAQ,KAAK,IAAI,GAClF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"planner-sql-checks-Cd016Ycs.mjs","names":[],"sources":["../src/core/migrations/planner-type-resolution.ts","../src/core/migrations/planner-sql-checks.ts"],"sourcesContent":["import {\n isPostgresEnumStorageEntry,\n type PostgresEnumStorageEntry,\n type StorageColumn,\n type StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\n\nexport type ResolvedColumnTypeMetadata = Pick<\n StorageColumn,\n 'nativeType' | 'codecId' | 'typeParams'\n>;\n\nexport function resolveColumnTypeMetadata(\n column: StorageColumn,\n storageTypes: Readonly<Record<string, StorageTypeInstance | PostgresEnumStorageEntry>>,\n): ResolvedColumnTypeMetadata {\n if (!column.typeRef) {\n return column;\n }\n\n const referencedType = storageTypes[column.typeRef];\n if (!referencedType) {\n return column;\n }\n\n if (isPostgresEnumStorageEntry(referencedType)) {\n // Enum types are referenced by name (`quoteIdentifier(nativeType)`),\n // not via parameterised codec expansion. The structural shape\n // carries `codecId` as an enumerable property (mirroring the\n // codec-typed view); `typeParams` is intentionally omitted here so\n // `expandParameterizedTypeSql` does not try to look up a\n // (deliberately absent) `expandNativeType` hook for `pg/enum@*`.\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n };\n }\n\n return {\n codecId: referencedType.codecId,\n nativeType: referencedType.nativeType,\n typeParams: referencedType.typeParams,\n };\n}\n","import type { CodecControlHooks } from '@prisma-next/family-sql/control';\nimport type {\n PostgresEnumStorageEntry,\n StorageColumn,\n StorageTypeInstance,\n} from '@prisma-next/sql-contract/types';\nimport { escapeLiteral, quoteIdentifier } from '../sql-utils';\nimport { resolveColumnTypeMetadata } from './planner-type-resolution';\n\nexport function qualifyTableName(schema: string, table: string): string {\n return `${quoteIdentifier(schema)}.${quoteIdentifier(table)}`;\n}\n\nexport function toRegclassLiteral(schema: string, name: string): string {\n const regclass = `${quoteIdentifier(schema)}.${quoteIdentifier(name)}`;\n return `'${escapeLiteral(regclass)}'`;\n}\n\n/**\n * When `table` is omitted the check matches by name + schema across all tables.\n * Pass `table` to scope the check to a single table (prevents false matches on\n * identically-named constraints in different tables).\n */\nexport function constraintExistsCheck({\n constraintName,\n schema,\n table,\n exists = true,\n}: {\n constraintName: string;\n schema: string;\n table?: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? 'EXISTS' : 'NOT EXISTS';\n const tableFilter = table\n ? `AND c.conrelid = to_regclass(${toRegclassLiteral(schema, table)})`\n : '';\n return `SELECT ${existsClause} (\n SELECT 1 FROM pg_constraint c\n JOIN pg_namespace n ON c.connamespace = n.oid\n WHERE c.conname = '${escapeLiteral(constraintName)}'\n AND n.nspname = '${escapeLiteral(schema)}'\n ${tableFilter}\n)`;\n}\n\nexport function columnExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const existsClause = exists ? '' : 'NOT ';\n return `SELECT ${existsClause}EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n)`;\n}\n\nexport function columnNullabilityCheck({\n schema,\n table,\n column,\n nullable,\n}: {\n schema: string;\n table: string;\n column: string;\n nullable: boolean;\n}): string {\n const expected = nullable ? 'YES' : 'NO';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND is_nullable = '${expected}'\n)`;\n}\n\nexport function tableIsEmptyCheck(qualifiedTableName: string): string {\n return `SELECT NOT EXISTS (SELECT 1 FROM ${qualifiedTableName} LIMIT 1)`;\n}\n\nexport function columnHasNoDefaultCheck(opts: {\n schema: string;\n table: string;\n column: string;\n}): string {\n return `SELECT NOT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(opts.schema)}'\n AND table_name = '${escapeLiteral(opts.table)}'\n AND column_name = '${escapeLiteral(opts.column)}'\n AND column_default IS NOT NULL\n)`;\n}\n\nconst FORMAT_TYPE_DISPLAY: ReadonlyMap<string, string> = new Map([\n ['int2', 'smallint'],\n ['int4', 'integer'],\n ['int8', 'bigint'],\n ['float4', 'real'],\n ['float8', 'double precision'],\n ['bool', 'boolean'],\n ['timestamp', 'timestamp without time zone'],\n ['timestamptz', 'timestamp with time zone'],\n ['time', 'time without time zone'],\n ['timetz', 'time with time zone'],\n]);\n\nconst UNQUOTED_POSTGRES_IDENTIFIER_PATTERN = /^[a-z_][a-z0-9_$]*$/;\n\nconst POSTGRES_RESERVED_IDENTIFIER_WORDS = new Set([\n 'all',\n 'analyse',\n 'analyze',\n 'and',\n 'any',\n 'array',\n 'as',\n 'asc',\n 'asymmetric',\n 'authorization',\n 'between',\n 'binary',\n 'both',\n 'case',\n 'cast',\n 'check',\n 'collate',\n 'column',\n 'constraint',\n 'create',\n 'current_catalog',\n 'current_date',\n 'current_role',\n 'current_time',\n 'current_timestamp',\n 'current_user',\n 'default',\n 'deferrable',\n 'desc',\n 'distinct',\n 'do',\n 'else',\n 'end',\n 'except',\n 'false',\n 'fetch',\n 'for',\n 'foreign',\n 'freeze',\n 'from',\n 'full',\n 'grant',\n 'group',\n 'having',\n 'ilike',\n 'in',\n 'initially',\n 'inner',\n 'intersect',\n 'into',\n 'is',\n 'isnull',\n 'join',\n 'lateral',\n 'leading',\n 'left',\n 'like',\n 'limit',\n 'localtime',\n 'localtimestamp',\n 'natural',\n 'not',\n 'notnull',\n 'null',\n 'offset',\n 'on',\n 'only',\n 'or',\n 'order',\n 'outer',\n 'overlaps',\n 'placing',\n 'primary',\n 'references',\n 'right',\n 'select',\n 'session_user',\n 'similar',\n 'some',\n 'symmetric',\n 'table',\n 'then',\n 'to',\n 'trailing',\n 'true',\n 'union',\n 'unique',\n 'user',\n 'using',\n 'variadic',\n 'verbose',\n 'when',\n 'where',\n 'window',\n 'with',\n]);\n\nfunction formatUserDefinedTypeName(identifier: string): string {\n if (\n UNQUOTED_POSTGRES_IDENTIFIER_PATTERN.test(identifier) &&\n !POSTGRES_RESERVED_IDENTIFIER_WORDS.has(identifier)\n ) {\n return identifier;\n }\n\n return quoteIdentifier(identifier);\n}\n\nexport function buildExpectedFormatType(\n column: StorageColumn,\n codecHooks: Map<string, CodecControlHooks>,\n storageTypes: Record<string, StorageTypeInstance | PostgresEnumStorageEntry> = {},\n): string {\n const resolved = resolveColumnTypeMetadata(column, storageTypes);\n\n if (resolved.typeParams && resolved.codecId) {\n const hooks = codecHooks.get(resolved.codecId);\n if (hooks?.expandNativeType) {\n return hooks.expandNativeType({\n nativeType: resolved.nativeType,\n codecId: resolved.codecId,\n typeParams: resolved.typeParams,\n });\n }\n }\n\n if (column.typeRef) {\n return formatUserDefinedTypeName(resolved.nativeType);\n }\n\n return FORMAT_TYPE_DISPLAY.get(resolved.nativeType) ?? resolved.nativeType;\n}\n\nexport function columnTypeCheck({\n schema,\n table,\n column,\n expectedType,\n}: {\n schema: string;\n table: string;\n column: string;\n expectedType: string;\n}): string {\n return `SELECT EXISTS (\n SELECT 1\n FROM pg_attribute a\n JOIN pg_class c ON c.oid = a.attrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND a.attname = '${escapeLiteral(column)}'\n AND format_type(a.atttypid, a.atttypmod) = '${escapeLiteral(expectedType)}'\n AND NOT a.attisdropped\n)`;\n}\n\nexport function columnDefaultExistsCheck({\n schema,\n table,\n column,\n exists = true,\n}: {\n schema: string;\n table: string;\n column: string;\n exists?: boolean;\n}): string {\n const nullCheck = exists ? 'IS NOT NULL' : 'IS NULL';\n return `SELECT EXISTS (\n SELECT 1\n FROM information_schema.columns\n WHERE table_schema = '${escapeLiteral(schema)}'\n AND table_name = '${escapeLiteral(table)}'\n AND column_name = '${escapeLiteral(column)}'\n AND column_default ${nullCheck}\n)`;\n}\n\nexport function tableHasPrimaryKeyCheck(\n schema: string,\n table: string,\n exists: boolean,\n constraintName?: string,\n): string {\n const comparison = exists ? '' : 'NOT ';\n const constraintFilter = constraintName\n ? `AND c2.relname = '${escapeLiteral(constraintName)}'`\n : '';\n return `SELECT ${comparison}EXISTS (\n SELECT 1\n FROM pg_index i\n JOIN pg_class c ON c.oid = i.indrelid\n JOIN pg_namespace n ON n.oid = c.relnamespace\n LEFT JOIN pg_class c2 ON c2.oid = i.indexrelid\n WHERE n.nspname = '${escapeLiteral(schema)}'\n AND c.relname = '${escapeLiteral(table)}'\n AND i.indisprimary\n ${constraintFilter}\n)`;\n}\n"],"mappings":";;;AAYA,SAAgB,0BACd,QACA,cAC4B;CAC5B,IAAI,CAAC,OAAO,SACV,OAAO;CAGT,MAAM,iBAAiB,aAAa,OAAO;CAC3C,IAAI,CAAC,gBACH,OAAO;CAGT,IAAI,2BAA2B,eAAe,EAO5C,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;EAC5B;CAGH,OAAO;EACL,SAAS,eAAe;EACxB,YAAY,eAAe;EAC3B,YAAY,eAAe;EAC5B;;;;ACjCH,SAAgB,iBAAiB,QAAgB,OAAuB;CACtE,OAAO,GAAG,gBAAgB,OAAO,CAAC,GAAG,gBAAgB,MAAM;;AAG7D,SAAgB,kBAAkB,QAAgB,MAAsB;CAEtE,OAAO,IAAI,cAAc,GADL,gBAAgB,OAAO,CAAC,GAAG,gBAAgB,KAAK,GAClC,CAAC;;;;;;;AAQrC,SAAgB,sBAAsB,EACpC,gBACA,QACA,O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;yBACtB,UAAU;;;AAInC,SAAgB,wBACd,QACA,OACA,QACA,gBACQ;CACR,MAAM,aAAa,SAAS,KAAK;CACjC,MAAM,mBAAmB,iBACrB,qBAAqB,cAAc,eAAe,CAAC,KACnD;CACJ,OAAO,UAAU,WAAW;;;;;;uBAMP,cAAc,OAAO,CAAC;uBACtB,cAAc,MAAM,CAAC;;MAEtC,iBAAiB"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { t as PostgresEnumType } from "./postgres-enum-type-DS-KLVRH.mjs";
|
|
2
|
-
import { n as postgresAuthoringEntityTypes } from "./descriptor-meta-DFUCClk_.mjs";
|
|
3
|
-
import { SqlContractSerializerBase } from "@prisma-next/family-sql/ir";
|
|
4
|
-
//#region src/core/postgres-contract-serializer.ts
|
|
5
|
-
/**
|
|
6
|
-
* Build the hydration registry from this target pack's literal
|
|
7
|
-
* `postgresAuthoringEntityTypes`. Extension-pack-contributed entity
|
|
8
|
-
* types do not reach this registry today; the surface is honest for
|
|
9
|
-
* in-tree consumers (Postgres pack only) and the slot stays
|
|
10
|
-
* deserializable because the family-layer validator's
|
|
11
|
-
* `StorageTypeEntrySchema` only admits kinds whose factory the
|
|
12
|
-
* Postgres pack already ships.
|
|
13
|
-
*
|
|
14
|
-
* Future open (F14): lift the registry build to descriptor-composition
|
|
15
|
-
* time, threading the composed `AuthoringContributions.entityTypes`
|
|
16
|
-
* from extension packs, so a real extension pack shipping a
|
|
17
|
-
* round-trip-needing entity type can be deserialized end-to-end.
|
|
18
|
-
* Earned by the first such extension pack in tree.
|
|
19
|
-
*/
|
|
20
|
-
function buildPostgresEntityTypeRegistry() {
|
|
21
|
-
const ctx = {
|
|
22
|
-
family: "sql",
|
|
23
|
-
target: "postgres"
|
|
24
|
-
};
|
|
25
|
-
const registry = /* @__PURE__ */ new Map();
|
|
26
|
-
for (const descriptor of Object.values(postgresAuthoringEntityTypes)) {
|
|
27
|
-
if (descriptor.kind !== "entity") continue;
|
|
28
|
-
if (!("factory" in descriptor.output)) continue;
|
|
29
|
-
const factory = descriptor.output.factory;
|
|
30
|
-
registry.set(descriptor.discriminator, (entry) => {
|
|
31
|
-
if (entry instanceof PostgresEnumType) return entry;
|
|
32
|
-
return factory(entry, ctx);
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return registry;
|
|
36
|
-
}
|
|
37
|
-
/**
|
|
38
|
-
* Postgres target `ContractSerializer` concretion. Inherits the full
|
|
39
|
-
* SQL-family deserialization pipeline (structural validation +
|
|
40
|
-
* hydration walker that materialises the SQL Contract IR class
|
|
41
|
-
* hierarchy from the validated JSON envelope). Polymorphic
|
|
42
|
-
* `storage.types` entries hydrate through the pack contribution registry
|
|
43
|
-
* keyed by each entity type's declared `discriminator` (matching the
|
|
44
|
-
* enumerable `kind` on the persisted JSON envelope).
|
|
45
|
-
*
|
|
46
|
-
* `serializeContract` falls through to the family-base default —
|
|
47
|
-
* Postgres' contract is JSON-clean today (`PostgresEnumType`
|
|
48
|
-
* instances are frozen with enumerable own properties, so
|
|
49
|
-
* `JSON.stringify` produces the canonical envelope shape). Once
|
|
50
|
-
* target-only fields land (e.g. per-target derived storage fields)
|
|
51
|
-
* this is the home for stripping them from the persisted envelope.
|
|
52
|
-
*/
|
|
53
|
-
var PostgresContractSerializer = class extends SqlContractSerializerBase {
|
|
54
|
-
constructor() {
|
|
55
|
-
super(buildPostgresEntityTypeRegistry());
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
//#endregion
|
|
59
|
-
export { PostgresContractSerializer as t };
|
|
60
|
-
|
|
61
|
-
//# sourceMappingURL=postgres-contract-serializer-D5VJk6lo.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postgres-contract-serializer-D5VJk6lo.mjs","names":[],"sources":["../src/core/postgres-contract-serializer.ts"],"sourcesContent":["import type { Contract } from '@prisma-next/contract/types';\nimport {\n SqlContractSerializerBase,\n type SqlEntityHydrationFactory,\n} from '@prisma-next/family-sql/ir';\nimport type { AuthoringEntityContext } from '@prisma-next/framework-components/authoring';\nimport type { SqlStorage, SqlStorageTypeEntry } from '@prisma-next/sql-contract/types';\nimport { postgresAuthoringEntityTypes } from './authoring';\nimport { PostgresEnumType } from './postgres-enum-type';\n\n/**\n * Build the hydration registry from this target pack's literal\n * `postgresAuthoringEntityTypes`. Extension-pack-contributed entity\n * types do not reach this registry today; the surface is honest for\n * in-tree consumers (Postgres pack only) and the slot stays\n * deserializable because the family-layer validator's\n * `StorageTypeEntrySchema` only admits kinds whose factory the\n * Postgres pack already ships.\n *\n * Future open (F14): lift the registry build to descriptor-composition\n * time, threading the composed `AuthoringContributions.entityTypes`\n * from extension packs, so a real extension pack shipping a\n * round-trip-needing entity type can be deserialized end-to-end.\n * Earned by the first such extension pack in tree.\n */\nfunction buildPostgresEntityTypeRegistry(): ReadonlyMap<string, SqlEntityHydrationFactory> {\n const ctx: AuthoringEntityContext = { family: 'sql', target: 'postgres' };\n const registry = new Map<string, SqlEntityHydrationFactory>();\n for (const descriptor of Object.values(postgresAuthoringEntityTypes)) {\n if (descriptor.kind !== 'entity') {\n continue;\n }\n if (!('factory' in descriptor.output)) {\n continue;\n }\n const factory = descriptor.output.factory as (\n input: never,\n ctx: AuthoringEntityContext,\n ) => SqlStorageTypeEntry;\n registry.set(descriptor.discriminator, (entry) => {\n if (entry instanceof PostgresEnumType) {\n return entry;\n }\n return factory(entry as never, ctx);\n });\n }\n return registry;\n}\n\n/**\n * Postgres target `ContractSerializer` concretion. Inherits the full\n * SQL-family deserialization pipeline (structural validation +\n * hydration walker that materialises the SQL Contract IR class\n * hierarchy from the validated JSON envelope). Polymorphic\n * `storage.types` entries hydrate through the pack contribution registry\n * keyed by each entity type's declared `discriminator` (matching the\n * enumerable `kind` on the persisted JSON envelope).\n *\n * `serializeContract` falls through to the family-base default —\n * Postgres' contract is JSON-clean today (`PostgresEnumType`\n * instances are frozen with enumerable own properties, so\n * `JSON.stringify` produces the canonical envelope shape). Once\n * target-only fields land (e.g. per-target derived storage fields)\n * this is the home for stripping them from the persisted envelope.\n */\nexport class PostgresContractSerializer extends SqlContractSerializerBase<Contract<SqlStorage>> {\n constructor() {\n super(buildPostgresEntityTypeRegistry());\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAyBA,SAAS,kCAAkF;CACzF,MAAM,MAA8B;EAAE,QAAQ;EAAO,QAAQ;EAAY;CACzE,MAAM,2BAAW,IAAI,KAAwC;CAC7D,KAAK,MAAM,cAAc,OAAO,OAAO,6BAA6B,EAAE;EACpE,IAAI,WAAW,SAAS,UACtB;EAEF,IAAI,EAAE,aAAa,WAAW,SAC5B;EAEF,MAAM,UAAU,WAAW,OAAO;EAIlC,SAAS,IAAI,WAAW,gBAAgB,UAAU;GAChD,IAAI,iBAAiB,kBACnB,OAAO;GAET,OAAO,QAAQ,OAAgB,IAAI;IACnC;;CAEJ,OAAO;;;;;;;;;;;;;;;;;;AAmBT,IAAa,6BAAb,cAAgD,0BAAgD;CAC9F,cAAc;EACZ,MAAM,iCAAiC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shared-DLYdmYo-.d.mts","names":[],"sources":["../src/core/migrations/operations/shared.ts"],"mappings":";;;;;KAMY,EAAA,GAAK,yBAAA,CAA0B,yBAAA;;AAA3C;;;;;AAcA;;;;;;UAAiB,UAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;EAAA,SACA,QAAA;AAAA;;;;;UAOM,cAAA;EAAA,SACN,IAAA;EAAA,SACA,OAAA;EAAA,SACA,UAAA;IAAA,SACE,KAAA;IAAA,SACA,OAAA;EAAA;EAAA,SAEF,QAAA,GAAW,iBAAA;EAAA,SACX,QAAA,GAAW,iBAAA;AAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"tables-Ce_Q0I8B.mjs","names":[],"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/enums.ts","../src/core/migrations/operations/indexes.ts","../src/core/migrations/operations/tables.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 `createTable` and\n * `addColumn`. Fully materialized: codec expansion and default rendering have\n * 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. The referenced table is\n * assumed to live in the same schema as the constrained table.\n */\nexport interface ForeignKeySpec {\n readonly name: string;\n readonly columns: readonly string[];\n readonly references: {\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) {\n return { description, sql };\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 { quoteIdentifier } from '../../sql-utils';\nimport {\n columnDefaultExistsCheck,\n columnExistsCheck,\n columnNullabilityCheck,\n columnTypeCheck,\n qualifyTableName,\n} from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, step, targetDetails } from './shared';\n\nexport function addColumn(schemaName: string, tableName: string, column: ColumnSpec): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const parts = [\n `ALTER TABLE ${qualified}`,\n `ADD COLUMN ${quoteIdentifier(column.name)} ${column.typeSql}`,\n column.defaultSql,\n column.nullable ? '' : 'NOT NULL',\n ].filter(Boolean);\n const addSql = parts.join(' ');\n\n return {\n id: `column.${tableName}.${column.name}`,\n label: `Add column \"${column.name}\" to \"${tableName}\"`,\n operationClass: 'additive',\n target: targetDetails('column', column.name, schemaName, tableName),\n precheck: [\n step(\n `ensure column \"${column.name}\" is missing`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: column.name,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add column \"${column.name}\"`, addSql)],\n postcheck: [\n step(\n `verify column \"${column.name}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: column.name }),\n ),\n ],\n };\n}\n\nexport function dropColumn(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\n execute: [\n step(\n `drop column \"${columnName}\"`,\n `ALTER TABLE ${qualified} DROP COLUMN ${quoteIdentifier(columnName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify column \"${columnName}\" does not exist`,\n columnExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\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 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): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const usingClause = options.using\n ? ` USING ${options.using}`\n : ` USING ${quoteIdentifier(columnName)}::${options.qualifiedTargetType}`;\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: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\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 columnTypeCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n expectedType: options.formatTypeExpected,\n }),\n ),\n ],\n meta: { warning: 'TABLE_REWRITE' },\n };\n}\n\nexport function setNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n step(\n `ensure no NULL values in \"${columnName}\"`,\n `SELECT NOT EXISTS (SELECT 1 FROM ${qualified} WHERE ${quoteIdentifier(columnName)} IS NULL)`,\n ),\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(\n `verify column \"${columnName}\" is NOT NULL`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: false,\n }),\n ),\n ],\n };\n}\n\nexport function dropNotNull(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\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: [\n step(\n `verify column \"${columnName}\" is nullable`,\n columnNullabilityCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n nullable: true,\n }),\n ),\n ],\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 function setDefault(\n schemaName: string,\n tableName: string,\n columnName: string,\n defaultSql: string,\n operationClass: 'additive' | 'widening' = 'additive',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\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(\n `verify column \"${columnName}\" has a default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: true,\n }),\n ),\n ],\n };\n}\n\nexport function dropDefault(schemaName: string, tableName: string, columnName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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: [\n step(\n `ensure column \"${columnName}\" exists`,\n columnExistsCheck({ schema: schemaName, table: tableName, column: columnName }),\n ),\n ],\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(\n `verify column \"${columnName}\" has no default`,\n columnDefaultExistsCheck({\n schema: schemaName,\n table: tableName,\n column: columnName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import type { ReferentialAction } from '@prisma-next/sql-contract/types';\nimport { quoteIdentifier } from '../../sql-utils';\nimport { constraintExistsCheck, qualifyTableName } from '../planner-sql-checks';\nimport { type ForeignKeySpec, type Op, step, targetDetails } from './shared';\n\nconst REFERENTIAL_ACTION_SQL: Record<ReferentialAction, string> = {\n noAction: 'NO ACTION',\n restrict: 'RESTRICT',\n cascade: 'CASCADE',\n setNull: 'SET NULL',\n setDefault: 'SET DEFAULT',\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(schemaName, 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 function addPrimaryKey(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\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(\n `ensure primary key \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\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: [\n step(\n `verify primary key \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addUnique(\n schemaName: string,\n tableName: string,\n constraintName: string,\n columns: readonly string[],\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnList = columns.map(quoteIdentifier).join(', ');\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(\n `ensure constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [\n step(\n `add unique constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} ADD CONSTRAINT ${quoteIdentifier(constraintName)} UNIQUE (${columnList})`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n };\n}\n\nexport function addForeignKey(schemaName: string, tableName: string, fk: ForeignKeySpec): Op {\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: [\n step(\n `ensure FK \"${fk.name}\" does not exist`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n execute: [step(`add FK \"${fk.name}\"`, renderForeignKeySql(schemaName, tableName, fk))],\n postcheck: [\n step(\n `verify FK \"${fk.name}\" exists`,\n constraintExistsCheck({\n constraintName: fk.name,\n schema: schemaName,\n table: tableName,\n }),\n ),\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 function dropConstraint(\n schemaName: string,\n tableName: string,\n constraintName: string,\n kind: 'foreignKey' | 'unique' | 'primaryKey' = 'unique',\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\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: [\n step(\n `ensure constraint \"${constraintName}\" exists`,\n constraintExistsCheck({ constraintName, schema: schemaName, table: tableName }),\n ),\n ],\n execute: [\n step(\n `drop constraint \"${constraintName}\"`,\n `ALTER TABLE ${qualified} DROP CONSTRAINT ${quoteIdentifier(constraintName)}`,\n ),\n ],\n postcheck: [\n step(\n `verify constraint \"${constraintName}\" does not exist`,\n constraintExistsCheck({\n constraintName,\n schema: schemaName,\n table: tableName,\n exists: false,\n }),\n ),\n ],\n };\n}\n","import { 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 function installExtension(options: {\n readonly extensionName: string;\n readonly invariantId: string;\n readonly id: string;\n readonly label?: string;\n}): Op {\n const { extensionName, invariantId, id } = options;\n const label = options.label ?? `Enable extension \"${extensionName}\"`;\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(\n `verify extension \"${extensionName}\" is not already enabled`,\n `SELECT NOT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n execute: [\n step(\n `create extension \"${extensionName}\"`,\n `CREATE EXTENSION IF NOT EXISTS ${extensionName}`,\n ),\n ],\n postcheck: [\n step(\n `confirm extension \"${extensionName}\" is enabled`,\n `SELECT EXISTS (SELECT 1 FROM pg_extension WHERE extname = '${extensionName}')`,\n ),\n ],\n };\n}\n\nexport function createSchema(schemaName: string): Op {\n return {\n id: `schema.${schemaName}`,\n label: `Create schema \"${schemaName}\"`,\n operationClass: 'additive',\n target: { id: 'postgres' },\n precheck: [],\n execute: [\n step(\n `Create schema \"${schemaName}\"`,\n `CREATE SCHEMA IF NOT EXISTS ${quoteIdentifier(schemaName)}`,\n ),\n ],\n postcheck: [],\n };\n}\n","import { escapeLiteral, qualifyName, quoteIdentifier } from '../../sql-utils';\nimport { type Op, step, targetDetails } from './shared';\n\nfunction enumTypeExistsCheck(schemaName: string, nativeType: string, exists = true): string {\n const clause = exists ? 'EXISTS' : 'NOT EXISTS';\n return `SELECT ${clause} (\n SELECT 1\n FROM pg_type t\n JOIN pg_namespace n ON t.typnamespace = n.oid\n WHERE n.nspname = '${escapeLiteral(schemaName)}'\n AND t.typname = '${escapeLiteral(nativeType)}'\n)`;\n}\n\nexport function createEnumType(\n schemaName: string,\n typeName: string,\n values: readonly string[],\n nativeType: string = typeName,\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n const literalValues = values.map((v) => `'${escapeLiteral(v)}'`).join(', ');\n return {\n id: `type.${typeName}`,\n label: `Create enum type \"${typeName}\"`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(\n `ensure type \"${nativeType}\" does not exist`,\n enumTypeExistsCheck(schemaName, nativeType, false),\n ),\n ],\n execute: [\n step(\n `create enum type \"${typeName}\"`,\n `CREATE TYPE ${qualifiedType} AS ENUM (${literalValues})`,\n ),\n ],\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\n/**\n * `typeName` is the contract-facing type name (used for id/label).\n * `nativeType` is the Postgres type name to mutate (may differ for external types).\n */\nexport function addEnumValues(\n schemaName: string,\n typeName: string,\n nativeType: string,\n values: readonly string[],\n): Op {\n const qualifiedType = qualifyName(schemaName, nativeType);\n return {\n id: `type.${typeName}.addValues`,\n label: `Add values to enum type \"${typeName}\": ${values.join(', ')}`,\n operationClass: 'additive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [\n step(`ensure type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n execute: values.map((value) =>\n step(\n `add value '${value}' to enum \"${nativeType}\"`,\n `ALTER TYPE ${qualifiedType} ADD VALUE '${escapeLiteral(value)}'`,\n ),\n ),\n postcheck: [\n step(`verify type \"${nativeType}\" exists`, enumTypeExistsCheck(schemaName, nativeType)),\n ],\n };\n}\n\nexport function dropEnumType(schemaName: string, typeName: string): Op {\n const qualified = qualifyName(schemaName, typeName);\n return {\n id: `type.${typeName}.drop`,\n label: `Drop enum type \"${typeName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', typeName, schemaName),\n precheck: [step(`ensure type \"${typeName}\" exists`, enumTypeExistsCheck(schemaName, typeName))],\n execute: [step(`drop enum type \"${typeName}\"`, `DROP TYPE ${qualified}`)],\n postcheck: [\n step(`verify type \"${typeName}\" removed`, enumTypeExistsCheck(schemaName, typeName, false)),\n ],\n };\n}\n\nexport function renameType(schemaName: string, fromName: string, toName: string): Op {\n const qualifiedFrom = qualifyName(schemaName, fromName);\n return {\n id: `type.${fromName}.rename`,\n label: `Rename type \"${fromName}\" to \"${toName}\"`,\n operationClass: 'destructive',\n target: targetDetails('type', fromName, schemaName),\n precheck: [\n step(`ensure type \"${fromName}\" exists`, enumTypeExistsCheck(schemaName, fromName)),\n step(\n `ensure type \"${toName}\" does not already exist`,\n enumTypeExistsCheck(schemaName, toName, false),\n ),\n ],\n execute: [\n step(\n `rename type \"${fromName}\" to \"${toName}\"`,\n `ALTER TYPE ${qualifiedFrom} RENAME TO ${quoteIdentifier(toName)}`,\n ),\n ],\n postcheck: [step(`verify type \"${toName}\" exists`, enumTypeExistsCheck(schemaName, toName))],\n };\n}\n","import { escapeLiteral, quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type Op, step, targetDetails } from './shared';\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 function createIndex(\n schemaName: string,\n tableName: string,\n indexName: string,\n columns: readonly string[],\n extras?: CreateIndexExtras,\n): 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 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: [\n step(\n `ensure index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n execute: [\n step(\n `create index \"${indexName}\"`,\n `CREATE INDEX ${quoteIdentifier(indexName)} ON ${qualified}${using} (${columnList})${withClause}`,\n ),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropIndex(schemaName: string, tableName: string, indexName: string): Op {\n return {\n id: `dropIndex.${tableName}.${indexName}`,\n label: `Drop index \"${indexName}\"`,\n operationClass: 'destructive',\n target: targetDetails('index', indexName, schemaName, tableName),\n precheck: [\n step(\n `ensure index \"${indexName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NOT NULL`,\n ),\n ],\n execute: [\n step(`drop index \"${indexName}\"`, `DROP INDEX ${qualifyTableName(schemaName, indexName)}`),\n ],\n postcheck: [\n step(\n `verify index \"${indexName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, indexName)}) IS NULL`,\n ),\n ],\n };\n}\n","import { quoteIdentifier } from '../../sql-utils';\nimport { qualifyTableName, toRegclassLiteral } from '../planner-sql-checks';\nimport { type ColumnSpec, type Op, renderColumnDefinition, step, targetDetails } from './shared';\n\nexport function createTable(\n schemaName: string,\n tableName: string,\n columns: ReadonlyArray<ColumnSpec>,\n primaryKey?: { readonly columns: readonly string[] },\n): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n const columnDefs = columns.map(renderColumnDefinition);\n const constraintDefs: string[] = [];\n if (primaryKey) {\n constraintDefs.push(`PRIMARY KEY (${primaryKey.columns.map(quoteIdentifier).join(', ')})`);\n }\n const allDefs = [...columnDefs, ...constraintDefs];\n const createSql = `CREATE TABLE ${qualified} (\\n ${allDefs.join(',\\n ')}\\n)`;\n\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: [\n step(\n `ensure table \"${tableName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`,\n ),\n ],\n execute: [step(`create table \"${tableName}\"`, createSql)],\n postcheck: [\n step(\n `verify table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n };\n}\n\nexport function dropTable(schemaName: string, tableName: string): Op {\n const qualified = qualifyTableName(schemaName, tableName);\n return {\n id: `dropTable.${tableName}`,\n label: `Drop table \"${tableName}\"`,\n operationClass: 'destructive',\n target: targetDetails('table', tableName, schemaName),\n precheck: [\n step(\n `ensure table \"${tableName}\" exists`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NOT NULL`,\n ),\n ],\n execute: [step(`drop table \"${tableName}\"`, `DROP TABLE ${qualified}`)],\n postcheck: [\n step(\n `verify table \"${tableName}\" does not exist`,\n `SELECT to_regclass(${toRegclassLiteral(schemaName, tableName)}) IS NULL`,\n ),\n ],\n };\n}\n"],"mappings":";;;;AA0CA,SAAgB,KAAK,aAAqB,KAAa;CACrD,OAAO;EAAE;EAAa;EAAK;;AAG7B,SAAgB,cACd,YACA,MACA,QACA,OAC0E;CAC1E,OAAO;EACL,IAAI;EACJ,SAAS;GAAE;GAAQ;GAAY;GAAM,GAAG,UAAU,SAAS,MAAM;GAAE;EACpE;;AAGH,SAAgB,uBAAuB,QAA4B;CAOjE,OANc;EACZ,gBAAgB,OAAO,KAAK;EAC5B,OAAO;EACP,OAAO;EACP,OAAO,WAAW,KAAK;EACxB,CAAC,OAAO,QACG,CAAC,KAAK,IAAI;;;;ACvDxB,SAAgB,UAAU,YAAoB,WAAmB,QAAwB;CAQvF,MAAM,SANQ;EACZ,eAFgB,iBAAiB,YAAY,UAErB;EACxB,cAAc,gBAAgB,OAAO,KAAK,CAAC,GAAG,OAAO;EACrD,OAAO;EACP,OAAO,WAAW,KAAK;EACxB,CAAC,OAAO,QACW,CAAC,KAAK,IAAI;CAE9B,O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