@danceroutine/tango-migrations 1.11.0 → 1.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"cli-7j3R1Y1r.js","names":["modulePath: string","configPathArg: string | undefined","configEnvArg: ConfigEnvironment | undefined","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}","argv: {\n dialect?: string;\n dir?: string;\n db?: string;\n config?: string;\n env?: ConfigEnvironment;\n}","value: unknown","moduleValue: unknown","models: ModelMetadataLike[]","modelsPath: string","dbUrl: string","dialect: string","db: string","dialect: Dialect","sql: string","params?: readonly unknown[]","filename: string","yargsBuilder: Argv","dbState: DbSchema"],"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,mBAAmB;AA6C5C,eAAe,aAAaA,YAAsD;AAC9E,QAAO,WAAW,YAAY,EAAE,aAAa,QAAQ,KAAK,CAAE,EAAC;AAChE;AAED,eAAe,yBACXC,eACAC,cACkC;CAClC,MAAM,4BAA4B,kBAAkB,YAAY,cAAc,MAAM,CAAC,SAAS;CAC9F,MAAM,eAAe,QAAQ,QAAQ,KAAK,EAAE,eAAe,MAAM,IAAI,oBAAoB;AAEzF,KAAI;AACA,QAAM,OAAO,cAAc,YAAY,KAAK;CAC/C,S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SAAS,SAAS,SAAS;EACxE,MAAM,WAAW,MAAM,OAAO,QAAQ;AAEtC,MAAI,SAAS,WAAW,EACpB,QAAO,KAAK,sBAAsB;IAElC,UAAS,QAAQ,CAAC,eAAe;GAC7B,MAAM,SAAS,WAAW,UAAU,QAAQ;AAC5C,UAAO,MAAM,IAAI,OAAO,GAAG,WAAW,GAAG,EAAE;EAC9C,EAAC;AAGN,QAAM,SAAS,OAAO;CACzB,EACJ;AACR"}
@@ -1,5 +0,0 @@
1
- import type { Argv } from 'yargs';
2
- /**
3
- * Register Tango's migration commands on an existing yargs parser.
4
- */
5
- export declare function registerMigrationsCommands(yargsBuilder: Argv): Argv;
@@ -1,10 +0,0 @@
1
- import { __export } from "./chunk-BkvOhyD0.js";
2
- import { registerMigrationsCommands } from "./cli-7j3R1Y1r.js";
3
-
4
- //#region src/commands/index.ts
5
- var commands_exports = {};
6
- __export(commands_exports, { registerMigrationsCommands: () => registerMigrationsCommands });
7
-
8
- //#endregion
9
- export { commands_exports };
10
- //# sourceMappingURL=commands-Cl2MU7tq.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"commands-Cl2MU7tq.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,8 +0,0 @@
1
- import type { SQLCompiler } from './SQLCompiler';
2
- /**
3
- * Factory contract for SQL compiler instances.
4
- */
5
- export interface CompilerFactory {
6
- /** Create a compiler instance. */
7
- create(): SQLCompiler;
8
- }
@@ -1,4 +0,0 @@
1
- export type SQL = {
2
- sql: string;
3
- params: readonly unknown[];
4
- };
@@ -1,11 +0,0 @@
1
- import type { MigrationOperation } from '../../domain/MigrationOperation';
2
- import type { SQL } from './SQL';
3
- /**
4
- * Contract for dialect-specific migration SQL compilers.
5
- */
6
- export interface SQLCompiler {
7
- /** Prepare operations into the dialect-specific execution order. */
8
- prepareOperations?(operations: MigrationOperation[]): MigrationOperation[];
9
- /** Compile an operation into SQL statements. */
10
- compile(operation: MigrationOperation): SQL[];
11
- }
@@ -1,6 +0,0 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export type { SQL } from './SQL';
5
- export type { SQLCompiler } from './SQLCompiler';
6
- export type { CompilerFactory } from './CompilerFactory';
@@ -1,32 +0,0 @@
1
- import type { MigrationOperation } from '../../domain/MigrationOperation';
2
- import type { SQL } from '../contracts/SQL';
3
- import type { SQLCompiler } from '../contracts/SQLCompiler';
4
- /**
5
- * PostgreSQL SQL compiler for migration operations.
6
- */
7
- export declare class PostgresCompiler implements SQLCompiler {
8
- static readonly BRAND: "tango.migrations.postgres_compiler";
9
- readonly __tangoBrand: typeof PostgresCompiler.BRAND;
10
- private readonly sqlSafety;
11
- /**
12
- * Narrow an unknown value to the PostgreSQL migration compiler implementation.
13
- */
14
- static isPostgresCompiler(value: unknown): value is PostgresCompiler;
15
- /**
16
- * Rewrite migration operations into PostgreSQL's preferred execution
17
- * order, including separating inline foreign keys from table creation.
18
- */
19
- prepareOperations(operations: MigrationOperation[]): MigrationOperation[];
20
- /**
21
- * Compile a migration operation into one or more PostgreSQL statements.
22
- */
23
- compile(op: MigrationOperation): SQL[];
24
- /**
25
- * Compile a DEFAULT value change into ALTER TABLE statements.
26
- * Extracted to flatten the nested conditional logic.
27
- */
28
- private compileDefaultChange;
29
- private stripTableCreateForeignKeys;
30
- private colDDL;
31
- private typeToSQL;
32
- }
@@ -1,27 +0,0 @@
1
- import type { MigrationOperation } from '../../domain/MigrationOperation';
2
- import type { SQL } from '../contracts/SQL';
3
- import type { SQLCompiler } from '../contracts/SQLCompiler';
4
- /**
5
- * SQLite SQL compiler for migration operations.
6
- */
7
- export declare class SqliteCompiler implements SQLCompiler {
8
- static readonly BRAND: "tango.migrations.sqlite_compiler";
9
- readonly __tangoBrand: typeof SqliteCompiler.BRAND;
10
- private readonly sqlSafety;
11
- /**
12
- * Narrow an unknown value to the SQLite migration compiler implementation.
13
- */
14
- static isSqliteCompiler(value: unknown): value is SqliteCompiler;
15
- /**
16
- * Rewrite migration operations into SQLite's safe execution order,
17
- * including topological table creation and unique-column add expansion.
18
- */
19
- prepareOperations(operations: MigrationOperation[]): MigrationOperation[];
20
- /**
21
- * Compile a migration operation into one or more SQLite statements.
22
- */
23
- compile(op: MigrationOperation): SQL[];
24
- private colDDL;
25
- private prepareColumnAdd;
26
- private topologicalSortTableCreatesWithReferences;
27
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { PostgresCompiler } from './PostgresCompiler';
5
- export { SqliteCompiler } from './SqliteCompiler';
@@ -1,17 +0,0 @@
1
- import type { CompilerFactory } from '../contracts/CompilerFactory';
2
- import type { SQLCompiler } from '../contracts/SQLCompiler';
3
- /**
4
- * Factory for PostgreSQL migration compilers.
5
- */
6
- export declare class PostgresCompilerFactory implements CompilerFactory {
7
- static readonly BRAND: "tango.migrations.postgres_compiler_factory";
8
- readonly __tangoBrand: typeof PostgresCompilerFactory.BRAND;
9
- /**
10
- * Narrow an unknown value to the factory that provisions PostgreSQL compilers.
11
- */
12
- static isPostgresCompilerFactory(value: unknown): value is PostgresCompilerFactory;
13
- /**
14
- * Create a PostgreSQL SQL compiler instance.
15
- */
16
- create(): SQLCompiler;
17
- }
@@ -1,17 +0,0 @@
1
- import type { CompilerFactory } from '../contracts/CompilerFactory';
2
- import type { SQLCompiler } from '../contracts/SQLCompiler';
3
- /**
4
- * Factory for SQLite migration compilers.
5
- */
6
- export declare class SqliteCompilerFactory implements CompilerFactory {
7
- static readonly BRAND: "tango.migrations.sqlite_compiler_factory";
8
- readonly __tangoBrand: typeof SqliteCompilerFactory.BRAND;
9
- /**
10
- * Narrow an unknown value to the factory that provisions SQLite compilers.
11
- */
12
- static isSqliteCompilerFactory(value: unknown): value is SqliteCompilerFactory;
13
- /**
14
- * Create a SQLite SQL compiler instance.
15
- */
16
- create(): SQLCompiler;
17
- }
@@ -1,5 +0,0 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { PostgresCompilerFactory } from './PostgresCompilerFactory';
5
- export { SqliteCompilerFactory } from './SqliteCompilerFactory';
@@ -1,39 +0,0 @@
1
- import type { DbSchema } from '../introspect/PostgresIntrospector';
2
- import type { MigrationOperation } from '../domain/MigrationOperation';
3
- import type { ColumnType } from '../builder/contracts/ColumnType';
4
- import type { DeleteReferentialAction } from '../builder/contracts/DeleteReferentialAction';
5
- import type { UpdateReferentialAction } from '../builder/contracts/UpdateReferentialAction';
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
- export 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
- export declare function diffSchema(db: DbSchema, models: ModelMetadataLike[]): MigrationOperation[];
39
- export {};
@@ -1 +0,0 @@
1
- {"version":3,"file":"diff-B9MhagJF.js","names":["db: DbSchema","models: ModelMetadataLike[]","ops: MigrationOperation[]","field: Field","registry: ModelRegistry","projection: ModelMetadataLike[]"],"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":";;;;;AAyCO,SAAS,WAAWA,IAAcC,QAAmD;CACxF,MAAMC,MAA4B,CAAE;AACpC,QAAO,QAAQ,CAAC,UAAU;AACtB,MAAI,MAAM,YAAY,MAClB;EAGJ,MAAM,UAAU,GAAG,OAAO,MAAM;AAEhC,OAAK,SAAS;AACV,OAAI,KACA,UAAG,MAAM,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS;AACnC,UAAM,OAAO,QAAQ,CAAC,UAAU;AAC5B,UAAK,IAAI,MAAM,MAAM,CAAC,YAAY;AAC9B,gBAAU,eAAe,SAAS,MAAM,KAAK;AAE7C,UAAI,MAAM,QACN,WAAU,QAAQ,SAAS;AAG/B,UAAI,MAAM,YAAY,KAClB,WAAU,QAAQ,QAAQ,KAAK;SACxB,MAAM,kBAAkB,MAAM,YAAY,YAAY,SAAS,MAAM,QAC5E,WAAU,QAAQ,YAAY;gBAChB,MAAM,YAAY,SAChC,WAAU,QAAQ,QAAQ,WAAW,MAAM,QAAQ,CAAC;AAGxD,UAAI,MAAM,WACN,WAAU,QAAQ,YAAY;AAGlC,UAAI,MAAM,OACN,WAAU,QAAQ,QAAQ;AAG9B,UAAI,MAAM,WACN,WAAU,QAAQ,WAAW,MAAM,WAAW,OAAO,MAAM,WAAW,QAAQ;OAC1E,UAAU,MAAM,WAAW;OAC3B,UAAU,MAAM,WAAW;MAC9B,EAAC;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EF,MAAM,eAAe,IAAI,IAAI,CAAC,MAAM,WAAW,CAAE,GAAE,IAAI,CAAC,UAAU,CAAC,MAAM,MAAM,KAAM,EAAU;EAC/F,MAAM,eAAe,IAAI,IAAI,OAAO,KAAK,QAAQ,QAAQ;AAEzD,eAAa,QAAQ,CAAC,OAAO,cAAc;AACvC,QAAK,aAAa,IAAI,UAAU,CAC5B,KAAI,KACA,UAAG,MAAM,OAAO;IACZ,MAAM,MAAM;IACZ,OAAO,MAAM;IACb,IAAI,MAAM;IACV,UAAU,MAAM;GACnB,EAAC,CACL;EAER,EAAC;CAKL,EAAC;AAEF,QAAO;AACV;;;;ACpKD,SAAS,kBAAkBC,OAAmD;AAC1E,QAAO;EACH,MAAM,MAAM;EACZ,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,SAAS,MAAM;EACf,YAAY,MAAM;EAClB,QAAQ,MAAM;EACd,YAAY,MAAM;CACrB;AACJ;AAEM,SAAS,sCAAsCC,UAA8C;AAChG,UAAS,0BAA0B;CACnC,MAAMC,aAAkC,CAAE;AAC1C,MAAK,MAAM,SAAS,SAAS,QAAQ,EAAE;EACnC,MAAM,YAAY,SAAS,mBAAmB,MAAM,SAAS,IAAI;AACjE,aAAW,KAAK;GACZ,MAAM,MAAM,SAAS;GACrB,OAAO,MAAM,SAAS;GACtB,SAAS,MAAM,SAAS,WAAW;GACnC,QAAQ,UAAU,IAAI,kBAAkB;GACxC,SAAS,MAAM,SAAS,SAAS,IAAI,CAAC,WAAW;IAC7C,MAAM,MAAM;IACZ,IAAI,CAAC,GAAG,MAAM,EAAG;IACjB,QAAQ,MAAM;GACjB,GAAE;EACN,EAAC;CACL;AACD,QAAO;AACV"}
@@ -1,2 +0,0 @@
1
- import type { InternalDialect } from './internal/InternalDialect';
2
- export type Dialect = (typeof InternalDialect)[keyof typeof InternalDialect];
@@ -1,29 +0,0 @@
1
- import type { Builder } from '../builder/contracts/Builder';
2
- import type { MigrationMode } from './MigrationMode';
3
- /**
4
- * Base migration contract.
5
- *
6
- * Concrete migrations provide a stable `id` and define reversible schema/data
7
- * operations through `up` and `down`.
8
- */
9
- export declare abstract class Migration {
10
- static readonly BRAND: "tango.migration";
11
- static readonly CONSTRUCTOR_BRAND: "tango.migration.constructor";
12
- static readonly __tangoConstructorBrand: typeof Migration.CONSTRUCTOR_BRAND;
13
- readonly __tangoBrand: typeof Migration.BRAND;
14
- abstract id: string;
15
- /** Optional execution mode override (`online`/`offline`). */
16
- mode?: MigrationMode;
17
- /** Apply migration operations. */
18
- abstract up(m: Builder): void | Promise<void>;
19
- /** Revert migration operations. */
20
- abstract down(m: Builder): void | Promise<void>;
21
- /**
22
- * Narrow an unknown value to a migration instance.
23
- */
24
- static isMigration(value: unknown): value is Migration;
25
- /**
26
- * Narrow an unknown value to a migration constructor.
27
- */
28
- static isMigrationConstructor(value: unknown): value is new () => Migration;
29
- }
@@ -1,2 +0,0 @@
1
- import type { InternalMigrationMode } from './internal/InternalMigrationMode';
2
- export type MigrationMode = (typeof InternalMigrationMode)[keyof typeof InternalMigrationMode];
@@ -1,77 +0,0 @@
1
- import type { TrustedSqlFragment } from '@danceroutine/tango-core';
2
- import { InternalOperationKind } from './internal/InternalOperationKind';
3
- import type { ColumnSpec } from '../builder/contracts/ColumnSpec';
4
- export type TableCreate = {
5
- kind: typeof InternalOperationKind.TABLE_CREATE;
6
- table: string;
7
- columns: ColumnSpec[];
8
- };
9
- export type TableDrop = {
10
- kind: typeof InternalOperationKind.TABLE_DROP;
11
- table: string;
12
- cascade?: boolean;
13
- };
14
- export type ColumnAdd = {
15
- kind: typeof InternalOperationKind.COLUMN_ADD;
16
- table: string;
17
- column: ColumnSpec;
18
- };
19
- export type ColumnDrop = {
20
- kind: typeof InternalOperationKind.COLUMN_DROP;
21
- table: string;
22
- column: string;
23
- };
24
- export type ColumnAlter = {
25
- kind: typeof InternalOperationKind.COLUMN_ALTER;
26
- table: string;
27
- column: string;
28
- to: Partial<ColumnSpec>;
29
- };
30
- export type ColumnRename = {
31
- kind: typeof InternalOperationKind.COLUMN_RENAME;
32
- table: string;
33
- from: string;
34
- to: string;
35
- };
36
- export type IndexCreate = {
37
- kind: typeof InternalOperationKind.INDEX_CREATE;
38
- table: string;
39
- name: string;
40
- on: string[];
41
- unique?: boolean;
42
- where?: TrustedSqlFragment;
43
- concurrently?: boolean;
44
- };
45
- export type IndexDrop = {
46
- kind: typeof InternalOperationKind.INDEX_DROP;
47
- table: string;
48
- name: string;
49
- concurrently?: boolean;
50
- };
51
- export type ForeignKeyCreate = {
52
- kind: typeof InternalOperationKind.FK_CREATE;
53
- table: string;
54
- name?: string;
55
- columns: string[];
56
- refTable: string;
57
- refColumns: string[];
58
- onDelete?: string;
59
- onUpdate?: string;
60
- notValid?: boolean;
61
- };
62
- export type ForeignKeyValidate = {
63
- kind: typeof InternalOperationKind.FK_VALIDATE;
64
- table: string;
65
- name: string;
66
- };
67
- export type ForeignKeyDrop = {
68
- kind: typeof InternalOperationKind.FK_DROP;
69
- table: string;
70
- name: string;
71
- };
72
- export type CustomMigrationOperation<TName extends string = string, TArgs extends object = Record<string, unknown>> = {
73
- kind: 'custom';
74
- name: TName;
75
- args: TArgs;
76
- };
77
- export type MigrationOperation = TableCreate | TableDrop | ColumnAdd | ColumnDrop | ColumnAlter | ColumnRename | IndexCreate | IndexDrop | ForeignKeyCreate | ForeignKeyValidate | ForeignKeyDrop | CustomMigrationOperation;
@@ -1,11 +0,0 @@
1
- export declare const InternalColumnType: {
2
- readonly SERIAL: "serial";
3
- readonly INT: "int";
4
- readonly BIGINT: "bigint";
5
- readonly TEXT: "text";
6
- readonly BOOL: "bool";
7
- readonly TIMESTAMPTZ: "timestamptz";
8
- readonly JSONB: "jsonb";
9
- readonly UUID: "uuid";
10
- };
11
- export type InternalColumnType = (typeof InternalColumnType)[keyof typeof InternalColumnType];
@@ -1,5 +0,0 @@
1
- export declare const InternalDialect: {
2
- readonly POSTGRES: "postgres";
3
- readonly SQLITE: "sqlite";
4
- };
5
- export type InternalDialect = (typeof InternalDialect)[keyof typeof InternalDialect];
@@ -1,5 +0,0 @@
1
- export declare const InternalMigrationMode: {
2
- readonly TRANSACTIONAL: "transactional";
3
- readonly ONLINE: "online";
4
- };
5
- export type InternalMigrationMode = (typeof InternalMigrationMode)[keyof typeof InternalMigrationMode];
@@ -1,14 +0,0 @@
1
- export declare const InternalOperationKind: {
2
- readonly TABLE_CREATE: "table.create";
3
- readonly TABLE_DROP: "table.drop";
4
- readonly COLUMN_ADD: "column.add";
5
- readonly COLUMN_DROP: "column.drop";
6
- readonly COLUMN_ALTER: "column.alter";
7
- readonly COLUMN_RENAME: "column.rename";
8
- readonly INDEX_CREATE: "index.create";
9
- readonly INDEX_DROP: "index.drop";
10
- readonly FK_CREATE: "fk.create";
11
- readonly FK_VALIDATE: "fk.validate";
12
- readonly FK_DROP: "fk.drop";
13
- };
14
- export type InternalOperationKind = (typeof InternalOperationKind)[keyof typeof InternalOperationKind];
@@ -1,7 +0,0 @@
1
- export declare const InternalReferentialAction: {
2
- readonly CASCADE: "CASCADE";
3
- readonly SET_NULL: "SET NULL";
4
- readonly RESTRICT: "RESTRICT";
5
- readonly NO_ACTION: "NO ACTION";
6
- };
7
- export type InternalReferentialAction = (typeof InternalReferentialAction)[keyof typeof InternalReferentialAction];
@@ -1,10 +0,0 @@
1
- import { __export } from "./chunk-BkvOhyD0.js";
2
- import { Migration } from "./Migration-DYQ0hUG7.js";
3
-
4
- //#region src/domain/index.ts
5
- var domain_exports = {};
6
- __export(domain_exports, { Migration: () => Migration });
7
-
8
- //#endregion
9
- export { domain_exports };
10
- //# sourceMappingURL=domain-CwR-kUNS.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"domain-CwR-kUNS.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,48 +0,0 @@
1
- import type { MigrationOperation } from '../domain/MigrationOperation';
2
- /**
3
- * Input contract for generating a migration source file.
4
- */
5
- export interface GenerateMigrationOptions {
6
- /** Human-readable suffix used in file name/id generation. */
7
- name: string;
8
- /** Ordered migration operations to render. */
9
- operations: MigrationOperation[];
10
- /** Output directory for generated migration files. */
11
- directory: string;
12
- }
13
- /**
14
- * Source generator for class-based migration files.
15
- */
16
- export declare class MigrationGenerator {
17
- static readonly BRAND: "tango.migrations.generator";
18
- readonly __tangoBrand: typeof MigrationGenerator.BRAND;
19
- /**
20
- * Narrow an unknown value to `MigrationGenerator`.
21
- */
22
- static isMigrationGenerator(value: unknown): value is MigrationGenerator;
23
- /**
24
- * Generate a migration file and write it to disk.
25
- * Returns the file path of the created migration.
26
- */
27
- generate(options: GenerateMigrationOptions): Promise<string>;
28
- /**
29
- * Render migration operations to a TypeScript source string without writing to disk.
30
- */
31
- render(id: string, operations: MigrationOperation[]): string;
32
- private renderClassName;
33
- private renderOperation;
34
- private renderReverseOperation;
35
- private renderTableCreate;
36
- private renderTableDrop;
37
- private renderColumnAdd;
38
- private renderColumnDrop;
39
- private renderColumnAlter;
40
- private renderColumnRename;
41
- private renderIndexCreate;
42
- private renderIndexDrop;
43
- private renderForeignKeyCreate;
44
- private renderForeignKeyDrop;
45
- private renderColumnChain;
46
- private timestamp;
47
- private isNowDefault;
48
- }
@@ -1,10 +0,0 @@
1
- import { __export } from "./chunk-BkvOhyD0.js";
2
- import { MigrationGenerator } from "./MigrationGenerator-B1p0jHnx.js";
3
-
4
- //#region src/generator/index.ts
5
- var generator_exports = {};
6
- __export(generator_exports, { MigrationGenerator: () => MigrationGenerator });
7
-
8
- //#endregion
9
- export { generator_exports };
10
- //# sourceMappingURL=generator-DK-_f-PF.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"generator-DK-_f-PF.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":""}
@@ -1,24 +0,0 @@
1
- import { SqlSafetyEngine, type SqlDialect, type TrustedSqlFragment } from '@danceroutine/tango-core';
2
- /**
3
- * Migrations-local adapter that maps migration operations into the shared SQL
4
- * safety engine and returns quoted identifiers or trusted raw fragments.
5
- */
6
- export declare class MigrationSqlSafetyAdapter {
7
- private readonly dialect;
8
- private readonly engine;
9
- constructor(dialect: SqlDialect, engine?: SqlSafetyEngine);
10
- table(value: string): string;
11
- column(value: string, allowlist?: readonly string[]): string;
12
- columns(values: readonly string[], allowlist?: readonly string[]): string[];
13
- index(value: string): string;
14
- constraint(value: string): string;
15
- schema(value: string): string;
16
- rawFragment(key: string, value: TrustedSqlFragment): string;
17
- optionalRawFragment(key: string, value?: TrustedSqlFragment): string | undefined;
18
- rawDefault(value: TrustedSqlFragment | {
19
- now: true;
20
- } | null | undefined, nowSql: string): string | null | undefined;
21
- isTrustedFragment(value: unknown): value is TrustedSqlFragment;
22
- private quote;
23
- private isNowDefault;
24
- }
@@ -1,17 +0,0 @@
1
- import type { DbSchema } from './PostgresIntrospector';
2
- /**
3
- * Minimal DB client shape required by schema introspection.
4
- */
5
- export interface DBClient {
6
- /** Execute a SQL statement and return row results. */
7
- query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{
8
- rows: T[];
9
- }>;
10
- }
11
- /**
12
- * Dialect-specific schema introspection contract.
13
- */
14
- export interface DatabaseIntrospector {
15
- /** Read the current database schema state. */
16
- introspect(client: DBClient): Promise<DbSchema>;
17
- }