@prisma-next/target-postgres 0.4.0-dev.9 → 0.5.0-dev.1
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-CojIXVf9.mjs +29 -0
- package/dist/codec-ids-CojIXVf9.mjs.map +1 -0
- package/dist/codec-ids.d.mts +28 -0
- package/dist/codec-ids.d.mts.map +1 -0
- package/dist/codec-ids.mjs +3 -0
- package/dist/codec-types.d.mts +42 -0
- package/dist/codec-types.d.mts.map +1 -0
- package/dist/codec-types.mjs +3 -0
- package/dist/codecs-BoahtY_Q.mjs +385 -0
- package/dist/codecs-BoahtY_Q.mjs.map +1 -0
- package/dist/codecs-D-F2KJqt.d.mts +299 -0
- package/dist/codecs-D-F2KJqt.d.mts.map +1 -0
- package/dist/codecs.d.mts +2 -0
- package/dist/codecs.mjs +3 -0
- package/dist/control.d.mts +1 -9
- package/dist/control.d.mts.map +1 -1
- package/dist/control.mjs +23 -5101
- package/dist/control.mjs.map +1 -1
- package/dist/data-transform-CxFRBIUp.d.mts +32 -0
- package/dist/data-transform-CxFRBIUp.d.mts.map +1 -0
- package/dist/data-transform-VfEGzXWt.mjs +39 -0
- package/dist/data-transform-VfEGzXWt.mjs.map +1 -0
- package/dist/data-transform.d.mts +2 -0
- package/dist/data-transform.mjs +3 -0
- package/dist/default-normalizer-DNOpRoOF.mjs +131 -0
- package/dist/default-normalizer-DNOpRoOF.mjs.map +1 -0
- package/dist/default-normalizer.d.mts +19 -0
- package/dist/default-normalizer.d.mts.map +1 -0
- package/dist/default-normalizer.mjs +3 -0
- package/dist/{descriptor-meta-DkvCmY98.mjs → descriptor-meta-BVoVtyp-.mjs} +1 -1
- package/dist/{descriptor-meta-DkvCmY98.mjs.map → descriptor-meta-BVoVtyp-.mjs.map} +1 -1
- package/dist/errors-AFvEPZ1R.mjs +34 -0
- package/dist/errors-AFvEPZ1R.mjs.map +1 -0
- package/dist/errors.d.mts +27 -0
- package/dist/errors.d.mts.map +1 -0
- package/dist/errors.mjs +3 -0
- package/dist/issue-planner-CFjB0_oO.mjs +879 -0
- package/dist/issue-planner-CFjB0_oO.mjs.map +1 -0
- package/dist/issue-planner.d.mts +85 -0
- package/dist/issue-planner.d.mts.map +1 -0
- package/dist/issue-planner.mjs +3 -0
- package/dist/migration.d.mts +90 -0
- package/dist/migration.d.mts.map +1 -0
- package/dist/migration.mjs +24 -0
- package/dist/migration.mjs.map +1 -0
- package/dist/native-type-normalizer-CInai_oY.mjs +38 -0
- package/dist/native-type-normalizer-CInai_oY.mjs.map +1 -0
- package/dist/native-type-normalizer.d.mts +18 -0
- package/dist/native-type-normalizer.d.mts.map +1 -0
- package/dist/native-type-normalizer.mjs +3 -0
- package/dist/op-factory-call-BKlruaiC.mjs +605 -0
- package/dist/op-factory-call-BKlruaiC.mjs.map +1 -0
- package/dist/op-factory-call-C3bWXKSP.d.mts +304 -0
- package/dist/op-factory-call-C3bWXKSP.d.mts.map +1 -0
- package/dist/op-factory-call.d.mts +3 -0
- package/dist/op-factory-call.mjs +3 -0
- package/dist/pack.d.mts +1 -1
- package/dist/pack.mjs +1 -1
- package/dist/planner-CLUvVhUN.mjs +98 -0
- package/dist/planner-CLUvVhUN.mjs.map +1 -0
- package/dist/planner-ddl-builders-Dxvw1LHw.mjs +132 -0
- package/dist/planner-ddl-builders-Dxvw1LHw.mjs.map +1 -0
- package/dist/planner-ddl-builders.d.mts +22 -0
- package/dist/planner-ddl-builders.d.mts.map +1 -0
- package/dist/planner-ddl-builders.mjs +3 -0
- package/dist/planner-identity-values-Dju-o5GF.mjs +91 -0
- package/dist/planner-identity-values-Dju-o5GF.mjs.map +1 -0
- package/dist/planner-identity-values.d.mts +20 -0
- package/dist/planner-identity-values.d.mts.map +1 -0
- package/dist/planner-identity-values.mjs +3 -0
- package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts +20 -0
- package/dist/planner-produced-postgres-migration-CRRTno6Z.d.mts.map +1 -0
- package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs +33 -0
- package/dist/planner-produced-postgres-migration-DSSPq8QS.mjs.map +1 -0
- package/dist/planner-produced-postgres-migration.d.mts +5 -0
- package/dist/planner-produced-postgres-migration.mjs +3 -0
- package/dist/planner-schema-lookup-B7lkypwn.mjs +29 -0
- package/dist/planner-schema-lookup-B7lkypwn.mjs.map +1 -0
- package/dist/planner-schema-lookup.d.mts +22 -0
- package/dist/planner-schema-lookup.d.mts.map +1 -0
- package/dist/planner-schema-lookup.mjs +3 -0
- package/dist/planner-sql-checks-7jkgm9TX.mjs +241 -0
- package/dist/planner-sql-checks-7jkgm9TX.mjs.map +1 -0
- package/dist/planner-sql-checks.d.mts +55 -0
- package/dist/planner-sql-checks.d.mts.map +1 -0
- package/dist/planner-sql-checks.mjs +3 -0
- package/dist/planner-target-details-DH-azLu-.d.mts +11 -0
- package/dist/planner-target-details-DH-azLu-.d.mts.map +1 -0
- package/dist/planner-target-details.d.mts +2 -0
- package/dist/planner-target-details.mjs +1 -0
- package/dist/planner.d.mts +68 -0
- package/dist/planner.d.mts.map +1 -0
- package/dist/planner.mjs +4 -0
- package/dist/postgres-migration-BjA3Zmts.d.mts +50 -0
- package/dist/postgres-migration-BjA3Zmts.d.mts.map +1 -0
- package/dist/postgres-migration-qtmtbONe.mjs +52 -0
- package/dist/postgres-migration-qtmtbONe.mjs.map +1 -0
- package/dist/render-ops-D6_DHdOK.mjs +8 -0
- package/dist/render-ops-D6_DHdOK.mjs.map +1 -0
- package/dist/render-ops.d.mts +11 -0
- package/dist/render-ops.d.mts.map +1 -0
- package/dist/render-ops.mjs +3 -0
- package/dist/render-typescript-1rF_SB4g.mjs +85 -0
- package/dist/render-typescript-1rF_SB4g.mjs.map +1 -0
- package/dist/render-typescript.d.mts +15 -0
- package/dist/render-typescript.d.mts.map +1 -0
- package/dist/render-typescript.mjs +3 -0
- package/dist/runtime.d.mts +15 -3
- package/dist/runtime.d.mts.map +1 -1
- package/dist/runtime.mjs +10 -1
- package/dist/runtime.mjs.map +1 -1
- package/dist/shared-Bxkt8pNO.d.mts +41 -0
- package/dist/shared-Bxkt8pNO.d.mts.map +1 -0
- package/dist/sql-utils-r-Lw535w.mjs +76 -0
- package/dist/sql-utils-r-Lw535w.mjs.map +1 -0
- package/dist/sql-utils.d.mts +59 -0
- package/dist/sql-utils.d.mts.map +1 -0
- package/dist/sql-utils.mjs +3 -0
- package/dist/statement-builders-BPnmt6wx.mjs +116 -0
- package/dist/statement-builders-BPnmt6wx.mjs.map +1 -0
- package/dist/statement-builders.d.mts +23 -0
- package/dist/statement-builders.d.mts.map +1 -0
- package/dist/statement-builders.mjs +3 -0
- package/dist/tables-BmdW_FWO.mjs +477 -0
- package/dist/tables-BmdW_FWO.mjs.map +1 -0
- package/dist/types-ClK03Ojd.d.mts +10 -0
- package/dist/types-ClK03Ojd.d.mts.map +1 -0
- package/dist/types.d.mts +2 -0
- package/dist/types.mjs +1 -0
- package/package.json +38 -19
- package/src/core/codec-ids.ts +30 -0
- package/src/core/codecs.ts +645 -0
- package/src/core/default-normalizer.ts +131 -0
- package/src/core/descriptor-meta.ts +1 -1
- package/src/core/errors.ts +33 -0
- package/src/core/json-schema-type-expression.ts +131 -0
- package/src/core/migrations/issue-planner.ts +832 -0
- package/src/core/migrations/op-factory-call.ts +858 -0
- package/src/core/migrations/operations/columns.ts +285 -0
- package/src/core/migrations/operations/constraints.ts +191 -0
- package/src/core/migrations/operations/data-transform.ts +119 -0
- package/src/core/migrations/operations/dependencies.ts +36 -0
- package/src/core/migrations/operations/enums.ts +113 -0
- package/src/core/migrations/operations/indexes.ts +61 -0
- package/src/core/migrations/operations/raw.ts +15 -0
- package/src/core/migrations/operations/shared.ts +67 -0
- package/src/core/migrations/operations/tables.ts +63 -0
- package/src/core/migrations/planner-ddl-builders.ts +1 -1
- package/src/core/migrations/planner-produced-postgres-migration.ts +67 -0
- package/src/core/migrations/planner-recipes.ts +1 -1
- package/src/core/migrations/planner-sql-checks.ts +1 -1
- package/src/core/migrations/planner-strategies.ts +592 -151
- package/src/core/migrations/planner-target-details.ts +0 -6
- package/src/core/migrations/planner.ts +65 -785
- package/src/core/migrations/postgres-migration.ts +73 -0
- package/src/core/migrations/render-ops.ts +9 -0
- package/src/core/migrations/render-typescript.ts +105 -0
- package/src/core/migrations/runner.ts +2 -4
- package/src/core/native-type-normalizer.ts +49 -0
- package/src/core/sql-utils.ts +104 -0
- package/src/exports/codec-ids.ts +1 -0
- package/src/exports/codec-types.ts +51 -0
- package/src/exports/codecs.ts +2 -0
- package/src/exports/control.ts +9 -142
- package/src/exports/data-transform.ts +1 -0
- package/src/exports/default-normalizer.ts +1 -0
- package/src/exports/errors.ts +1 -0
- package/src/exports/issue-planner.ts +1 -0
- package/src/exports/migration.ts +46 -0
- package/src/exports/native-type-normalizer.ts +1 -0
- package/src/exports/op-factory-call.ts +25 -0
- package/src/exports/planner-ddl-builders.ts +8 -0
- package/src/exports/planner-identity-values.ts +1 -0
- package/src/exports/planner-produced-postgres-migration.ts +1 -0
- package/src/exports/planner-schema-lookup.ts +6 -0
- package/src/exports/planner-sql-checks.ts +11 -0
- package/src/exports/planner-target-details.ts +1 -0
- package/src/exports/planner.ts +1 -0
- package/src/exports/render-ops.ts +1 -0
- package/src/exports/render-typescript.ts +1 -0
- package/src/exports/runtime.ts +19 -4
- package/src/exports/sql-utils.ts +7 -0
- package/src/exports/statement-builders.ts +7 -0
- package/src/exports/types.ts +1 -0
- package/dist/migration-builders.d.mts +0 -88
- package/dist/migration-builders.d.mts.map +0 -1
- package/dist/migration-builders.mjs +0 -3
- package/dist/operation-descriptors-CxymFSgK.mjs +0 -52
- package/dist/operation-descriptors-CxymFSgK.mjs.map +0 -1
- package/src/core/migrations/descriptor-planner.ts +0 -464
- package/src/core/migrations/operation-descriptors.ts +0 -166
- package/src/core/migrations/operation-resolver.ts +0 -929
- package/src/core/migrations/planner-reconciliation.ts +0 -798
- package/src/core/migrations/scaffolding.ts +0 -140
- package/src/exports/migration-builders.ts +0 -56
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-planner-CFjB0_oO.mjs","names":["notNullBackfillCallStrategy: CallMigrationStrategy","matched: SchemaIssue[]","calls: PostgresOpFactoryCall[]","typeChangeCallStrategy: CallMigrationStrategy","nullableTighteningCallStrategy: CallMigrationStrategy","columnRefs: { table: string; column: string }[]","enumChangeCallStrategy: CallMigrationStrategy","storageTypePlanCallStrategy: CallMigrationStrategy","dependencyInstallCallStrategy: CallMigrationStrategy","notNullAddColumnCallStrategy: CallMigrationStrategy","postgresPlannerStrategies: readonly CallMigrationStrategy[]","ISSUE_KIND_ORDER: Record<string, number>","columns: ColumnSpec[]","calls: PostgresOpFactoryCall[]","fkSpec: ForeignKeySpec","DEFAULT_POLICY: MigrationOperationPolicy","location: {\n table?: string;\n column?: string;\n index?: string;\n constraint?: string;\n type?: string;\n }","context: StrategyContext","recipeCalls: PostgresOpFactoryCall[]","bucketablePatternCalls: PostgresOpFactoryCall[]","defaultCalls: PostgresOpFactoryCall[]","conflicts: SqlPlannerConflict[]","gatedDefaultBucket: PostgresOpFactoryCall[]","gatedRecipeBucket: PostgresOpFactoryCall[]","gatedBucketableBucket: PostgresOpFactoryCall[]"],"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 { StorageColumn, StorageTypeInstance } 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>;\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, dependency\n * installs, temp-default backfill) and `mapIssueToCall` defaults emit\n * direct DDL instead.\n */\n\nimport type { Contract } from '@prisma-next/contract/types';\nimport type {\n CodecControlHooks,\n ComponentDatabaseDependency,\n MigrationOperationPolicy,\n SqlMigrationPlanOperation,\n} from '@prisma-next/family-sql/control';\nimport { collectInitDependencies } 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 type { SqlStorage, StorageTypeInstance } from '@prisma-next/sql-contract/types';\nimport type { SqlSchemaIR } from '@prisma-next/sql-schema-ir/types';\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>>;\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 * `enumChangeCallStrategy` (dataTransform → createEnumType →\n * dropEnumType), `notNullBackfillCallStrategy` (addColumn →\n * dataTransform → setNotNull). Defaults to `false`, which lets\n * `planIssues` hoist individual calls into their DDL 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<string, StorageTypeInstance>;\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<string, StorageTypeInstance>;\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 nativeType = toType.nativeType;\n const desiredValues = (toType.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\nexport const enumChangeCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n // The shrink/rebuild branches emit a `DataTransformCall` placeholder or a\n // destructive rebuild that should be authored explicitly. When the policy\n // excludes `'data'` (`db update` / `db init`), skip the entire strategy so\n // `storageTypePlanCallStrategy` (codec-hook driven) takes over with the\n // dev-push enum behavior.\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 !== 'enum_values_changed') continue;\n matched.push(issue);\n\n if (issue.removedValues.length > 0) {\n calls.push(\n new DataTransformCall(\n `migrate-${issue.typeName}-values`,\n `migrate-${issue.typeName}-values:check`,\n `migrate-${issue.typeName}-values:run`,\n ),\n ...enumRebuildCallRecipe(issue.typeName, ctx),\n );\n } else if (issue.addedValues.length === 0) {\n calls.push(...enumRebuildCallRecipe(issue.typeName, ctx));\n } else {\n const toType = ctx.toContract.storage.types?.[issue.typeName];\n if (toType) {\n calls.push(\n new AddEnumValuesCall(\n ctx.schemaName,\n issue.typeName,\n toType.nativeType,\n issue.addedValues,\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 recipe: true,\n };\n};\n\n// ============================================================================\n// Walk-schema strategies (absorbed from the legacy planner)\n// ============================================================================\n\n/**\n * Dispatches storage types through their codec's `planTypeOperations` hook.\n * Replaces the walk-schema `buildStorageTypeOperations` path: the hook is\n * the authoritative source for codec-driven DDL (enum create/rebuild/add-\n * value, custom type creation, etc.).\n *\n * Runs after `enumChangeCallStrategy` so the structured enum path (value\n * add, rebuild recipe) gets first pick at `enum_values_changed` issues;\n * this strategy then handles remaining `type_missing` / `enum_values_changed`\n * issues for types whose hook produced at least one op.\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 const hook = ctx.codecHooks.get(typeInstance.codecId);\n if (!hook?.planTypeOperations) continue;\n const planResult = hook.planTypeOperations({\n typeName,\n typeInstance,\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 * Dispatches component-declared database dependencies. Replaces the\n * walk-schema `buildDatabaseDependencyOperations` path. Rather than consuming\n * `dependency_missing` issues (which only carry the id), this strategy\n * re-invokes `collectInitDependencies(frameworkComponents)` at plan time so\n * the handler has access to the structured `install` ops each component\n * declared — including arbitrary SQL launders — and dedupes by dependency id\n * plus per-op id.\n */\nexport const dependencyInstallCallStrategy: CallMigrationStrategy = (issues, ctx) => {\n const installedIds = new Set(ctx.schema.dependencies.map((d) => d.id));\n const dependencies = sortDependencies(\n collectInitDependencies(ctx.frameworkComponents).filter(isPostgresPlannerDependency),\n );\n\n const calls: PostgresOpFactoryCall[] = [];\n const handledDependencyIds = new Set<string>();\n const seenOperationIds = new Set<string>();\n\n for (const dep of dependencies) {\n handledDependencyIds.add(dep.id);\n if (installedIds.has(dep.id)) continue;\n for (const installOp of dep.install) {\n if (seenOperationIds.has(installOp.id)) continue;\n seenOperationIds.add(installOp.id);\n calls.push(liftInstallOpToCall(installOp));\n }\n }\n\n // Consume ALL `dependency_missing` issues — even non-postgres ones. The\n // walk-schema predecessor silently skipped non-postgres deps; leaving those\n // issues in the stream would let `mapIssueToCall` reject them as\n // \"Unknown dependency type\".\n const remaining = issues.filter((issue) => issue.kind !== 'dependency_missing');\n\n if (calls.length === 0 && remaining.length === issues.length) {\n return { kind: 'no_match' };\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<string, StorageTypeInstance>;\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\ntype PlannerDatabaseDependency = ComponentDatabaseDependency<unknown> & {\n readonly install: readonly SqlMigrationPlanOperation<PostgresPlanTargetDetails>[];\n};\n\nfunction isPostgresPlannerDependency(\n dependency: ComponentDatabaseDependency<unknown>,\n): dependency is PlannerDatabaseDependency {\n return dependency.install.every((operation) => operation.target.id === 'postgres');\n}\n\nfunction sortDependencies(\n dependencies: ReadonlyArray<PlannerDatabaseDependency>,\n): ReadonlyArray<PlannerDatabaseDependency> {\n return [...dependencies].sort((a, b) => a.id.localeCompare(b.id));\n}\n\n/**\n * Lift a component install op into migration IR. Structured shapes — extension\n * and schema installs with predictable SQL — collapse to typed `*Call`\n * subclasses so the scaffolded migration authoring surface stays readable.\n * Everything else (arbitrary SQL) falls through to `RawSqlCall` as an escape\n * hatch.\n */\n/**\n * Component-declared install ops are wrapped as `RawSqlCall` so the\n * component's original `label`, `precheck`, `execute`, `postcheck`, and op\n * id are preserved verbatim. Structured conversion (to e.g.\n * `CreateExtensionCall`) would drop the precheck/postcheck pair and\n * change the DDL label, breaking walk-schema output parity. Classification\n * as `'dep'` happens in `classifyCall` via the underlying op's id prefix.\n */\nfunction liftInstallOpToCall(\n op: SqlMigrationPlanOperation<PostgresPlanTargetDetails>,\n): PostgresOpFactoryCall {\n return new RawSqlCall(op);\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 * (`enumChangeCallStrategy`, `notNullBackfillCallStrategy`,\n * `typeChangeCallStrategy`, `nullableTighteningCallStrategy`) consume their\n * matching issues and emit `DataTransformCall` placeholders or recipe ops.\n *\n * - When `'data'` is not allowed (`db update` / `db init`), each data-safe\n * strategy short-circuits to `no_match`, leaving the issue for the\n * downstream walk-schema strategies (`storageTypePlanCallStrategy`,\n * `dependencyInstallCallStrategy`, `notNullAddColumnCallStrategy`) or the\n * `mapIssueToCall` default to handle with direct DDL.\n *\n * Order matters: data-safe strategies must run before the walk-schema\n * strategies on overlapping issue kinds (e.g. `enum_values_changed`,\n * `missing_column` for NOT NULL) so they take priority when active.\n */\nexport const postgresPlannerStrategies: readonly CallMigrationStrategy[] = [\n enumChangeCallStrategy,\n notNullBackfillCallStrategy,\n typeChangeCallStrategy,\n nullableTighteningCallStrategy,\n storageTypePlanCallStrategy,\n dependencyInstallCallStrategy,\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 type { TargetBoundComponentDescriptor } from '@prisma-next/framework-components/components';\nimport type { SchemaIssue } from '@prisma-next/framework-components/control';\nimport type {\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 {\n AddColumnCall,\n AddForeignKeyCall,\n AddPrimaryKeyCall,\n AddUniqueCall,\n AlterColumnTypeCall,\n CreateEnumTypeCall,\n CreateExtensionCall,\n CreateIndexCall,\n CreateSchemaCall,\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 // Dependencies and types first\n dependency_missing: 1,\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>>;\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. Used by the\n * dependency-install strategy to dispatch `databaseDependencies.init` at\n * 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>>,\n): ColumnSpec {\n return {\n name,\n typeSql: buildColumnTypeSql(\n column,\n codecHooks as Map<string, CodecControlHooks>,\n storageTypes as Record<string, StorageTypeInstance>,\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 calls.push(new CreateIndexCall(schemaName, issue.table, indexName, [...index.columns]));\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<string, StorageTypeInstance>;\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 indexName = `${issue.table}_${columns.join('_')}_idx`;\n return ok([new CreateIndexCall(schemaName, issue.table, indexName, columns)]);\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.codecId.startsWith('pg/enum')) {\n const values = (typeInstance.typeParams['values'] ?? []) as readonly string[];\n return ok([new CreateEnumTypeCall(schemaName, typeInstance.nativeType, values)]);\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 case 'dependency_missing':\n if (!issue.dependencyId)\n return notOk(\n issueConflict('unsupportedOperation', 'Dependency missing issue has no dependencyId'),\n );\n if (issue.dependencyId.startsWith('ext:')) {\n return ok([new CreateExtensionCall(issue.dependencyId.slice(4))]);\n }\n if (issue.dependencyId.startsWith('schema:')) {\n return ok([new CreateSchemaCall(issue.dependencyId.slice(7))]);\n }\n return notOk(\n issueConflict('unsupportedOperation', `Unknown dependency type: ${issue.dependencyId}`),\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 // Install ops (`dependencyInstallCallStrategy`) and type ops\n // (`storageTypePlanCallStrategy`) both lift raw `SqlMigrationPlanOperation`s\n // through `RawSqlCall` to preserve the component-declared label and\n // precheck/postcheck. Classification falls back to inspecting the\n // underlying op's target details (`objectType: 'type'`) and id prefix\n // (`extension.*` / `schema.*`).\n const op = (\n call as {\n op?: {\n id?: string;\n target?: { details?: { objectType?: string } };\n };\n }\n ).op;\n const objectType = op?.target?.details?.objectType;\n if (objectType === 'type') return 'dep';\n const id = typeof op?.id === 'string' ? op.id : '';\n if (id.startsWith('extension.') || id.startsWith('schema.')) 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: {}, dependencies: [] };\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 (`enumChangeCallStrategy`, `notNullBackfillCallStrategy`,\n // etc.) emit a cohesive sequence that must stay contiguous. They are\n // inserted at a single pattern slot. Non-recipe pattern strategies\n // (`dependencyInstallCallStrategy`, `storageTypePlanCallStrategy`,\n // `notNullAddColumnCallStrategy`) produce individually classifiable calls\n // that slot into DDL buckets alongside 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;AAC3B,QAAO;EACL;EACA;EACA;EACA,GAAG,UAAU,SAAS,MAAM;EAC7B;;;;;AClBH,SAAgB,gCACd,QACA,WACA,YAIA;AACA,QAAO;EACL,IA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AE;AACzC,WAAO,KAAK,KAAK;AACjB;;AAEF,aAAU,KAAK,0BAA0B,MAAM,QAAQ,CAAC;;EAE1D,MAAMC,qBAA8C,EAAE;EACtD,MAAMC,oBAA6C,EAAE;EACrD,MAAMC,wBAAiD,EAAE;AACzD,eAAa,QAAQ,cAAc,mBAAmB,CAAC;AACvD,cAAY,QAAQ,cAAc,kBAAkB,CAAC;AACrD,yBAAuB,QAAQ,cAAc,sBAAsB,CAAC;AACpE,iBAAe;AACf,gBAAc;AACd,oBAAkB;;AAGpB,KAAI,UAAU,SAAS,EACrB,QAAO,MAAM,UAAU;CASzB,MAAM,qBAAqB,CAAC,GAAG,cAAc,GAAG,gBAAgB;CAChE,MAAM,cAAc,QAClB,mBAAmB,QAAQ,MAAM,aAAa,EAAE,KAAK,IAAI;AAe3D,QAAO,GAAG,EAAE,OAb2B;EACrC,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;EAC5B,EAEkB,CAAC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import "./shared-Bxkt8pNO.mjs";
|
|
2
|
+
import { b as PostgresOpFactoryCall } from "./op-factory-call-C3bWXKSP.mjs";
|
|
3
|
+
import { CodecControlHooks, MigrationOperationPolicy, SqlPlannerConflict } from "@prisma-next/family-sql/control";
|
|
4
|
+
import { Result } from "@prisma-next/utils/result";
|
|
5
|
+
import { Contract } from "@prisma-next/contract/types";
|
|
6
|
+
import { SqlStorage, StorageTypeInstance } from "@prisma-next/sql-contract/types";
|
|
7
|
+
import { SchemaIssue } from "@prisma-next/framework-components/control";
|
|
8
|
+
import { TargetBoundComponentDescriptor } from "@prisma-next/framework-components/components";
|
|
9
|
+
import { SqlSchemaIR } from "@prisma-next/sql-schema-ir/types";
|
|
10
|
+
|
|
11
|
+
//#region src/core/migrations/planner-strategies.d.ts
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Context passed to each migration strategy.
|
|
15
|
+
*
|
|
16
|
+
* Strategies read the source (`fromContract`), target (`toContract`), current
|
|
17
|
+
* database state (`schema`), operation policy (`policy`), and component list
|
|
18
|
+
* (`frameworkComponents`) to make planning decisions. `fromContract` is null
|
|
19
|
+
* when no prior contract is available (e.g. `db update`, where the current
|
|
20
|
+
* DB state is approximated via `schema`).
|
|
21
|
+
*/
|
|
22
|
+
interface StrategyContext {
|
|
23
|
+
readonly toContract: Contract<SqlStorage>;
|
|
24
|
+
readonly fromContract: Contract<SqlStorage> | null;
|
|
25
|
+
readonly schemaName: string;
|
|
26
|
+
readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;
|
|
27
|
+
readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;
|
|
28
|
+
readonly schema: SqlSchemaIR;
|
|
29
|
+
readonly policy: MigrationOperationPolicy;
|
|
30
|
+
readonly frameworkComponents: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
31
|
+
}
|
|
32
|
+
type CallMigrationStrategy = (issues: readonly SchemaIssue[], context: StrategyContext) => {
|
|
33
|
+
kind: 'match';
|
|
34
|
+
issues: readonly SchemaIssue[];
|
|
35
|
+
calls: readonly PostgresOpFactoryCall[];
|
|
36
|
+
/**
|
|
37
|
+
* `true` for strategies that emit cohesive sequential recipes whose
|
|
38
|
+
* calls must stay contiguous and in the returned order — e.g.
|
|
39
|
+
* `enumChangeCallStrategy` (dataTransform → createEnumType →
|
|
40
|
+
* dropEnumType), `notNullBackfillCallStrategy` (addColumn →
|
|
41
|
+
* dataTransform → setNotNull). Defaults to `false`, which lets
|
|
42
|
+
* `planIssues` hoist individual calls into their DDL sequencing bucket.
|
|
43
|
+
*/
|
|
44
|
+
recipe?: boolean;
|
|
45
|
+
} | {
|
|
46
|
+
kind: 'no_match';
|
|
47
|
+
};
|
|
48
|
+
//#endregion
|
|
49
|
+
//#region src/core/migrations/issue-planner.d.ts
|
|
50
|
+
interface IssuePlannerOptions {
|
|
51
|
+
readonly issues: readonly SchemaIssue[];
|
|
52
|
+
readonly toContract: Contract<SqlStorage>;
|
|
53
|
+
readonly fromContract: Contract<SqlStorage> | null;
|
|
54
|
+
readonly schemaName: string;
|
|
55
|
+
readonly codecHooks: ReadonlyMap<string, CodecControlHooks>;
|
|
56
|
+
readonly storageTypes: Readonly<Record<string, StorageTypeInstance>>;
|
|
57
|
+
/**
|
|
58
|
+
* Current database schema IR. Strategies read this to detect whether a
|
|
59
|
+
* structure already exists (e.g. `buildSchemaLookupMap` for shared-temp-
|
|
60
|
+
* default safety, extension dependency checks). Defaults to an empty schema
|
|
61
|
+
* when omitted so the planner can still run over "fresh DB" contract
|
|
62
|
+
* snapshots.
|
|
63
|
+
*/
|
|
64
|
+
readonly schema?: SqlSchemaIR;
|
|
65
|
+
/**
|
|
66
|
+
* Operation-class policy. `planIssues` filters calls whose `operationClass`
|
|
67
|
+
* is not in `policy.allowedOperationClasses` and surfaces them as conflicts
|
|
68
|
+
* instead of emitting disallowed DDL. Defaults to additive-only.
|
|
69
|
+
*/
|
|
70
|
+
readonly policy?: MigrationOperationPolicy;
|
|
71
|
+
/**
|
|
72
|
+
* Framework components participating in this composition. Used by the
|
|
73
|
+
* dependency-install strategy to dispatch `databaseDependencies.init` at
|
|
74
|
+
* plan time.
|
|
75
|
+
*/
|
|
76
|
+
readonly frameworkComponents?: ReadonlyArray<TargetBoundComponentDescriptor<'sql', string>>;
|
|
77
|
+
readonly strategies?: readonly CallMigrationStrategy[];
|
|
78
|
+
}
|
|
79
|
+
interface IssuePlannerValue {
|
|
80
|
+
readonly calls: readonly PostgresOpFactoryCall[];
|
|
81
|
+
}
|
|
82
|
+
declare function planIssues(options: IssuePlannerOptions): Result<IssuePlannerValue, readonly SqlPlannerConflict[]>;
|
|
83
|
+
//#endregion
|
|
84
|
+
export { planIssues };
|
|
85
|
+
//# sourceMappingURL=issue-planner.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"issue-planner.d.mts","names":[],"sources":["../src/core/migrations/planner-strategies.ts","../src/core/migrations/issue-planner.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;;;;;;;;;;ACiIA;AAC4B,UDlDX,eAAA,CCkDW;EACI,SAAA,UAAA,EDlDT,QCkDS,CDlDA,UCkDA,CAAA;EAAT,SAAA,YAAA,EDjDE,QCiDF,CDjDW,UCiDX,CAAA,GAAA,IAAA;EACW,SAAA,UAAA,EAAA,MAAA;EAAT,SAAA,UAAA,EDhDF,WCgDE,CAAA,MAAA,EDhDkB,iBCgDlB,CAAA;EAEkB,SAAA,YAAA,EDjDlB,QCiDkB,CDjDT,MCiDS,CAAA,MAAA,EDjDM,mBCiDN,CAAA,CAAA;EAApB,SAAA,MAAA,EDhDJ,WCgDI;EAC0B,SAAA,MAAA,EDhD9B,wBCgD8B;EAAf,SAAA,mBAAA,ED/CF,aC+CE,CD/CY,8BC+CZ,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;;AAQd,KDhDR,qBAAA,GCgDQ,CAAA,MAAA,EAAA,SD/CD,WC+CC,EAAA,EAAA,OAAA,ED9CT,eC8CS,EAAA,GAAA;EAMA,IAAA,EAAA,OAAA;EAM2B,MAAA,EAAA,SDtDxB,WCsDwB,EAAA;EAAd,KAAA,EAAA,SDrDX,qBCqDW,EAAA;EACA;;AAGjC;AA2iBA;;;;;EAES,MAAA,CAAA,EAAA,OAAA;;;;;;ADvnByB,UC4CjB,mBAAA,CD5CiB;EAAT,SAAA,MAAA,EAAA,SC6CG,WD7CH,EAAA;EACN,SAAA,UAAA,EC6CI,QD7CJ,CC6Ca,UD7Cb,CAAA;EACA,SAAA,YAAA,EC6CM,QD7CN,CC6Ce,UD7Cf,CAAA,GAAA,IAAA;EAC2B,SAAA,UAAA,EAAA,MAAA;EAAd,SAAA,UAAA,EC8CT,WD9CS,CAAA,MAAA,EC8CW,iBD9CX,CAAA;EAAa,SAAA,YAAA,EC+CpB,QD/CoB,CC+CX,MD/CW,CAAA,MAAA,EC+CI,mBD/CJ,CAAA,CAAA;EAOjC;;;;;;;oBCgDQ;;AAdpB;;;;EAGkC,SAAA,MAAA,CAAA,EAiBd,wBAjBc;EAAT;;;;;EAGA,SAAA,mBAAA,CAAA,EAoBQ,aApBR,CAoBsB,8BApBtB,CAAA,KAAA,EAAA,MAAA,CAAA,CAAA;EAQL,SAAA,UAAA,CAAA,EAAA,SAaa,qBAbb,EAAA;;AAY2B,UAI9B,iBAAA,CAJ8B;EAAd,SAAA,KAAA,EAAA,SAKN,qBALM,EAAA;;AACqB,iBA8iBtC,UAAA,CA9iBsC,OAAA,EA+iB3C,mBA/iB2C,CAAA,EAgjBnD,MAhjBmD,CAgjB5C,iBAhjB4C,EAAA,SAgjBhB,kBAhjBgB,EAAA,CAAA"}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { i as dataTransform, n as DataTransformOptions, t as DataTransformClosure } from "./data-transform-CxFRBIUp.mjs";
|
|
2
|
+
import { n as ForeignKeySpec, r as Op, t as ColumnSpec } from "./shared-Bxkt8pNO.mjs";
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-BjA3Zmts.mjs";
|
|
4
|
+
import { placeholder } from "@prisma-next/errors/migration";
|
|
5
|
+
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
|
6
|
+
|
|
7
|
+
//#region src/core/migrations/operations/columns.d.ts
|
|
8
|
+
declare function addColumn(schemaName: string, tableName: string, column: ColumnSpec): Op;
|
|
9
|
+
declare function dropColumn(schemaName: string, tableName: string, columnName: string): Op;
|
|
10
|
+
/**
|
|
11
|
+
* `qualifiedTargetType` is the new column type as it appears in the
|
|
12
|
+
* `ALTER COLUMN TYPE` clause (schema-qualified for user-defined types, raw
|
|
13
|
+
* native name for built-ins). `formatTypeExpected` is the unqualified
|
|
14
|
+
* `format_type` form used in the postcheck. `rawTargetTypeForLabel` is the
|
|
15
|
+
* string appearing in the human-readable label (typically `toType` when
|
|
16
|
+
* explicit, else the column's native type).
|
|
17
|
+
*/
|
|
18
|
+
declare function alterColumnType(schemaName: string, tableName: string, columnName: string, options: {
|
|
19
|
+
readonly qualifiedTargetType: string;
|
|
20
|
+
readonly formatTypeExpected: string;
|
|
21
|
+
readonly rawTargetTypeForLabel: string;
|
|
22
|
+
readonly using?: string;
|
|
23
|
+
}): Op;
|
|
24
|
+
declare function setNotNull(schemaName: string, tableName: string, columnName: string): Op;
|
|
25
|
+
declare function dropNotNull(schemaName: string, tableName: string, columnName: string): Op;
|
|
26
|
+
/**
|
|
27
|
+
* `defaultSql` is the full `DEFAULT …` clause as produced by
|
|
28
|
+
* `buildColumnDefaultSql` — e.g. `"DEFAULT 42"`,
|
|
29
|
+
* `"DEFAULT (CURRENT_TIMESTAMP)"`, or `"DEFAULT nextval('seq'::regclass)"`.
|
|
30
|
+
*
|
|
31
|
+
* `operationClass` defaults to `'additive'` (setting a default on a column
|
|
32
|
+
* that currently has none). The reconciliation planner passes `'widening'`
|
|
33
|
+
* when the column already has a different default — policy enforcement
|
|
34
|
+
* treats that as a widening change rather than an additive one.
|
|
35
|
+
*/
|
|
36
|
+
declare function setDefault(schemaName: string, tableName: string, columnName: string, defaultSql: string, operationClass?: 'additive' | 'widening'): Op;
|
|
37
|
+
declare function dropDefault(schemaName: string, tableName: string, columnName: string): Op;
|
|
38
|
+
//#endregion
|
|
39
|
+
//#region src/core/migrations/operations/constraints.d.ts
|
|
40
|
+
declare function addPrimaryKey(schemaName: string, tableName: string, constraintName: string, columns: readonly string[]): Op;
|
|
41
|
+
declare function addUnique(schemaName: string, tableName: string, constraintName: string, columns: readonly string[]): Op;
|
|
42
|
+
declare function addForeignKey(schemaName: string, tableName: string, fk: ForeignKeySpec): Op;
|
|
43
|
+
/**
|
|
44
|
+
* `kind` feeds the operation's `target.details.objectType`. Descriptor-flow
|
|
45
|
+
* does not carry kind information in its drop-constraint descriptor, so the
|
|
46
|
+
* default is `'unique'`. The reconciliation planner passes the correct kind
|
|
47
|
+
* (`'foreignKey'`, `'primaryKey'`, or `'unique'`) based on the `SchemaIssue`
|
|
48
|
+
* that produced the drop.
|
|
49
|
+
*/
|
|
50
|
+
declare function dropConstraint(schemaName: string, tableName: string, constraintName: string, kind?: 'foreignKey' | 'unique' | 'primaryKey'): Op;
|
|
51
|
+
//#endregion
|
|
52
|
+
//#region src/core/migrations/operations/dependencies.d.ts
|
|
53
|
+
declare function createExtension(extensionName: string): Op;
|
|
54
|
+
declare function createSchema(schemaName: string): Op;
|
|
55
|
+
//#endregion
|
|
56
|
+
//#region src/core/migrations/operations/enums.d.ts
|
|
57
|
+
declare function createEnumType(schemaName: string, typeName: string, values: readonly string[]): Op;
|
|
58
|
+
/**
|
|
59
|
+
* `typeName` is the contract-facing type name (used for id/label).
|
|
60
|
+
* `nativeType` is the Postgres type name to mutate (may differ for external types).
|
|
61
|
+
*/
|
|
62
|
+
declare function addEnumValues(schemaName: string, typeName: string, nativeType: string, values: readonly string[]): Op;
|
|
63
|
+
declare function dropEnumType(schemaName: string, typeName: string): Op;
|
|
64
|
+
declare function renameType(schemaName: string, fromName: string, toName: string): Op;
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/core/migrations/operations/indexes.d.ts
|
|
67
|
+
declare function createIndex(schemaName: string, tableName: string, indexName: string, columns: readonly string[]): Op;
|
|
68
|
+
declare function dropIndex(schemaName: string, tableName: string, indexName: string): Op;
|
|
69
|
+
//#endregion
|
|
70
|
+
//#region src/core/migrations/operations/raw.d.ts
|
|
71
|
+
/**
|
|
72
|
+
* Identity factory for an already-materialized `SqlMigrationPlanOperation`.
|
|
73
|
+
*
|
|
74
|
+
* The planner uses this via `liftOpToCall` to carry ops produced by SQL
|
|
75
|
+
* family methods, codec control hooks, and component database dependencies
|
|
76
|
+
* alongside migration IR without reverse-engineering them. Users writing
|
|
77
|
+
* raw migrations can pass a full op shape directly — typically built by
|
|
78
|
+
* composing SQL family helpers — to author a migration that bypasses the
|
|
79
|
+
* structured call classes.
|
|
80
|
+
*/
|
|
81
|
+
declare function rawSql(op: Op): Op;
|
|
82
|
+
//#endregion
|
|
83
|
+
//#region src/core/migrations/operations/tables.d.ts
|
|
84
|
+
declare function createTable(schemaName: string, tableName: string, columns: ReadonlyArray<ColumnSpec>, primaryKey?: {
|
|
85
|
+
readonly columns: readonly string[];
|
|
86
|
+
}): Op;
|
|
87
|
+
declare function dropTable(schemaName: string, tableName: string): Op;
|
|
88
|
+
//#endregion
|
|
89
|
+
export { type DataTransformClosure, type DataTransformOptions, PostgresMigration as Migration, MigrationCLI, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, createEnumType, createExtension, createIndex, createSchema, createTable, dataTransform, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, placeholder, rawSql, renameType, setDefault, setNotNull };
|
|
90
|
+
//# sourceMappingURL=migration.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.d.mts","names":[],"sources":["../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/raw.ts","../src/core/migrations/operations/tables.ts"],"sourcesContent":[],"mappings":";;;;;;;iBAUgB,SAAA,gDAAyD,aAAa;iBAoCtE,UAAA,6DAAuE;;;;;AApCvF;AAoCA;AAyCA;AA+CA;AAqCgB,iBApFA,eAAA,CAoF0E,UAAA,EAAA,MAAA,EAAA,SAAA,EAAA,MAAA,EAAA,UAAA,EAAA,MAAA,EAAA,OAAA,EAAA;EA2C1E,SAAA,mBAMb,EAAE,MAAA;EAiCW,SAAA,kBAAwE,EAAA,MAAE;;;IA5JvF;AC3Da,iBDgGA,UAAA,CC3Fb,UAAE,EAAA,MAAA,EAAA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+JwE,EAAA,EK/J7D,EL+J+D,CAAA,EK/J1D,EL+J0D;;;iBMvK1E,WAAA,iDAGL,cAAc;;IAEtB;iBAgCa,SAAA,yCAAkD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { _ as dropColumn, a as addEnumValues, b as setDefault, c as renameType, d as addForeignKey, f as addPrimaryKey, g as alterColumnType, h as addColumn, i as dropIndex, l as createExtension, m as dropConstraint, n as dropTable, o as createEnumType, p as addUnique, r as createIndex, s as dropEnumType, t as createTable, u as createSchema, v as dropDefault, x as setNotNull, y as dropNotNull } from "./tables-BmdW_FWO.mjs";
|
|
2
|
+
import { t as dataTransform } from "./data-transform-VfEGzXWt.mjs";
|
|
3
|
+
import { t as PostgresMigration } from "./postgres-migration-qtmtbONe.mjs";
|
|
4
|
+
import { placeholder } from "@prisma-next/errors/migration";
|
|
5
|
+
import { MigrationCLI } from "@prisma-next/cli/migration-cli";
|
|
6
|
+
|
|
7
|
+
//#region src/core/migrations/operations/raw.ts
|
|
8
|
+
/**
|
|
9
|
+
* Identity factory for an already-materialized `SqlMigrationPlanOperation`.
|
|
10
|
+
*
|
|
11
|
+
* The planner uses this via `liftOpToCall` to carry ops produced by SQL
|
|
12
|
+
* family methods, codec control hooks, and component database dependencies
|
|
13
|
+
* alongside migration IR without reverse-engineering them. Users writing
|
|
14
|
+
* raw migrations can pass a full op shape directly — typically built by
|
|
15
|
+
* composing SQL family helpers — to author a migration that bypasses the
|
|
16
|
+
* structured call classes.
|
|
17
|
+
*/
|
|
18
|
+
function rawSql(op) {
|
|
19
|
+
return op;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
//#endregion
|
|
23
|
+
export { PostgresMigration as Migration, MigrationCLI, addColumn, addEnumValues, addForeignKey, addPrimaryKey, addUnique, alterColumnType, createEnumType, createExtension, createIndex, createSchema, createTable, dataTransform, dropColumn, dropConstraint, dropDefault, dropEnumType, dropIndex, dropNotNull, dropTable, placeholder, rawSql, renameType, setDefault, setNotNull };
|
|
24
|
+
//# sourceMappingURL=migration.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migration.mjs","names":[],"sources":["../src/core/migrations/operations/raw.ts"],"sourcesContent":["import type { Op } from './shared';\n\n/**\n * Identity factory for an already-materialized `SqlMigrationPlanOperation`.\n *\n * The planner uses this via `liftOpToCall` to carry ops produced by SQL\n * family methods, codec control hooks, and component database dependencies\n * alongside migration IR without reverse-engineering them. Users writing\n * raw migrations can pass a full op shape directly — typically built by\n * composing SQL family helpers — to author a migration that bypasses the\n * structured call classes.\n */\nexport function rawSql(op: Op): Op {\n return op;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAYA,SAAgB,OAAO,IAAY;AACjC,QAAO"}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
//#region src/core/native-type-normalizer.ts
|
|
2
|
+
/**
|
|
3
|
+
* Postgres native-type normalization.
|
|
4
|
+
*
|
|
5
|
+
* Lives in `target-postgres` because both the migration planner/runner (control
|
|
6
|
+
* plane) and the introspection adapter (control plane) need to normalize raw
|
|
7
|
+
* native-type strings to the same canonical form for comparison.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Lookup map for simple prefix-based type normalization.
|
|
11
|
+
*
|
|
12
|
+
* Using a Map for O(1) lookup instead of multiple startsWith checks.
|
|
13
|
+
*/
|
|
14
|
+
const TYPE_PREFIX_MAP = new Map([
|
|
15
|
+
["varchar", "character varying"],
|
|
16
|
+
["bpchar", "character"],
|
|
17
|
+
["varbit", "bit varying"]
|
|
18
|
+
]);
|
|
19
|
+
/**
|
|
20
|
+
* Normalizes a Postgres schema native type to its canonical form for comparison.
|
|
21
|
+
*
|
|
22
|
+
* Uses a pre-computed lookup map for simple prefix replacements (O(1))
|
|
23
|
+
* and handles complex temporal type normalization separately.
|
|
24
|
+
*/
|
|
25
|
+
function normalizeSchemaNativeType(nativeType) {
|
|
26
|
+
const trimmed = nativeType.trim();
|
|
27
|
+
for (const [prefix, replacement] of TYPE_PREFIX_MAP) if (trimmed.startsWith(prefix)) return replacement + trimmed.slice(prefix.length);
|
|
28
|
+
if (trimmed.includes(" with time zone")) {
|
|
29
|
+
if (trimmed.startsWith("timestamp")) return `timestamptz${trimmed.slice(9).replace(" with time zone", "")}`;
|
|
30
|
+
if (trimmed.startsWith("time")) return `timetz${trimmed.slice(4).replace(" with time zone", "")}`;
|
|
31
|
+
}
|
|
32
|
+
if (trimmed.includes(" without time zone")) return trimmed.replace(" without time zone", "");
|
|
33
|
+
return trimmed;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
//#endregion
|
|
37
|
+
export { normalizeSchemaNativeType as t };
|
|
38
|
+
//# sourceMappingURL=native-type-normalizer-CInai_oY.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-type-normalizer-CInai_oY.mjs","names":["TYPE_PREFIX_MAP: ReadonlyMap<string, string>"],"sources":["../src/core/native-type-normalizer.ts"],"sourcesContent":["/**\n * Postgres native-type normalization.\n *\n * Lives in `target-postgres` because both the migration planner/runner (control\n * plane) and the introspection adapter (control plane) need to normalize raw\n * native-type strings to the same canonical form for comparison.\n */\n\n/**\n * Lookup map for simple prefix-based type normalization.\n *\n * Using a Map for O(1) lookup instead of multiple startsWith checks.\n */\nconst TYPE_PREFIX_MAP: ReadonlyMap<string, string> = new Map([\n ['varchar', 'character varying'],\n ['bpchar', 'character'],\n ['varbit', 'bit varying'],\n]);\n\n/**\n * Normalizes a Postgres schema native type to its canonical form for comparison.\n *\n * Uses a pre-computed lookup map for simple prefix replacements (O(1))\n * and handles complex temporal type normalization separately.\n */\nexport function normalizeSchemaNativeType(nativeType: string): string {\n const trimmed = nativeType.trim();\n\n for (const [prefix, replacement] of TYPE_PREFIX_MAP) {\n if (trimmed.startsWith(prefix)) {\n return replacement + trimmed.slice(prefix.length);\n }\n }\n\n if (trimmed.includes(' with time zone')) {\n if (trimmed.startsWith('timestamp')) {\n return `timestamptz${trimmed.slice(9).replace(' with time zone', '')}`;\n }\n if (trimmed.startsWith('time')) {\n return `timetz${trimmed.slice(4).replace(' with time zone', '')}`;\n }\n }\n\n if (trimmed.includes(' without time zone')) {\n return trimmed.replace(' without time zone', '');\n }\n\n return trimmed;\n}\n"],"mappings":";;;;;;;;;;;;;AAaA,MAAMA,kBAA+C,IAAI,IAAI;CAC3D,CAAC,WAAW,oBAAoB;CAChC,CAAC,UAAU,YAAY;CACvB,CAAC,UAAU,cAAc;CAC1B,CAAC;;;;;;;AAQF,SAAgB,0BAA0B,YAA4B;CACpE,MAAM,UAAU,WAAW,MAAM;AAEjC,MAAK,MAAM,CAAC,QAAQ,gBAAgB,gBAClC,KAAI,QAAQ,WAAW,OAAO,CAC5B,QAAO,cAAc,QAAQ,MAAM,OAAO,OAAO;AAIrD,KAAI,QAAQ,SAAS,kBAAkB,EAAE;AACvC,MAAI,QAAQ,WAAW,YAAY,CACjC,QAAO,cAAc,QAAQ,MAAM,EAAE,CAAC,QAAQ,mBAAmB,GAAG;AAEtE,MAAI,QAAQ,WAAW,OAAO,CAC5B,QAAO,SAAS,QAAQ,MAAM,EAAE,CAAC,QAAQ,mBAAmB,GAAG;;AAInE,KAAI,QAAQ,SAAS,qBAAqB,CACxC,QAAO,QAAQ,QAAQ,sBAAsB,GAAG;AAGlD,QAAO"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//#region src/core/native-type-normalizer.d.ts
|
|
2
|
+
/**
|
|
3
|
+
* Postgres native-type normalization.
|
|
4
|
+
*
|
|
5
|
+
* Lives in `target-postgres` because both the migration planner/runner (control
|
|
6
|
+
* plane) and the introspection adapter (control plane) need to normalize raw
|
|
7
|
+
* native-type strings to the same canonical form for comparison.
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Normalizes a Postgres schema native type to its canonical form for comparison.
|
|
11
|
+
*
|
|
12
|
+
* Uses a pre-computed lookup map for simple prefix replacements (O(1))
|
|
13
|
+
* and handles complex temporal type normalization separately.
|
|
14
|
+
*/
|
|
15
|
+
declare function normalizeSchemaNativeType(nativeType: string): string;
|
|
16
|
+
//#endregion
|
|
17
|
+
export { normalizeSchemaNativeType };
|
|
18
|
+
//# sourceMappingURL=native-type-normalizer.d.mts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-type-normalizer.d.mts","names":[],"sources":["../src/core/native-type-normalizer.ts"],"sourcesContent":[],"mappings":";;AAyBA;;;;;;;;;;;;iBAAgB,yBAAA"}
|