@danceroutine/tango-migrations 1.11.1 → 1.11.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/dist/Builder-y8vj7XXN.d.ts +25 -0
  2. package/dist/{CollectingBuilder--4fqDQdE.js → CollectingBuilder-BIfAKs_x.js} +6 -4
  3. package/dist/CollectingBuilder-BIfAKs_x.js.map +1 -0
  4. package/dist/CompilerFactory-Czv-zEOS.d.ts +30 -0
  5. package/dist/CompilerStrategy-DqmcqAC-.d.ts +44 -0
  6. package/dist/{CompilerStrategy-_AiXiyjS.js → CompilerStrategy-vcZKg8qf.js} +14 -10
  7. package/dist/CompilerStrategy-vcZKg8qf.js.map +1 -0
  8. package/dist/Dialect-Cp4r7UfW.d.ts +12 -0
  9. package/dist/{InternalColumnType-G9zV9StN.js → InternalColumnType-Dzs9T6a6.js} +3 -4
  10. package/dist/{InternalColumnType-G9zV9StN.js.map → InternalColumnType-Dzs9T6a6.js.map} +1 -1
  11. package/dist/{InternalOperationKind-Bt6Weuon.js → InternalOperationKind-M4a4H9OZ.js} +3 -4
  12. package/dist/{InternalOperationKind-Bt6Weuon.js.map → InternalOperationKind-M4a4H9OZ.js.map} +1 -1
  13. package/dist/{IntrospectorStrategy-BEIG5GqA.js → IntrospectorStrategy-BijuyIaN.js} +14 -9
  14. package/dist/IntrospectorStrategy-BijuyIaN.js.map +1 -0
  15. package/dist/{Migration-DYQ0hUG7.js → Migration-DxHHPyzn.js} +9 -4
  16. package/dist/Migration-DxHHPyzn.js.map +1 -0
  17. package/dist/{MigrationGenerator-B1p0jHnx.js → MigrationGenerator-BmmerPXJ.js} +24 -35
  18. package/dist/MigrationGenerator-BmmerPXJ.js.map +1 -0
  19. package/dist/MigrationOperation-qpdhPEs9.d.ts +145 -0
  20. package/dist/{MigrationRunner-DomrOZIn.js → MigrationRunner-B5AJel12.js} +52 -24
  21. package/dist/MigrationRunner-B5AJel12.js.map +1 -0
  22. package/dist/{MigrationSqlSafetyAdapter-CGRbB2k2.js → MigrationSqlSafetyAdapter-yP6fPjeC.js} +13 -9
  23. package/dist/MigrationSqlSafetyAdapter-yP6fPjeC.js.map +1 -0
  24. package/dist/PostgresIntrospector-DQDTZUW_.d.ts +77 -0
  25. package/dist/{SqliteCompilerFactory-BvdJ0kBl.js → SqliteCompilerFactory-CXlPAclY.js} +38 -40
  26. package/dist/SqliteCompilerFactory-CXlPAclY.js.map +1 -0
  27. package/dist/{SqliteIntrospector-CWwPWhmA.js → SqliteIntrospector-CfItmGgA.js} +15 -15
  28. package/dist/SqliteIntrospector-CfItmGgA.js.map +1 -0
  29. package/dist/builder/index.d.ts +4 -10
  30. package/dist/builder/index.js +3 -6
  31. package/dist/{builder-xJ-Bq2pk.js → builder-BSepa_PF.js} +24 -24
  32. package/dist/builder-BSepa_PF.js.map +1 -0
  33. package/dist/chunk-D7D4PA-g.js +13 -0
  34. package/dist/{cli-7j3R1Y1r.js → cli-e8I1-dab.js} +34 -47
  35. package/dist/cli-e8I1-dab.js.map +1 -0
  36. package/dist/cli.d.ts +1 -2
  37. package/dist/cli.js +3 -16
  38. package/dist/cli.js.map +1 -1
  39. package/dist/commands/index.d.ts +2 -4
  40. package/dist/commands/index.js +7 -16
  41. package/dist/commands/index.js.map +1 -0
  42. package/dist/compilers/index.d.ts +3 -10
  43. package/dist/compilers/index.js +3 -7
  44. package/dist/{compilers-C-GiumJB.js → compilers-BW-WALoD.js} +9 -16
  45. package/dist/{compilers-C-GiumJB.js.map → compilers-BW-WALoD.js.map} +1 -1
  46. package/dist/diff/index.d.ts +2 -5
  47. package/dist/diff/index.js +2 -7
  48. package/dist/{diff-B9MhagJF.js → diff-7Xw8k4vp.js} +14 -14
  49. package/dist/diff-7Xw8k4vp.js.map +1 -0
  50. package/dist/domain/index.d.ts +5 -7
  51. package/dist/domain/index.js +7 -3
  52. package/dist/domain/index.js.map +1 -0
  53. package/dist/generator/index.d.ts +2 -4
  54. package/dist/generator/index.js +7 -4
  55. package/dist/generator/index.js.map +1 -0
  56. package/dist/index-B8VoE0M4.d.ts +56 -0
  57. package/dist/index-CsTGwtZ0.d.ts +110 -0
  58. package/dist/index-CzdR_Ig9.d.ts +47 -0
  59. package/dist/index-CzpjLzoS.d.ts +180 -0
  60. package/dist/index-D7qe9iKG.d.ts +13 -0
  61. package/dist/index-DdCF5yCg.d.ts +38 -0
  62. package/dist/index-a1Y--85Y.d.ts +41 -0
  63. package/dist/index-ni7Db8Lv.d.ts +86 -0
  64. package/dist/index-sywIP4pt.d.ts +61 -0
  65. package/dist/index.d.ts +17 -27
  66. package/dist/index.js +19 -23
  67. package/dist/introspect/index.d.ts +3 -6
  68. package/dist/introspect/index.js +10 -4
  69. package/dist/introspect/index.js.map +1 -0
  70. package/dist/runner/index.d.ts +2 -4
  71. package/dist/runner/index.js +7 -10
  72. package/dist/runner/index.js.map +1 -0
  73. package/dist/strategies/index.d.ts +3 -5
  74. package/dist/strategies/index.js +13 -9
  75. package/dist/strategies/index.js.map +1 -0
  76. package/package.json +9 -9
  77. package/dist/CollectingBuilder--4fqDQdE.js.map +0 -1
  78. package/dist/CompilerStrategy-_AiXiyjS.js.map +0 -1
  79. package/dist/IntrospectorStrategy-BEIG5GqA.js.map +0 -1
  80. package/dist/Migration-DYQ0hUG7.js.map +0 -1
  81. package/dist/MigrationGenerator-B1p0jHnx.js.map +0 -1
  82. package/dist/MigrationRunner-DomrOZIn.js.map +0 -1
  83. package/dist/MigrationSqlSafetyAdapter-CGRbB2k2.js.map +0 -1
  84. package/dist/SqliteCompilerFactory-BvdJ0kBl.js.map +0 -1
  85. package/dist/SqliteIntrospector-CWwPWhmA.js.map +0 -1
  86. package/dist/builder/contracts/Builder.d.ts +0 -11
  87. package/dist/builder/contracts/ColumnSpec.d.ts +0 -20
  88. package/dist/builder/contracts/ColumnType.d.ts +0 -2
  89. package/dist/builder/contracts/DeleteReferentialAction.d.ts +0 -2
  90. package/dist/builder/contracts/UpdateReferentialAction.d.ts +0 -2
  91. package/dist/builder/contracts/index.d.ts +0 -8
  92. package/dist/builder/ops/OpBuilder.d.ts +0 -129
  93. package/dist/builder/ops/index.d.ts +0 -4
  94. package/dist/builder/runtime/CollectingBuilder.d.ts +0 -39
  95. package/dist/builder/runtime/index.d.ts +0 -4
  96. package/dist/builder-xJ-Bq2pk.js.map +0 -1
  97. package/dist/chunk-BkvOhyD0.js +0 -12
  98. package/dist/cli-7j3R1Y1r.js.map +0 -1
  99. package/dist/commands/cli.d.ts +0 -5
  100. package/dist/commands-Cl2MU7tq.js +0 -10
  101. package/dist/commands-Cl2MU7tq.js.map +0 -1
  102. package/dist/compilers/contracts/CompilerFactory.d.ts +0 -8
  103. package/dist/compilers/contracts/SQL.d.ts +0 -4
  104. package/dist/compilers/contracts/SQLCompiler.d.ts +0 -11
  105. package/dist/compilers/contracts/index.d.ts +0 -6
  106. package/dist/compilers/dialects/PostgresCompiler.d.ts +0 -32
  107. package/dist/compilers/dialects/SqliteCompiler.d.ts +0 -27
  108. package/dist/compilers/dialects/index.d.ts +0 -5
  109. package/dist/compilers/factories/PostgresCompilerFactory.d.ts +0 -17
  110. package/dist/compilers/factories/SqliteCompilerFactory.d.ts +0 -17
  111. package/dist/compilers/factories/index.d.ts +0 -5
  112. package/dist/diff/diffSchema.d.ts +0 -39
  113. package/dist/diff-B9MhagJF.js.map +0 -1
  114. package/dist/domain/Dialect.d.ts +0 -2
  115. package/dist/domain/Migration.d.ts +0 -29
  116. package/dist/domain/MigrationMode.d.ts +0 -2
  117. package/dist/domain/MigrationOperation.d.ts +0 -77
  118. package/dist/domain/internal/InternalColumnType.d.ts +0 -11
  119. package/dist/domain/internal/InternalDialect.d.ts +0 -5
  120. package/dist/domain/internal/InternalMigrationMode.d.ts +0 -5
  121. package/dist/domain/internal/InternalOperationKind.d.ts +0 -14
  122. package/dist/domain/internal/InternalReferentialAction.d.ts +0 -7
  123. package/dist/domain-CwR-kUNS.js +0 -10
  124. package/dist/domain-CwR-kUNS.js.map +0 -1
  125. package/dist/generator/MigrationGenerator.d.ts +0 -48
  126. package/dist/generator-DK-_f-PF.js +0 -10
  127. package/dist/generator-DK-_f-PF.js.map +0 -1
  128. package/dist/internal/MigrationSqlSafetyAdapter.d.ts +0 -24
  129. package/dist/introspect/DatabaseIntrospector.d.ts +0 -17
  130. package/dist/introspect/PostgresIntrospector.d.ts +0 -56
  131. package/dist/introspect/SqliteIntrospector.d.ts +0 -53
  132. package/dist/introspect-DD3fm15e.js +0 -13
  133. package/dist/introspect-DD3fm15e.js.map +0 -1
  134. package/dist/runner/MigrationRunner.d.ts +0 -79
  135. package/dist/runner-C97xT8_W.js +0 -10
  136. package/dist/runner-C97xT8_W.js.map +0 -1
  137. package/dist/runtime/loadModule.d.ts +0 -18
  138. package/dist/schema/buildMigrationModelMetadataProjection.d.ts +0 -3
  139. package/dist/strategies/CompilerStrategy.d.ts +0 -42
  140. package/dist/strategies/IntrospectorStrategy.d.ts +0 -34
  141. package/dist/strategies-HwUWvmLC.js +0 -16
  142. package/dist/strategies-HwUWvmLC.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli-e8I1-dab.js","names":["fsConstants"],"sources":["../src/commands/cli.ts"],"sourcesContent":["import { access, mkdir } from 'node:fs/promises';\nimport { constants as fsConstants } from 'node:fs';\nimport { dirname, resolve } from 'node:path';\nimport type { Argv } from 'yargs';\nimport { MigrationRunner } from '../runner/MigrationRunner';\nimport { MigrationGenerator } from '../generator/MigrationGenerator';\nimport { buildMigrationModelMetadataProjection, diffSchema } from '../diff/index';\nimport type { DbSchema } from '../introspect/PostgresIntrospector';\nimport type { Dialect } from '../domain/Dialect';\nimport type { ColumnType } from '../builder/contracts/ColumnType';\nimport type { DeleteReferentialAction } from '../builder/contracts/DeleteReferentialAction';\nimport type { UpdateReferentialAction } from '../builder/contracts/UpdateReferentialAction';\nimport { createDefaultIntrospectorStrategy } from '../strategies/IntrospectorStrategy';\nimport { InternalDialect } from '../domain/internal/InternalDialect';\nimport { loadConfig } from '@danceroutine/tango-config';\nimport { loadProjectModule } from '@danceroutine/tango-codegen/commands';\nimport { writeRelationRegistryArtifacts } from '@danceroutine/tango-codegen/generators';\nimport { getLogger } from '@danceroutine/tango-core';\nimport { GENERATED_RELATION_REGISTRY_DIRNAME, ModelRegistry } from '@danceroutine/tango-schema';\nimport { loadModule } from '../runtime/loadModule';\n\nconst logger = getLogger('tango.migrations');\n\ntype ConfigEnvironment = 'development' | 'test' | 'production';\n\ntype OptionalMigrationDefaults = {\n dialect?: Dialect;\n db?: string;\n dir?: string;\n autoApply?: boolean;\n};\n\ntype ModelMetadataLike = {\n table: string;\n fields: Array<{\n name: string;\n type: ColumnType;\n notNull?: boolean;\n default?: string | { now: true } | null;\n primaryKey?: boolean;\n unique?: boolean;\n references?: {\n table: string;\n column: string;\n onDelete?: DeleteReferentialAction;\n onUpdate?: UpdateReferentialAction;\n };\n }>;\n indexes?: Array<{ name: string; on: string[]; unique?: boolean }>;\n};\n\ntype CliDbClient = {\n query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{ rows: T[] }>;\n close(): Promise<void>;\n};\n\ntype LoadedModelsResult = {\n models: ModelMetadataLike[];\n registry: ModelRegistry;\n modelTypeAccessors: Record<string, string>;\n};\n\ntype ModelContainerLike = {\n metadata: ModelMetadataLike;\n};\n\nasync function importModule(modulePath: string): Promise<Record<string, unknown>> {\n return loadModule(modulePath, { projectRoot: process.cwd() });\n}\n\nasync function tryLoadMigrationDefaults(\n configPathArg: string | undefined,\n configEnvArg: ConfigEnvironment | undefined\n): Promise<OptionalMigrationDefaults> {\n const explicitConfigPath = typeof configPathArg === 'string' && configPathArg.trim().length > 0;\n const resolvedPath = resolve(process.cwd(), configPathArg?.trim() || './tango.config.ts');\n\n try {\n await access(resolvedPath, fsConstants.F_OK);\n } catch (error) {\n if (explicitConfigPath) {\n throw new Error(`Config file not found: ${resolvedPath}`, { cause: error });\n }\n return {};\n }\n\n const module = await importModule(resolvedPath);\n const fileConfig = (module.default ?? module) as { current?: ConfigEnvironment } & Record<string, unknown>;\n\n const loaded = loadConfig(() => ({\n ...fileConfig,\n ...(configEnvArg ? { current: configEnvArg } : {}),\n }));\n\n const { db, migrations } = loaded.current;\n const inferredDialect = db.adapter as Dialect;\n const inferredDb = resolveDbTarget(db);\n\n return {\n dialect: inferredDialect,\n db: inferredDb,\n dir: migrations.dir,\n autoApply: (migrations as { autoApply?: boolean }).autoApply,\n };\n}\n\nfunction resolveDbTarget(db: {\n adapter: string;\n url?: string;\n filename?: string;\n host?: string;\n port?: number;\n database?: string;\n user?: string;\n password?: string;\n}): string | undefined {\n if (db.adapter === InternalDialect.SQLITE) {\n return db.filename ?? db.url;\n }\n\n if (db.url) {\n return db.url;\n }\n\n if (!db.database) {\n return undefined;\n }\n\n const host = db.host ?? 'localhost';\n const port = db.port ?? 5432;\n const encodedUser = db.user ? encodeURIComponent(db.user) : '';\n const encodedPassword = db.password ? encodeURIComponent(db.password) : '';\n const userInfo =\n encodedUser.length > 0\n ? encodedPassword.length > 0\n ? `${encodedUser}:${encodedPassword}@`\n : `${encodedUser}@`\n : '';\n\n return `postgres://${userInfo}${host}:${String(port)}/${db.database}`;\n}\n\nasync function resolveCommandInputs(argv: {\n dialect?: string;\n dir?: string;\n db?: string;\n config?: string;\n env?: ConfigEnvironment;\n}): Promise<{ dialect: Dialect; dir: string; db?: string; autoApply: boolean }> {\n const defaults = await tryLoadMigrationDefaults(argv.config, argv.env);\n\n const resolvedDialect = (argv.dialect as Dialect | undefined) ?? defaults.dialect ?? InternalDialect.POSTGRES;\n const resolvedDir = argv.dir ?? defaults.dir ?? 'migrations';\n const resolvedDb = argv.db ?? defaults.db;\n\n return {\n dialect: resolvedDialect,\n dir: resolvedDir,\n db: resolvedDb,\n autoApply: defaults.autoApply ?? true,\n };\n}\n\nfunction isModelContainerLike(value: unknown): value is ModelContainerLike {\n return typeof value === 'object' && value !== null && 'metadata' in value;\n}\n\nfunction collectExportedModels(moduleValue: unknown): ModelMetadataLike[] {\n if (!moduleValue || typeof moduleValue !== 'object') {\n return [];\n }\n\n const models: ModelMetadataLike[] = [];\n for (const value of Object.values(moduleValue as Record<string, unknown>)) {\n if (isModelContainerLike(value)) {\n models.push(value.metadata);\n continue;\n }\n\n if (!value || typeof value !== 'object') {\n continue;\n }\n\n for (const nestedValue of Object.values(value as Record<string, unknown>)) {\n if (isModelContainerLike(nestedValue)) {\n models.push(nestedValue.metadata);\n }\n }\n }\n\n return models;\n}\n\nasync function loadModels(modelsPath: string): Promise<LoadedModelsResult> {\n const {\n loaded: mod,\n registry,\n modelTypeAccessors,\n } = await loadProjectModule(modelsPath, {\n projectRoot: process.cwd(),\n outputDir: resolve(process.cwd(), GENERATED_RELATION_REGISTRY_DIRNAME),\n });\n const moduleValue = (mod.default ?? mod) as unknown;\n\n const models = isModelContainerLike(moduleValue)\n ? [moduleValue.metadata, ...collectExportedModels(moduleValue)]\n : collectExportedModels(moduleValue);\n\n if (models.length === 0) {\n throw new Error(`No models found in '${modelsPath}'. Ensure the module exports Model() definitions.`);\n }\n\n return {\n models,\n registry,\n modelTypeAccessors,\n };\n}\n\nasync function connectAndIntrospect(dbUrl: string, dialect: string): Promise<DbSchema> {\n const dbClient = await connectDbClient(dbUrl, dialect as Dialect);\n\n try {\n const strategy = createDefaultIntrospectorStrategy();\n return await strategy.introspect(dialect as Dialect, dbClient);\n } finally {\n await dbClient.close();\n }\n}\n\nasync function connectDbClient(db: string, dialect: Dialect): Promise<CliDbClient> {\n if (dialect === InternalDialect.POSTGRES) {\n const pg = await import('pg');\n const client = new pg.default.Client({ connectionString: db });\n await client.connect();\n\n return {\n async query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{ rows: T[] }> {\n const result = await client.query(sql, params as unknown[] | undefined);\n return { rows: result.rows as T[] };\n },\n async close(): Promise<void> {\n await client.end();\n },\n };\n }\n\n if (dialect === InternalDialect.SQLITE) {\n const sqlite = await import('better-sqlite3');\n const DatabaseCtor = (sqlite.default ?? sqlite) as new (filename: string) => {\n prepare(sql: string): {\n all(...params: unknown[]): unknown[];\n run(...params: unknown[]): unknown;\n };\n close(): void;\n };\n\n const filename = normalizeSqliteFilename(db);\n await ensureSqliteParentDirectory(filename);\n const connection = new DatabaseCtor(filename);\n\n return {\n async query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{ rows: T[] }> {\n const statement = connection.prepare(sql);\n const values = [...(params ?? [])];\n const isSelectLike = /^\\s*(SELECT|PRAGMA|WITH)\\b/i.test(sql);\n if (isSelectLike) {\n return { rows: statement.all(...values) as T[] };\n }\n\n statement.run(...values);\n return { rows: [] as T[] };\n },\n async close(): Promise<void> {\n connection.close();\n },\n };\n }\n\n throw new Error(`Unsupported dialect: ${dialect}`);\n}\n\nasync function ensureSqliteParentDirectory(filename: string): Promise<void> {\n if (filename === ':memory:' || filename === 'file::memory:') {\n return;\n }\n const directory = dirname(filename);\n if (directory === '.' || directory.length === 0) {\n return;\n }\n await mkdir(directory, { recursive: true });\n}\n\nfunction normalizeSqliteFilename(db: string): string {\n if (db.startsWith('sqlite://')) {\n return db.slice('sqlite://'.length);\n }\n return db;\n}\n\n/**\n * Register Tango's migration commands on an existing yargs parser.\n */\nexport function registerMigrationsCommands(yargsBuilder: Argv): Argv {\n return yargsBuilder\n .command(\n 'migrate',\n 'Apply pending migrations to the database',\n (builder) =>\n builder\n .option('dir', {\n type: 'string',\n describe: 'Migrations directory',\n })\n .option('db', {\n type: 'string',\n describe: 'Database connection URL',\n })\n .option('dialect', {\n type: 'string',\n choices: ['postgres', 'sqlite'] as const,\n describe: 'Database dialect',\n })\n .option('config', {\n type: 'string',\n describe: 'Path to tango.config.ts (auto-loads ./tango.config.ts when present)',\n })\n .option('env', {\n type: 'string',\n choices: ['development', 'test', 'production'] as const,\n describe: 'Config environment override',\n })\n .option('to', {\n type: 'string',\n describe: 'Target migration ID (apply up to this migration)',\n }),\n async (argv) => {\n const resolved = await resolveCommandInputs({\n dialect: argv.dialect as string | undefined,\n dir: argv.dir as string | undefined,\n db: argv.db as string | undefined,\n config: argv.config as string | undefined,\n env: argv.env as ConfigEnvironment | undefined,\n });\n\n if (!resolved.autoApply) {\n logger.info('Auto-migration disabled (autoApply: false). Skipping.');\n return;\n }\n\n if (!resolved.db) {\n throw new Error('No database target provided. Pass --db or define db settings in tango.config.ts.');\n }\n\n const dbClient = await connectDbClient(resolved.db, resolved.dialect);\n\n const runner = new MigrationRunner(dbClient, resolved.dialect, resolved.dir);\n await runner.apply(argv.to);\n\n await dbClient.close();\n logger.info('Migrations applied successfully');\n }\n )\n .command(\n 'make:migrations',\n 'Generate migration file by comparing models to database',\n (builder) =>\n builder\n .option('dir', {\n type: 'string',\n describe: 'Migrations directory',\n })\n .option('name', {\n type: 'string',\n demandOption: true,\n describe: 'Migration name (e.g. \"create_users\")',\n })\n .option('models', {\n type: 'string',\n demandOption: true,\n describe: 'Path to module exporting Model definitions (e.g. \"./src/models.ts\")',\n })\n .option('db', {\n type: 'string',\n describe: 'Database connection URL for introspection (omit for initial migration)',\n })\n .option('dialect', {\n type: 'string',\n choices: ['postgres', 'sqlite'] as const,\n describe: 'Database dialect',\n })\n .option('config', {\n type: 'string',\n describe: 'Path to tango.config.ts (auto-loads ./tango.config.ts when present)',\n })\n .option('env', {\n type: 'string',\n choices: ['development', 'test', 'production'] as const,\n describe: 'Config environment override',\n }),\n async (argv) => {\n const resolved = await resolveCommandInputs({\n dialect: argv.dialect as string | undefined,\n dir: argv.dir as string | undefined,\n db: argv.db as string | undefined,\n config: argv.config as string | undefined,\n env: argv.env as ConfigEnvironment | undefined,\n });\n const loaded = await loadModels(argv.models);\n const projectedModels = buildMigrationModelMetadataProjection(loaded.registry);\n logger.info(\n `Found ${loaded.models.length} exported model(s); ${projectedModels.length} model(s) after projection: ${projectedModels.map((m) => m.table).join(', ')}`\n );\n try {\n await writeRelationRegistryArtifacts({\n registry: loaded.registry,\n modelTypeAccessors: loaded.modelTypeAccessors,\n outputDir: resolve(process.cwd(), GENERATED_RELATION_REGISTRY_DIRNAME),\n });\n } catch (error) {\n logger.warn(\n `Unable to refresh generated relation registry during make:migrations. Continuing without updated relation artifacts: ${error instanceof Error ? error.message : String(error)}`\n );\n }\n\n let dbState: DbSchema;\n if (resolved.db) {\n logger.info('Introspecting database...');\n dbState = await connectAndIntrospect(resolved.db, resolved.dialect);\n } else {\n dbState = { tables: {} };\n }\n\n const operations = diffSchema(dbState, projectedModels);\n\n if (operations.length === 0) {\n logger.info('No changes detected — models and database are in sync');\n return;\n }\n\n const generator = new MigrationGenerator();\n const filepath = await generator.generate({\n name: argv.name,\n operations,\n directory: resolved.dir,\n });\n\n logger.info(`Generated migration: ${filepath}`);\n logger.info(` ${operations.length} operation(s)`);\n }\n )\n .command(\n 'plan',\n 'Print migration SQL without applying',\n (builder) =>\n builder\n .option('dir', {\n type: 'string',\n describe: 'Migrations directory',\n })\n .option('dialect', {\n type: 'string',\n choices: ['postgres', 'sqlite'] as const,\n describe: 'Database dialect',\n })\n .option('config', {\n type: 'string',\n describe: 'Path to tango.config.ts (auto-loads ./tango.config.ts when present)',\n })\n .option('env', {\n type: 'string',\n choices: ['development', 'test', 'production'] as const,\n describe: 'Config environment override',\n }),\n async (argv) => {\n const resolved = await resolveCommandInputs({\n dialect: argv.dialect as string | undefined,\n dir: argv.dir as string | undefined,\n db: argv.db as string | undefined,\n config: argv.config as string | undefined,\n env: argv.env as ConfigEnvironment | undefined,\n });\n const runner = new MigrationRunner(\n { query: async () => ({ rows: [] }), close: async () => {} },\n resolved.dialect,\n resolved.dir\n );\n const output = await runner.plan();\n logger.info(output);\n }\n )\n .command(\n 'status',\n 'Show applied/pending status of all migrations',\n (builder) =>\n builder\n .option('dir', {\n type: 'string',\n describe: 'Migrations directory',\n })\n .option('db', {\n type: 'string',\n describe: 'Database connection URL',\n })\n .option('dialect', {\n type: 'string',\n choices: ['postgres', 'sqlite'] as const,\n describe: 'Database dialect',\n })\n .option('config', {\n type: 'string',\n describe: 'Path to tango.config.ts (auto-loads ./tango.config.ts when present)',\n })\n .option('env', {\n type: 'string',\n choices: ['development', 'test', 'production'] as const,\n describe: 'Config environment override',\n }),\n async (argv) => {\n const resolved = await resolveCommandInputs({\n dialect: argv.dialect as string | undefined,\n dir: argv.dir as string | undefined,\n db: argv.db as string | undefined,\n config: argv.config as string | undefined,\n env: argv.env as ConfigEnvironment | undefined,\n });\n if (!resolved.db) {\n throw new Error('No database target provided. Pass --db or define db settings in tango.config.ts.');\n }\n\n const dbClient = await connectDbClient(resolved.db, resolved.dialect);\n\n const runner = new MigrationRunner(dbClient, resolved.dialect, resolved.dir);\n const statuses = await runner.status();\n\n if (statuses.length === 0) {\n logger.info('No migrations found');\n } else {\n statuses.forEach((statusItem) => {\n const marker = statusItem.applied ? '[x]' : '[ ]';\n logger.info(` ${marker} ${statusItem.id}`);\n });\n }\n\n await dbClient.close();\n }\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAqBA,MAAM,SAAS,UAAU,kBAAkB;AA6C3C,eAAe,aAAa,YAAsD;CAC9E,OAAO,WAAW,YAAY,EAAE,aAAa,QAAQ,IAAI,EAAE,CAAC;AAChE;AAEA,eAAe,yBACX,eACA,cACkC;CAClC,MAAM,qBAAqB,OAAO,kBAAkB,YAAY,cAAc,KAAK,EAAE,SAAS;CAC9F,MAAM,eAAe,QAAQ,QAAQ,IAAI,GAAG,eAAe,KAAK,KAAK,mBAAmB;CAExF,IAAI;EACA,MAAM,OAAO,cAAcA,UAAY,IAAI;CAC/C,SAAS,OAAO;EACZ,IAAI,oBACA,MAAM,IAAI,MAAM,0BAA0B,gBAAgB,EAAE,OAAO,MAAM,CAAC;EAE9E,OAAO,CAAC;CACZ;CAEA,MAAM,SAAS,MAAM,aAAa,YAAY;CAC9C,MAAM,aAAc,OAAO,WAAW;CAOtC,MAAM,EAAE,IAAI,eALG,kBAAkB;EAC7B,GAAG;EACH,GAAI,eAAe,EAAE,SAAS,aAAa,IAAI,CAAC;CACpD,EAEgC,EAAE;CAIlC,OAAO;EAC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GAEa,EAAE,KAAK;EACjC,OAAO,KAAK,MAAM;CACtB,CACJ,EACC,QACG,UACA,kDACC,YACG,QACK,OAAO,OAAO;EACX,MAAM;EACN,UAAU;CACd,CAAC,EACA,OAAO,MAAM;EACV,MAAM;EACN,UAAU;CACd,CAAC,EACA,OAAO,WAAW;EACf,MAAM;EACN,SAAS,CAAC,YAAY,QAAQ;EAC9B,UAAU;CACd,CAAC,EACA,OAAO,UAAU;EACd,MAAM;EACN,UAAU;CACd,CAAC,EACA,OAAO,OAAO;EACX,MAAM;EACN,SAAS;GAAC;GAAe;GAAQ;EAAY;EAC7C,UAAU;CACd,CAAC,GACT,OAAO,SAAS;EACZ,MAAM,WAAW,MAAM,qBAAqB;GACxC,SAAS,KAAK;GACd,KAAK,KAAK;GACV,IAAI,KAAK;GACT,QAAQ,KAAK;GACb,KAAK,KAAK;EACd,CAAC;EACD,IAAI,CAAC,SAAS,IACV,MAAM,IAAI,MAAM,kFAAkF;EAGtG,MAAM,WAAW,MAAM,gBAAgB,SAAS,IAAI,SAAS,OAAO;EAGpE,MAAM,WAAW,MAAM,IADJ,gBAAgB,UAAU,SAAS,SAAS,SAAS,GAC5C,EAAE,OAAO;EAErC,IAAI,SAAS,WAAW,GACpB,OAAO,KAAK,qBAAqB;OAEjC,SAAS,SAAS,eAAe;GAC7B,MAAM,SAAS,WAAW,UAAU,QAAQ;GAC5C,OAAO,KAAK,KAAK,OAAO,GAAG,WAAW,IAAI;EAC9C,CAAC;EAGL,MAAM,SAAS,MAAM;CACzB,CACJ;AACR"}
package/dist/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { };
package/dist/cli.js CHANGED
@@ -1,26 +1,13 @@
1
1
  #!/usr/bin/env node
2
- import "./CollectingBuilder--4fqDQdE.js";
3
- import "./Migration-DYQ0hUG7.js";
4
- import "./InternalOperationKind-Bt6Weuon.js";
5
- import "./InternalColumnType-G9zV9StN.js";
6
- import "./MigrationSqlSafetyAdapter-CGRbB2k2.js";
7
- import "./SqliteCompilerFactory-BvdJ0kBl.js";
8
- import "./CompilerStrategy-_AiXiyjS.js";
9
- import "./MigrationRunner-DomrOZIn.js";
10
- import "./MigrationGenerator-B1p0jHnx.js";
11
- import "./builder-xJ-Bq2pk.js";
12
- import "./diff-B9MhagJF.js";
13
- import "./SqliteIntrospector-CWwPWhmA.js";
14
- import "./IntrospectorStrategy-BEIG5GqA.js";
15
- import { registerMigrationsCommands } from "./cli-7j3R1Y1r.js";
2
+ import { t as registerMigrationsCommands } from "./cli-e8I1-dab.js";
16
3
  import yargs from "yargs";
17
4
  import { hideBin } from "yargs/helpers";
18
-
19
5
  //#region src/cli.ts
20
6
  function runMigrationsCli() {
21
7
  registerMigrationsCommands(yargs(hideBin(process.argv))).scriptName("tango").demandCommand(1, "You must specify a command").strict().help().alias("help", "h").alias("version", "v").parse();
22
8
  }
23
9
  runMigrationsCli();
24
-
25
10
  //#endregion
11
+ export {};
12
+
26
13
  //# sourceMappingURL=cli.js.map
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { registerMigrationsCommands } from './commands/cli';\n\nfunction runMigrationsCli(): void {\n registerMigrationsCommands(yargs(hideBin(process.argv)))\n .scriptName('tango')\n .demandCommand(1, 'You must specify a command')\n .strict()\n .help()\n .alias('help', 'h')\n .alias('version', 'v')\n .parse();\n}\n\nrunMigrationsCli();\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAKA,SAAS,mBAAyB;AAC9B,4BAA2B,MAAM,QAAQ,QAAQ,KAAK,CAAC,CAAC,CACnD,WAAW,QAAQ,CACnB,cAAc,GAAG,6BAA6B,CAC9C,QAAQ,CACR,MAAM,CACN,MAAM,QAAQ,IAAI,CAClB,MAAM,WAAW,IAAI,CACrB,OAAO;AACf;AAED,kBAAkB"}
1
+ {"version":3,"file":"cli.js","names":[],"sources":["../src/cli.ts"],"sourcesContent":["#!/usr/bin/env node\nimport yargs from 'yargs';\nimport { hideBin } from 'yargs/helpers';\nimport { registerMigrationsCommands } from './commands/cli';\n\nfunction runMigrationsCli(): void {\n registerMigrationsCommands(yargs(hideBin(process.argv)))\n .scriptName('tango')\n .demandCommand(1, 'You must specify a command')\n .strict()\n .help()\n .alias('help', 'h')\n .alias('version', 'v')\n .parse();\n}\n\nrunMigrationsCli();\n"],"mappings":";;;;;AAKA,SAAS,mBAAyB;CAC9B,2BAA2B,MAAM,QAAQ,QAAQ,IAAI,CAAC,CAAC,EAClD,WAAW,OAAO,EAClB,cAAc,GAAG,4BAA4B,EAC7C,OAAO,EACP,KAAK,EACL,MAAM,QAAQ,GAAG,EACjB,MAAM,WAAW,GAAG,EACpB,MAAM;AACf;AAEA,iBAAiB"}
@@ -1,4 +1,2 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { registerMigrationsCommands } from './cli';
1
+ import { n as registerMigrationsCommands } from "../index-D7qe9iKG.js";
2
+ export { registerMigrationsCommands };
@@ -1,17 +1,8 @@
1
- import "../CollectingBuilder--4fqDQdE.js";
2
- import "../Migration-DYQ0hUG7.js";
3
- import "../InternalOperationKind-Bt6Weuon.js";
4
- import "../InternalColumnType-G9zV9StN.js";
5
- import "../MigrationSqlSafetyAdapter-CGRbB2k2.js";
6
- import "../SqliteCompilerFactory-BvdJ0kBl.js";
7
- import "../CompilerStrategy-_AiXiyjS.js";
8
- import "../MigrationRunner-DomrOZIn.js";
9
- import "../MigrationGenerator-B1p0jHnx.js";
10
- import "../builder-xJ-Bq2pk.js";
11
- import "../diff-B9MhagJF.js";
12
- import "../SqliteIntrospector-CWwPWhmA.js";
13
- import "../IntrospectorStrategy-BEIG5GqA.js";
14
- import { registerMigrationsCommands } from "../cli-7j3R1Y1r.js";
15
- import "../commands-Cl2MU7tq.js";
1
+ import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
+ import { t as registerMigrationsCommands } from "../cli-e8I1-dab.js";
3
+ //#region src/commands/index.ts
4
+ var commands_exports = /* @__PURE__ */ __exportAll({ registerMigrationsCommands: () => registerMigrationsCommands });
5
+ //#endregion
6
+ export { registerMigrationsCommands, commands_exports as t };
16
7
 
17
- export { registerMigrationsCommands };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/commands/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { registerMigrationsCommands } from './cli';\n"],"mappings":""}
@@ -1,10 +1,3 @@
1
- /**
2
- * Domain boundary barrel: exposes namespaced exports for Django-style drill-down
3
- * imports and curated flat exports for TS-native ergonomics.
4
- */
5
- export * as contracts from './contracts/index';
6
- export * as dialects from './dialects/index';
7
- export * as factories from './factories/index';
8
- export type { SQL, SQLCompiler, CompilerFactory } from './contracts/index';
9
- export { PostgresCompiler, SqliteCompiler } from './dialects/index';
10
- export * from './factories/index';
1
+ import { n as SQLCompiler, r as SQL, t as CompilerFactory } from "../CompilerFactory-Czv-zEOS.js";
2
+ import { a as index_d_exports$1, c as index_d_exports, i as PostgresCompilerFactory, n as index_d_exports$2, o as SqliteCompiler, r as SqliteCompilerFactory, s as PostgresCompiler } from "../index-CsTGwtZ0.js";
3
+ export { type CompilerFactory, PostgresCompiler, PostgresCompilerFactory, type SQL, type SQLCompiler, SqliteCompiler, SqliteCompilerFactory, index_d_exports as contracts, index_d_exports$1 as dialects, index_d_exports$2 as factories };
@@ -1,7 +1,3 @@
1
- import "../InternalOperationKind-Bt6Weuon.js";
2
- import "../InternalColumnType-G9zV9StN.js";
3
- import "../MigrationSqlSafetyAdapter-CGRbB2k2.js";
4
- import { PostgresCompiler, PostgresCompilerFactory, SqliteCompiler, SqliteCompilerFactory } from "../SqliteCompilerFactory-BvdJ0kBl.js";
5
- import { contracts_exports$1 as contracts_exports, dialects_exports, factories_exports } from "../compilers-C-GiumJB.js";
6
-
7
- export { PostgresCompiler, PostgresCompilerFactory, SqliteCompiler, SqliteCompilerFactory, contracts_exports as contracts, dialects_exports as dialects, factories_exports as factories };
1
+ import { i as PostgresCompiler, n as SqliteCompiler, r as PostgresCompilerFactory, t as SqliteCompilerFactory } from "../SqliteCompilerFactory-CXlPAclY.js";
2
+ import { i as contracts_exports, n as factories_exports, r as dialects_exports } from "../compilers-BW-WALoD.js";
3
+ export { PostgresCompiler, PostgresCompilerFactory, SqliteCompiler, SqliteCompilerFactory, contracts_exports as contracts, dialects_exports as dialects, factories_exports as factories };
@@ -1,29 +1,22 @@
1
- import { __export } from "./chunk-BkvOhyD0.js";
2
- import { PostgresCompiler, PostgresCompilerFactory, SqliteCompiler, SqliteCompilerFactory } from "./SqliteCompilerFactory-BvdJ0kBl.js";
3
-
1
+ import { t as __exportAll } from "./chunk-D7D4PA-g.js";
2
+ import { i as PostgresCompiler, n as SqliteCompiler, r as PostgresCompilerFactory, t as SqliteCompilerFactory } from "./SqliteCompilerFactory-CXlPAclY.js";
4
3
  //#region src/compilers/contracts/index.ts
5
- var contracts_exports = {};
6
-
4
+ var contracts_exports = /* @__PURE__ */ __exportAll({});
7
5
  //#endregion
8
6
  //#region src/compilers/dialects/index.ts
9
- var dialects_exports = {};
10
- __export(dialects_exports, {
7
+ var dialects_exports = /* @__PURE__ */ __exportAll({
11
8
  PostgresCompiler: () => PostgresCompiler,
12
9
  SqliteCompiler: () => SqliteCompiler
13
10
  });
14
-
15
11
  //#endregion
16
12
  //#region src/compilers/factories/index.ts
17
- var factories_exports = {};
18
- __export(factories_exports, {
13
+ var factories_exports = /* @__PURE__ */ __exportAll({
19
14
  PostgresCompilerFactory: () => PostgresCompilerFactory,
20
15
  SqliteCompilerFactory: () => SqliteCompilerFactory
21
16
  });
22
-
23
17
  //#endregion
24
18
  //#region src/compilers/index.ts
25
- var compilers_exports = {};
26
- __export(compilers_exports, {
19
+ var compilers_exports = /* @__PURE__ */ __exportAll({
27
20
  PostgresCompiler: () => PostgresCompiler,
28
21
  PostgresCompilerFactory: () => PostgresCompilerFactory,
29
22
  SqliteCompiler: () => SqliteCompiler,
@@ -32,7 +25,7 @@ __export(compilers_exports, {
32
25
  dialects: () => dialects_exports,
33
26
  factories: () => factories_exports
34
27
  });
35
-
36
28
  //#endregion
37
- export { compilers_exports, contracts_exports as contracts_exports$1, dialects_exports, factories_exports };
38
- //# sourceMappingURL=compilers-C-GiumJB.js.map
29
+ export { contracts_exports as i, factories_exports as n, dialects_exports as r, compilers_exports as t };
30
+
31
+ //# sourceMappingURL=compilers-BW-WALoD.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"compilers-C-GiumJB.js","names":[],"sources":["../src/compilers/contracts/index.ts","../src/compilers/dialects/index.ts","../src/compilers/factories/index.ts","../src/compilers/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type { SQL } from './SQL';\nexport type { SQLCompiler } from './SQLCompiler';\nexport type { CompilerFactory } from './CompilerFactory';\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { PostgresCompiler } from './PostgresCompiler';\nexport { SqliteCompiler } from './SqliteCompiler';\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { PostgresCompilerFactory } from './PostgresCompilerFactory';\nexport { SqliteCompilerFactory } from './SqliteCompilerFactory';\n","/**\n * Domain boundary barrel: exposes namespaced exports for Django-style drill-down\n * imports and curated flat exports for TS-native ergonomics.\n */\n\nexport * as contracts from './contracts/index';\nexport * as dialects from './dialects/index';\nexport * as factories from './factories/index';\n\nexport type { SQL, SQLCompiler, CompilerFactory } from './contracts/index';\nexport { PostgresCompiler, SqliteCompiler } from './dialects/index';\nexport * from './factories/index';\n"],"mappings":""}
1
+ {"version":3,"file":"compilers-BW-WALoD.js","names":[],"sources":["../src/compilers/contracts/index.ts","../src/compilers/dialects/index.ts","../src/compilers/factories/index.ts","../src/compilers/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type { SQL } from './SQL';\nexport type { SQLCompiler } from './SQLCompiler';\nexport type { CompilerFactory } from './CompilerFactory';\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { PostgresCompiler } from './PostgresCompiler';\nexport { SqliteCompiler } from './SqliteCompiler';\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { PostgresCompilerFactory } from './PostgresCompilerFactory';\nexport { SqliteCompilerFactory } from './SqliteCompilerFactory';\n","/**\n * Domain boundary barrel: exposes namespaced exports for Django-style drill-down\n * imports and curated flat exports for TS-native ergonomics.\n */\n\nexport * as contracts from './contracts/index';\nexport * as dialects from './dialects/index';\nexport * as factories from './factories/index';\n\nexport type { SQL, SQLCompiler, CompilerFactory } from './contracts/index';\nexport { PostgresCompiler, SqliteCompiler } from './dialects/index';\nexport * from './factories/index';\n"],"mappings":""}
@@ -1,5 +1,2 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { diffSchema } from './diffSchema';
5
- export { buildMigrationModelMetadataProjection } from '../schema/buildMigrationModelMetadataProjection';
1
+ import { n as buildMigrationModelMetadataProjection, r as diffSchema } from "../index-CzdR_Ig9.js";
2
+ export { buildMigrationModelMetadataProjection, diffSchema };
@@ -1,7 +1,2 @@
1
- import "../CollectingBuilder--4fqDQdE.js";
2
- import "../InternalOperationKind-Bt6Weuon.js";
3
- import "../InternalColumnType-G9zV9StN.js";
4
- import "../builder-xJ-Bq2pk.js";
5
- import { buildMigrationModelMetadataProjection, diffSchema } from "../diff-B9MhagJF.js";
6
-
7
- export { buildMigrationModelMetadataProjection, diffSchema };
1
+ import { n as buildMigrationModelMetadataProjection, r as diffSchema } from "../diff-7Xw8k4vp.js";
2
+ export { buildMigrationModelMetadataProjection, diffSchema };
@@ -1,8 +1,11 @@
1
- import { __export } from "./chunk-BkvOhyD0.js";
2
- import { OpBuilder, applyFieldType } from "./builder-xJ-Bq2pk.js";
1
+ import { t as __exportAll } from "./chunk-D7D4PA-g.js";
2
+ import { a as applyFieldType, i as OpBuilder } from "./builder-BSepa_PF.js";
3
3
  import { trustedSql } from "@danceroutine/tango-core";
4
-
5
4
  //#region src/diff/diffSchema.ts
5
+ /**
6
+ * Compare model metadata with an introspected database schema and return the
7
+ * operations needed to bring the database into alignment.
8
+ */
6
9
  function diffSchema(db, models) {
7
10
  const ops = [];
8
11
  models.forEach((model) => {
@@ -15,8 +18,8 @@ function diffSchema(db, models) {
15
18
  builder = applyFieldType(builder, field.type);
16
19
  if (field.notNull) builder = builder.notNull();
17
20
  if (field.default === null) builder = builder.default(null);
18
- else if (field.default && typeof field.default === "object" && "now" in field.default) builder = builder.defaultNow();
19
- else if (typeof field.default === "string") builder = builder.default(trustedSql(field.default));
21
+ else if (field.default && typeof field.default === "object" && "now" in field.default) builder = builder.defaultNow();
22
+ else if (typeof field.default === "string") builder = builder.default(trustedSql(field.default));
20
23
  if (field.primaryKey) builder = builder.primaryKey();
21
24
  if (field.unique) builder = builder.unique();
22
25
  if (field.references) builder = builder.references(field.references.table, field.references.column, {
@@ -44,8 +47,8 @@ else if (typeof field.default === "string") builder = builder.default(trustedSql
44
47
  builder = applyFieldType(builder, field.type);
45
48
  if (field.notNull) builder = builder.notNull();
46
49
  if (field.default === null) builder = builder.default(null);
47
- else if (field.default && typeof field.default === "object" && "now" in field.default) builder = builder.defaultNow();
48
- else if (typeof field.default === "string") builder = builder.default(trustedSql(field.default));
50
+ else if (field.default && typeof field.default === "object" && "now" in field.default) builder = builder.defaultNow();
51
+ else if (typeof field.default === "string") builder = builder.default(trustedSql(field.default));
49
52
  if (field.primaryKey) builder = builder.primaryKey();
50
53
  if (field.unique) builder = builder.unique();
51
54
  if (field.references) builder = builder.references(field.references.table, field.references.column, {
@@ -71,7 +74,6 @@ else if (typeof field.default === "string") builder = builder.default(trustedSql
71
74
  });
72
75
  return ops;
73
76
  }
74
-
75
77
  //#endregion
76
78
  //#region src/schema/buildMigrationModelMetadataProjection.ts
77
79
  function fieldToModelField(field) {
@@ -104,15 +106,13 @@ function buildMigrationModelMetadataProjection(registry) {
104
106
  }
105
107
  return projection;
106
108
  }
107
-
108
109
  //#endregion
109
110
  //#region src/diff/index.ts
110
- var diff_exports = {};
111
- __export(diff_exports, {
111
+ var diff_exports = /* @__PURE__ */ __exportAll({
112
112
  buildMigrationModelMetadataProjection: () => buildMigrationModelMetadataProjection,
113
113
  diffSchema: () => diffSchema
114
114
  });
115
-
116
115
  //#endregion
117
- export { buildMigrationModelMetadataProjection, diffSchema, diff_exports };
118
- //# sourceMappingURL=diff-B9MhagJF.js.map
116
+ export { buildMigrationModelMetadataProjection as n, diffSchema as r, diff_exports as t };
117
+
118
+ //# sourceMappingURL=diff-7Xw8k4vp.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diff-7Xw8k4vp.js","names":["op"],"sources":["../src/diff/diffSchema.ts","../src/schema/buildMigrationModelMetadataProjection.ts","../src/diff/index.ts"],"sourcesContent":["import { trustedSql } from '@danceroutine/tango-core';\nimport type { DbSchema } from '../introspect/PostgresIntrospector';\nimport type { MigrationOperation } from '../domain/MigrationOperation';\nimport type { ColumnType } from '../builder/contracts/ColumnType';\nimport type { DeleteReferentialAction } from '../builder/contracts/DeleteReferentialAction';\nimport type { UpdateReferentialAction } from '../builder/contracts/UpdateReferentialAction';\nimport { op, applyFieldType } from '../builder/index';\n\ntype ModelField = {\n name: string;\n type: ColumnType;\n notNull?: boolean;\n default?: string | { now: true } | null;\n primaryKey?: boolean;\n unique?: boolean;\n references?: {\n table: string;\n column: string;\n onDelete?: DeleteReferentialAction;\n onUpdate?: UpdateReferentialAction;\n };\n};\n\ntype ModelIndex = {\n name: string;\n on: string[];\n unique?: boolean;\n};\n\nexport type ModelMetadataLike = {\n name?: string;\n table: string;\n fields: ModelField[];\n indexes?: ModelIndex[];\n managed?: boolean;\n};\n\n/**\n * Compare model metadata with an introspected database schema and return the\n * operations needed to bring the database into alignment.\n */\nexport function diffSchema(db: DbSchema, models: ModelMetadataLike[]): MigrationOperation[] {\n const ops: MigrationOperation[] = [];\n models.forEach((model) => {\n if (model.managed === false) {\n return;\n }\n\n const dbTable = db.tables[model.table];\n\n if (!dbTable) {\n ops.push(\n op.table(model.table).create((cols) => {\n model.fields.forEach((field) => {\n cols.add(field.name, (builder) => {\n builder = applyFieldType(builder, field.type);\n\n if (field.notNull) {\n builder = builder.notNull();\n }\n\n if (field.default === null) {\n builder = builder.default(null);\n } else if (field.default && typeof field.default === 'object' && 'now' in field.default) {\n builder = builder.defaultNow();\n } else if (typeof field.default === 'string') {\n builder = builder.default(trustedSql(field.default));\n }\n\n if (field.primaryKey) {\n builder = builder.primaryKey();\n }\n\n if (field.unique) {\n builder = builder.unique();\n }\n\n if (field.references) {\n builder = builder.references(field.references.table, field.references.column, {\n onDelete: field.references.onDelete,\n onUpdate: field.references.onUpdate,\n });\n }\n\n return builder;\n });\n });\n })\n );\n\n (model.indexes ?? []).forEach((index) => {\n ops.push(\n op.index.create({\n name: index.name,\n table: model.table,\n on: index.on,\n unique: !!index.unique,\n })\n );\n });\n return;\n }\n\n const modelFieldNames = new Set(model.fields.map((field) => field.name));\n const dbFieldNames = new Set(Object.keys(dbTable.columns));\n\n model.fields.forEach((field) => {\n if (!dbFieldNames.has(field.name)) {\n ops.push(\n op.table(model.table).addColumn(field.name, (builder) => {\n builder = applyFieldType(builder, field.type);\n\n if (field.notNull) {\n builder = builder.notNull();\n }\n if (field.default === null) {\n builder = builder.default(null);\n } else if (field.default && typeof field.default === 'object' && 'now' in field.default) {\n builder = builder.defaultNow();\n } else if (typeof field.default === 'string') {\n builder = builder.default(trustedSql(field.default));\n }\n if (field.primaryKey) {\n builder = builder.primaryKey();\n }\n if (field.unique) {\n builder = builder.unique();\n }\n if (field.references) {\n builder = builder.references(field.references.table, field.references.column, {\n onDelete: field.references.onDelete,\n onUpdate: field.references.onUpdate,\n });\n }\n\n return builder;\n })\n );\n }\n });\n\n dbFieldNames.forEach((dbColumnName) => {\n if (!modelFieldNames.has(dbColumnName)) {\n ops.push(op.table(model.table).dropColumn(dbColumnName));\n }\n });\n\n const modelIndexes = new Map((model.indexes ?? []).map((index) => [index.name, index] as const));\n const dbIndexNames = new Set(Object.keys(dbTable.indexes));\n\n modelIndexes.forEach((index, indexName) => {\n if (!dbIndexNames.has(indexName)) {\n ops.push(\n op.index.create({\n name: index.name,\n table: model.table,\n on: index.on,\n unique: !!index.unique,\n })\n );\n }\n });\n\n // Index drift is intentionally conservative. Extra indexes in the live\n // database may be app-owned or dialect-managed, so migrations only add\n // missing declared indexes and avoid destructive index drops here.\n });\n\n return ops;\n}\n","import type { ModelRegistry } from '@danceroutine/tango-schema';\nimport type { Field } from '@danceroutine/tango-schema/domain';\nimport type { ColumnType } from '../builder/contracts/ColumnType';\nimport type { ModelMetadataLike } from '../diff/diffSchema';\n\nfunction fieldToModelField(field: Field): ModelMetadataLike['fields'][number] {\n return {\n name: field.name,\n type: field.type as ColumnType,\n notNull: field.notNull,\n default: field.default,\n primaryKey: field.primaryKey,\n unique: field.unique,\n references: field.references as ModelMetadataLike['fields'][number]['references'],\n };\n}\n\nexport function buildMigrationModelMetadataProjection(registry: ModelRegistry): ModelMetadataLike[] {\n registry.finalizeStorageArtifacts();\n const projection: ModelMetadataLike[] = [];\n for (const model of registry.values()) {\n const finalized = registry.getFinalizedFields(model.metadata.key);\n projection.push({\n name: model.metadata.name,\n table: model.metadata.table,\n managed: model.metadata.managed ?? true,\n fields: finalized.map(fieldToModelField),\n indexes: model.metadata.indexes?.map((index) => ({\n name: index.name,\n on: [...index.on],\n unique: index.unique,\n })),\n });\n }\n return projection;\n}\n","/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { diffSchema } from './diffSchema';\nexport { buildMigrationModelMetadataProjection } from '../schema/buildMigrationModelMetadataProjection';\n"],"mappings":";;;;;;;;AAyCA,SAAgB,WAAW,IAAc,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CAAC;CAED,OAAO;AACX;;;ACpKA,SAAS,kBAAkB,OAAmD;CAC1E,OAAO;EACH,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,QAAQ,MAAM;EACd,YAAY,MAAM;CACtB;AACJ;AAEA,SAAgB,sCAAsC,UAA8C;CAChG,SAAS,yBAAyB;CAClC,MAAM,aAAkC,CAAC;CACzC,KAAK,MAAM,SAAS,SAAS,OAAO,GAAG;EACnC,MAAM,YAAY,SAAS,mBAAmB,MAAM,SAAS,GAAG;EAChE,WAAW,KAAK;GACZ,MAAM,MAAM,SAAS;GACrB,OAAO,MAAM,SAAS;GACtB,SAAS,MAAM,SAAS,WAAW;GACnC,QAAQ,UAAU,IAAI,iBAAiB;GACvC,SAAS,MAAM,SAAS,SAAS,KAAK,WAAW;IAC7C,MAAM,MAAM;IACZ,IAAI,CAAC,GAAG,MAAM,EAAE;IAChB,QAAQ,MAAM;GAClB,EAAE;EACN,CAAC;CACL;CACA,OAAO;AACX"}
@@ -1,7 +1,5 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export type { Dialect } from './Dialect';
5
- export { Migration } from './Migration';
6
- export type { MigrationMode } from './MigrationMode';
7
- export type { MigrationOperation } from './MigrationOperation';
1
+ import { n as MigrationMode } from "../Builder-y8vj7XXN.js";
2
+ import { d as MigrationOperation } from "../MigrationOperation-qpdhPEs9.js";
3
+ import { t as Dialect } from "../Dialect-Cp4r7UfW.js";
4
+ import { n as Migration } from "../index-DdCF5yCg.js";
5
+ export { type Dialect, Migration, type MigrationMode, type MigrationOperation };
@@ -1,4 +1,8 @@
1
- import { Migration } from "../Migration-DYQ0hUG7.js";
2
- import "../domain-CwR-kUNS.js";
1
+ import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
+ import { t as Migration } from "../Migration-DxHHPyzn.js";
3
+ //#region src/domain/index.ts
4
+ var domain_exports = /* @__PURE__ */ __exportAll({ Migration: () => Migration });
5
+ //#endregion
6
+ export { Migration, domain_exports as t };
3
7
 
4
- export { Migration };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/domain/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type { Dialect } from './Dialect';\nexport { Migration } from './Migration';\nexport type { MigrationMode } from './MigrationMode';\nexport type { MigrationOperation } from './MigrationOperation';\n"],"mappings":""}
@@ -1,4 +1,2 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { MigrationGenerator, type GenerateMigrationOptions } from './MigrationGenerator';
1
+ import { n as GenerateMigrationOptions, r as MigrationGenerator } from "../index-B8VoE0M4.js";
2
+ export { type GenerateMigrationOptions, MigrationGenerator };
@@ -1,5 +1,8 @@
1
- import "../InternalOperationKind-Bt6Weuon.js";
2
- import { MigrationGenerator } from "../MigrationGenerator-B1p0jHnx.js";
3
- import "../generator-DK-_f-PF.js";
1
+ import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
+ import { t as MigrationGenerator } from "../MigrationGenerator-BmmerPXJ.js";
3
+ //#region src/generator/index.ts
4
+ var generator_exports = /* @__PURE__ */ __exportAll({ MigrationGenerator: () => MigrationGenerator });
5
+ //#endregion
6
+ export { MigrationGenerator, generator_exports as t };
4
7
 
5
- export { MigrationGenerator };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/generator/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { MigrationGenerator, type GenerateMigrationOptions } from './MigrationGenerator';\n"],"mappings":""}
@@ -0,0 +1,56 @@
1
+ import { d as MigrationOperation } from "./MigrationOperation-qpdhPEs9.js";
2
+
3
+ //#region src/generator/MigrationGenerator.d.ts
4
+ /**
5
+ * Input contract for generating a migration source file.
6
+ */
7
+ interface GenerateMigrationOptions {
8
+ /** Human-readable suffix used in file name/id generation. */
9
+ name: string;
10
+ /** Ordered migration operations to render. */
11
+ operations: MigrationOperation[];
12
+ /** Output directory for generated migration files. */
13
+ directory: string;
14
+ }
15
+ /**
16
+ * Source generator for class-based migration files.
17
+ */
18
+ declare class MigrationGenerator {
19
+ static readonly BRAND: "tango.migrations.generator";
20
+ readonly __tangoBrand: typeof MigrationGenerator.BRAND;
21
+ /**
22
+ * Narrow an unknown value to `MigrationGenerator`.
23
+ */
24
+ static isMigrationGenerator(value: unknown): value is MigrationGenerator;
25
+ /**
26
+ * Generate a migration file and write it to disk.
27
+ * Returns the file path of the created migration.
28
+ */
29
+ generate(options: GenerateMigrationOptions): Promise<string>;
30
+ /**
31
+ * Render migration operations to a TypeScript source string without writing to disk.
32
+ */
33
+ render(id: string, operations: MigrationOperation[]): string;
34
+ private renderClassName;
35
+ private renderOperation;
36
+ private renderReverseOperation;
37
+ private renderTableCreate;
38
+ private renderTableDrop;
39
+ private renderColumnAdd;
40
+ private renderColumnDrop;
41
+ private renderColumnAlter;
42
+ private renderColumnRename;
43
+ private renderIndexCreate;
44
+ private renderIndexDrop;
45
+ private renderForeignKeyCreate;
46
+ private renderForeignKeyDrop;
47
+ private renderColumnChain;
48
+ private timestamp;
49
+ private isNowDefault;
50
+ }
51
+ declare namespace index_d_exports {
52
+ export { GenerateMigrationOptions, MigrationGenerator };
53
+ }
54
+ //#endregion
55
+ export { GenerateMigrationOptions as n, MigrationGenerator as r, index_d_exports as t };
56
+ //# sourceMappingURL=index-B8VoE0M4.d.ts.map
@@ -0,0 +1,110 @@
1
+ import { d as MigrationOperation } from "./MigrationOperation-qpdhPEs9.js";
2
+ import { n as SQLCompiler, r as SQL, t as CompilerFactory } from "./CompilerFactory-Czv-zEOS.js";
3
+
4
+ //#region src/compilers/contracts/index.d.ts
5
+ declare namespace index_d_exports$3 {
6
+ export { CompilerFactory, SQL, SQLCompiler };
7
+ }
8
+ //#endregion
9
+ //#region src/compilers/dialects/PostgresCompiler.d.ts
10
+ /**
11
+ * PostgreSQL SQL compiler for migration operations.
12
+ */
13
+ declare class PostgresCompiler implements SQLCompiler {
14
+ static readonly BRAND: "tango.migrations.postgres_compiler";
15
+ readonly __tangoBrand: typeof PostgresCompiler.BRAND;
16
+ private readonly sqlSafety;
17
+ /**
18
+ * Narrow an unknown value to the PostgreSQL migration compiler implementation.
19
+ */
20
+ static isPostgresCompiler(value: unknown): value is PostgresCompiler;
21
+ /**
22
+ * Rewrite migration operations into PostgreSQL's preferred execution
23
+ * order, including separating inline foreign keys from table creation.
24
+ */
25
+ prepareOperations(operations: MigrationOperation[]): MigrationOperation[];
26
+ /**
27
+ * Compile a migration operation into one or more PostgreSQL statements.
28
+ */
29
+ compile(op: MigrationOperation): SQL[];
30
+ /**
31
+ * Compile a DEFAULT value change into ALTER TABLE statements.
32
+ * Extracted to flatten the nested conditional logic.
33
+ */
34
+ private compileDefaultChange;
35
+ private stripTableCreateForeignKeys;
36
+ private colDDL;
37
+ private typeToSQL;
38
+ }
39
+ //#endregion
40
+ //#region src/compilers/dialects/SqliteCompiler.d.ts
41
+ /**
42
+ * SQLite SQL compiler for migration operations.
43
+ */
44
+ declare class SqliteCompiler implements SQLCompiler {
45
+ static readonly BRAND: "tango.migrations.sqlite_compiler";
46
+ readonly __tangoBrand: typeof SqliteCompiler.BRAND;
47
+ private readonly sqlSafety;
48
+ /**
49
+ * Narrow an unknown value to the SQLite migration compiler implementation.
50
+ */
51
+ static isSqliteCompiler(value: unknown): value is SqliteCompiler;
52
+ /**
53
+ * Rewrite migration operations into SQLite's safe execution order,
54
+ * including topological table creation and unique-column add expansion.
55
+ */
56
+ prepareOperations(operations: MigrationOperation[]): MigrationOperation[];
57
+ /**
58
+ * Compile a migration operation into one or more SQLite statements.
59
+ */
60
+ compile(op: MigrationOperation): SQL[];
61
+ private colDDL;
62
+ private prepareColumnAdd;
63
+ private topologicalSortTableCreatesWithReferences;
64
+ }
65
+ declare namespace index_d_exports$2 {
66
+ export { PostgresCompiler, SqliteCompiler };
67
+ }
68
+ //#endregion
69
+ //#region src/compilers/factories/PostgresCompilerFactory.d.ts
70
+ /**
71
+ * Factory for PostgreSQL migration compilers.
72
+ */
73
+ declare class PostgresCompilerFactory implements CompilerFactory {
74
+ static readonly BRAND: "tango.migrations.postgres_compiler_factory";
75
+ readonly __tangoBrand: typeof PostgresCompilerFactory.BRAND;
76
+ /**
77
+ * Narrow an unknown value to the factory that provisions PostgreSQL compilers.
78
+ */
79
+ static isPostgresCompilerFactory(value: unknown): value is PostgresCompilerFactory;
80
+ /**
81
+ * Create a PostgreSQL SQL compiler instance.
82
+ */
83
+ create(): SQLCompiler;
84
+ }
85
+ //#endregion
86
+ //#region src/compilers/factories/SqliteCompilerFactory.d.ts
87
+ /**
88
+ * Factory for SQLite migration compilers.
89
+ */
90
+ declare class SqliteCompilerFactory implements CompilerFactory {
91
+ static readonly BRAND: "tango.migrations.sqlite_compiler_factory";
92
+ readonly __tangoBrand: typeof SqliteCompilerFactory.BRAND;
93
+ /**
94
+ * Narrow an unknown value to the factory that provisions SQLite compilers.
95
+ */
96
+ static isSqliteCompilerFactory(value: unknown): value is SqliteCompilerFactory;
97
+ /**
98
+ * Create a SQLite SQL compiler instance.
99
+ */
100
+ create(): SQLCompiler;
101
+ }
102
+ declare namespace index_d_exports$1 {
103
+ export { PostgresCompilerFactory, SqliteCompilerFactory };
104
+ }
105
+ declare namespace index_d_exports {
106
+ export { CompilerFactory, PostgresCompiler, PostgresCompilerFactory, SQL, SQLCompiler, SqliteCompiler, SqliteCompilerFactory, index_d_exports$3 as contracts, index_d_exports$2 as dialects, index_d_exports$1 as factories };
107
+ }
108
+ //#endregion
109
+ export { index_d_exports$2 as a, index_d_exports$3 as c, PostgresCompilerFactory as i, index_d_exports$1 as n, SqliteCompiler as o, SqliteCompilerFactory as r, PostgresCompiler as s, index_d_exports as t };
110
+ //# sourceMappingURL=index-CsTGwtZ0.d.ts.map
@@ -0,0 +1,47 @@
1
+ import { _ as ColumnType, d as MigrationOperation, g as DeleteReferentialAction, h as UpdateReferentialAction } from "./MigrationOperation-qpdhPEs9.js";
2
+ import { i as DbSchema } from "./PostgresIntrospector-DQDTZUW_.js";
3
+ import { ModelRegistry } from "@danceroutine/tango-schema";
4
+
5
+ //#region src/diff/diffSchema.d.ts
6
+ type ModelField = {
7
+ name: string;
8
+ type: ColumnType;
9
+ notNull?: boolean;
10
+ default?: string | {
11
+ now: true;
12
+ } | null;
13
+ primaryKey?: boolean;
14
+ unique?: boolean;
15
+ references?: {
16
+ table: string;
17
+ column: string;
18
+ onDelete?: DeleteReferentialAction;
19
+ onUpdate?: UpdateReferentialAction;
20
+ };
21
+ };
22
+ type ModelIndex = {
23
+ name: string;
24
+ on: string[];
25
+ unique?: boolean;
26
+ };
27
+ type ModelMetadataLike = {
28
+ name?: string;
29
+ table: string;
30
+ fields: ModelField[];
31
+ indexes?: ModelIndex[];
32
+ managed?: boolean;
33
+ };
34
+ /**
35
+ * Compare model metadata with an introspected database schema and return the
36
+ * operations needed to bring the database into alignment.
37
+ */
38
+ declare function diffSchema(db: DbSchema, models: ModelMetadataLike[]): MigrationOperation[];
39
+ //#endregion
40
+ //#region src/schema/buildMigrationModelMetadataProjection.d.ts
41
+ declare function buildMigrationModelMetadataProjection(registry: ModelRegistry): ModelMetadataLike[];
42
+ declare namespace index_d_exports {
43
+ export { buildMigrationModelMetadataProjection, diffSchema };
44
+ }
45
+ //#endregion
46
+ export { buildMigrationModelMetadataProjection as n, diffSchema as r, index_d_exports as t };
47
+ //# sourceMappingURL=index-CzdR_Ig9.d.ts.map