@danceroutine/tango-migrations 1.11.3 → 1.11.4

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 (37) hide show
  1. package/dist/{CompilerStrategy-vcZKg8qf.js → CompilerStrategy-Dc5_3-nw.js} +2 -2
  2. package/dist/{CompilerStrategy-vcZKg8qf.js.map → CompilerStrategy-Dc5_3-nw.js.map} +1 -1
  3. package/dist/{InternalOperationKind-M4a4H9OZ.js → InternalOperationKind-BJ7n-pUH.js} +14 -2
  4. package/dist/InternalOperationKind-BJ7n-pUH.js.map +1 -0
  5. package/dist/{IntrospectorStrategy-BijuyIaN.js → IntrospectorStrategy-BCTs_4wl.js} +2 -2
  6. package/dist/{IntrospectorStrategy-BijuyIaN.js.map → IntrospectorStrategy-BCTs_4wl.js.map} +1 -1
  7. package/dist/{MigrationGenerator-BmmerPXJ.js → MigrationGenerator-D-sSbsFG.js} +65 -43
  8. package/dist/MigrationGenerator-D-sSbsFG.js.map +1 -0
  9. package/dist/{MigrationRunner-B5AJel12.js → MigrationRunner-vG1lVlkz.js} +2 -2
  10. package/dist/{MigrationRunner-B5AJel12.js.map → MigrationRunner-vG1lVlkz.js.map} +1 -1
  11. package/dist/{SqliteCompilerFactory-CXlPAclY.js → SqliteCompilerFactory-C_56xoQM.js} +2 -3
  12. package/dist/{SqliteCompilerFactory-CXlPAclY.js.map → SqliteCompilerFactory-C_56xoQM.js.map} +1 -1
  13. package/dist/builder/index.js +1 -1
  14. package/dist/{builder-BSepa_PF.js → builder-Bhm_to6b.js} +2 -3
  15. package/dist/{builder-BSepa_PF.js.map → builder-Bhm_to6b.js.map} +1 -1
  16. package/dist/{cli-e8I1-dab.js → cli-B3MNpH29.js} +6 -6
  17. package/dist/{cli-e8I1-dab.js.map → cli-B3MNpH29.js.map} +1 -1
  18. package/dist/cli.js +1 -1
  19. package/dist/commands/index.js +1 -1
  20. package/dist/compilers/index.js +2 -2
  21. package/dist/{compilers-BW-WALoD.js → compilers-BlLQwwmu.js} +2 -2
  22. package/dist/{compilers-BW-WALoD.js.map → compilers-BlLQwwmu.js.map} +1 -1
  23. package/dist/diff/index.js +1 -1
  24. package/dist/{diff-7Xw8k4vp.js → diff-BsQr9Sl8.js} +2 -2
  25. package/dist/{diff-7Xw8k4vp.js.map → diff-BsQr9Sl8.js.map} +1 -1
  26. package/dist/generator/index.d.ts +1 -1
  27. package/dist/generator/index.js +1 -1
  28. package/dist/{index-B8VoE0M4.d.ts → index-Dcuh1zcQ.d.ts} +5 -1
  29. package/dist/index.d.ts +1 -1
  30. package/dist/index.js +9 -9
  31. package/dist/runner/index.js +1 -1
  32. package/dist/strategies/index.js +2 -2
  33. package/package.json +7 -7
  34. package/dist/InternalColumnType-Dzs9T6a6.js +0 -15
  35. package/dist/InternalColumnType-Dzs9T6a6.js.map +0 -1
  36. package/dist/InternalOperationKind-M4a4H9OZ.js.map +0 -1
  37. package/dist/MigrationGenerator-BmmerPXJ.js.map +0 -1
@@ -45,6 +45,10 @@ declare class MigrationGenerator {
45
45
  private renderForeignKeyCreate;
46
46
  private renderForeignKeyDrop;
47
47
  private renderColumnChain;
48
+ private renderStringLiteral;
49
+ private renderStringArrayLiteral;
50
+ private renderCommentStringLiteral;
51
+ private renderColumnTypeMethod;
48
52
  private timestamp;
49
53
  private isNowDefault;
50
54
  }
@@ -53,4 +57,4 @@ declare namespace index_d_exports {
53
57
  }
54
58
  //#endregion
55
59
  export { GenerateMigrationOptions as n, MigrationGenerator as r, index_d_exports as t };
56
- //# sourceMappingURL=index-B8VoE0M4.d.ts.map
60
+ //# sourceMappingURL=index-Dcuh1zcQ.d.ts.map
package/dist/index.d.ts CHANGED
@@ -8,7 +8,7 @@ import { a as DbTable, c as DatabaseIntrospector, i as DbSchema, n as DbForeignK
8
8
  import { r as diffSchema, t as index_d_exports$3 } from "./index-CzdR_Ig9.js";
9
9
  import { t as Dialect } from "./Dialect-Cp4r7UfW.js";
10
10
  import { n as Migration, t as index_d_exports$4 } from "./index-DdCF5yCg.js";
11
- import { n as GenerateMigrationOptions, r as MigrationGenerator, t as index_d_exports$5 } from "./index-B8VoE0M4.js";
11
+ import { n as GenerateMigrationOptions, r as MigrationGenerator, t as index_d_exports$5 } from "./index-Dcuh1zcQ.js";
12
12
  import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "./CompilerStrategy-DqmcqAC-.js";
13
13
  import { n as MigrationRunner, t as index_d_exports$7 } from "./index-ni7Db8Lv.js";
14
14
  import { a as SqliteIntrospector, i as DbTable$1, n as DbColumn$1, r as DbSchema$1, t as index_d_exports$6 } from "./index-sywIP4pt.js";
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  import { t as Migration } from "./Migration-DxHHPyzn.js";
2
2
  import { t as domain_exports } from "./domain/index.js";
3
- import { a as applyFieldType, i as OpBuilder, t as builder_exports } from "./builder-BSepa_PF.js";
3
+ import { a as applyFieldType, i as OpBuilder, t as builder_exports } from "./builder-Bhm_to6b.js";
4
4
  import { t as CollectingBuilder } from "./CollectingBuilder-BIfAKs_x.js";
5
- import { i as PostgresCompiler, n as SqliteCompiler } from "./SqliteCompilerFactory-CXlPAclY.js";
6
- import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "./CompilerStrategy-vcZKg8qf.js";
7
- import { t as MigrationRunner } from "./MigrationRunner-B5AJel12.js";
5
+ import { i as PostgresCompiler, n as SqliteCompiler } from "./SqliteCompilerFactory-C_56xoQM.js";
6
+ import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "./CompilerStrategy-Dc5_3-nw.js";
7
+ import { t as MigrationRunner } from "./MigrationRunner-vG1lVlkz.js";
8
8
  import { t as runner_exports } from "./runner/index.js";
9
- import { t as MigrationGenerator } from "./MigrationGenerator-BmmerPXJ.js";
9
+ import { t as MigrationGenerator } from "./MigrationGenerator-D-sSbsFG.js";
10
10
  import { t as generator_exports } from "./generator/index.js";
11
- import { r as diffSchema, t as diff_exports } from "./diff-7Xw8k4vp.js";
12
- import { t as compilers_exports } from "./compilers-BW-WALoD.js";
11
+ import { r as diffSchema, t as diff_exports } from "./diff-BsQr9Sl8.js";
12
+ import { t as compilers_exports } from "./compilers-BlLQwwmu.js";
13
13
  import { n as PostgresIntrospector, t as SqliteIntrospector } from "./SqliteIntrospector-CfItmGgA.js";
14
14
  import { t as introspect_exports } from "./introspect/index.js";
15
- import { n as createDefaultIntrospectorStrategy, t as IntrospectorStrategy } from "./IntrospectorStrategy-BijuyIaN.js";
15
+ import { n as createDefaultIntrospectorStrategy, t as IntrospectorStrategy } from "./IntrospectorStrategy-BCTs_4wl.js";
16
16
  import { t as strategies_exports } from "./strategies/index.js";
17
- import { t as registerMigrationsCommands } from "./cli-e8I1-dab.js";
17
+ import { t as registerMigrationsCommands } from "./cli-B3MNpH29.js";
18
18
  import { t as commands_exports } from "./commands/index.js";
19
19
  import { trustedSql } from "@danceroutine/tango-core";
20
20
  export { CollectingBuilder, CompilerStrategy, IntrospectorStrategy, Migration, MigrationGenerator, MigrationRunner, OpBuilder, OpBuilder as op, PostgresCompiler, PostgresIntrospector, SqliteCompiler, SqliteIntrospector, applyFieldType, builder_exports as builder, commands_exports as commands, compilers_exports as compilers, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy, diff_exports as diff, diffSchema, domain_exports as domain, generator_exports as generator, introspect_exports as introspect, registerMigrationsCommands, runner_exports as runner, strategies_exports as strategies, trustedSql };
@@ -1,5 +1,5 @@
1
1
  import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
- import { t as MigrationRunner } from "../MigrationRunner-B5AJel12.js";
2
+ import { t as MigrationRunner } from "../MigrationRunner-vG1lVlkz.js";
3
3
  //#region src/runner/index.ts
4
4
  var runner_exports = /* @__PURE__ */ __exportAll({ MigrationRunner: () => MigrationRunner });
5
5
  //#endregion
@@ -1,6 +1,6 @@
1
1
  import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
- import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "../CompilerStrategy-vcZKg8qf.js";
3
- import { n as createDefaultIntrospectorStrategy, t as IntrospectorStrategy } from "../IntrospectorStrategy-BijuyIaN.js";
2
+ import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "../CompilerStrategy-Dc5_3-nw.js";
3
+ import { n as createDefaultIntrospectorStrategy, t as IntrospectorStrategy } from "../IntrospectorStrategy-BCTs_4wl.js";
4
4
  //#region src/strategies/index.ts
5
5
  var strategies_exports = /* @__PURE__ */ __exportAll({
6
6
  CompilerStrategy: () => CompilerStrategy,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danceroutine/tango-migrations",
3
- "version": "1.11.3",
3
+ "version": "1.11.4",
4
4
  "description": "Auto-migration system with ops DSL for Tango",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -67,10 +67,10 @@
67
67
  "jiti": "^2.7.0",
68
68
  "kleur": "^4.1.5",
69
69
  "yargs": "^18.0.0",
70
- "@danceroutine/tango-config": "1.11.3",
71
- "@danceroutine/tango-codegen": "1.11.3",
72
- "@danceroutine/tango-core": "1.11.3",
73
- "@danceroutine/tango-schema": "1.11.3"
70
+ "@danceroutine/tango-config": "1.11.4",
71
+ "@danceroutine/tango-core": "1.11.4",
72
+ "@danceroutine/tango-codegen": "1.11.4",
73
+ "@danceroutine/tango-schema": "1.11.4"
74
74
  },
75
75
  "peerDependencies": {
76
76
  "pg": "^8.20.0",
@@ -95,8 +95,8 @@
95
95
  "typescript": "^5.6.3",
96
96
  "vitest": "^4.1.7",
97
97
  "zod": "^4.0.0",
98
- "@danceroutine/tango-testing": "1.11.3",
99
- "@danceroutine/tango-orm": "1.11.3"
98
+ "@danceroutine/tango-testing": "1.11.4",
99
+ "@danceroutine/tango-orm": "1.11.4"
100
100
  },
101
101
  "scripts": {
102
102
  "build": "tsdown",
@@ -1,15 +0,0 @@
1
- //#region src/domain/internal/InternalColumnType.ts
2
- const InternalColumnType = {
3
- SERIAL: "serial",
4
- INT: "int",
5
- BIGINT: "bigint",
6
- TEXT: "text",
7
- BOOL: "bool",
8
- TIMESTAMPTZ: "timestamptz",
9
- JSONB: "jsonb",
10
- UUID: "uuid"
11
- };
12
- //#endregion
13
- export { InternalColumnType as t };
14
-
15
- //# sourceMappingURL=InternalColumnType-Dzs9T6a6.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"InternalColumnType-Dzs9T6a6.js","names":[],"sources":["../src/domain/internal/InternalColumnType.ts"],"sourcesContent":["export const InternalColumnType = {\n SERIAL: 'serial',\n INT: 'int',\n BIGINT: 'bigint',\n TEXT: 'text',\n BOOL: 'bool',\n TIMESTAMPTZ: 'timestamptz',\n JSONB: 'jsonb',\n UUID: 'uuid',\n} as const;\n\nexport type InternalColumnType = (typeof InternalColumnType)[keyof typeof InternalColumnType];\n"],"mappings":";AAAA,MAAa,qBAAqB;CAC9B,QAAQ;CACR,KAAK;CACL,QAAQ;CACR,MAAM;CACN,MAAM;CACN,aAAa;CACb,OAAO;CACP,MAAM;AACV"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"InternalOperationKind-M4a4H9OZ.js","names":[],"sources":["../src/domain/internal/InternalOperationKind.ts"],"sourcesContent":["export const InternalOperationKind = {\n TABLE_CREATE: 'table.create',\n TABLE_DROP: 'table.drop',\n COLUMN_ADD: 'column.add',\n COLUMN_DROP: 'column.drop',\n COLUMN_ALTER: 'column.alter',\n COLUMN_RENAME: 'column.rename',\n INDEX_CREATE: 'index.create',\n INDEX_DROP: 'index.drop',\n FK_CREATE: 'fk.create',\n FK_VALIDATE: 'fk.validate',\n FK_DROP: 'fk.drop',\n} as const;\n\nexport type InternalOperationKind = (typeof InternalOperationKind)[keyof typeof InternalOperationKind];\n"],"mappings":";AAAA,MAAa,wBAAwB;CACjC,cAAc;CACd,YAAY;CACZ,YAAY;CACZ,aAAa;CACb,cAAc;CACd,eAAe;CACf,cAAc;CACd,YAAY;CACZ,WAAW;CACX,aAAa;CACb,SAAS;AACb"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"MigrationGenerator-BmmerPXJ.js","names":[],"sources":["../src/generator/MigrationGenerator.ts"],"sourcesContent":["import { isTrustedSqlFragment } from '@danceroutine/tango-core';\nimport type {\n MigrationOperation,\n TableCreate,\n TableDrop,\n ColumnAdd,\n ColumnDrop,\n ColumnAlter,\n ColumnRename,\n IndexCreate,\n IndexDrop,\n ForeignKeyCreate,\n ForeignKeyDrop,\n} from '../domain/MigrationOperation';\nimport type { ColumnSpec } from '../builder/contracts/ColumnSpec';\nimport { InternalOperationKind } from '../domain/internal/InternalOperationKind';\nimport { writeFile, mkdir } from 'node:fs/promises';\nimport { join } from 'node:path';\n\n/**\n * Input contract for generating a migration source file.\n */\nexport interface GenerateMigrationOptions {\n /** Human-readable suffix used in file name/id generation. */\n name: string;\n /** Ordered migration operations to render. */\n operations: MigrationOperation[];\n /** Output directory for generated migration files. */\n directory: string;\n}\n\n/**\n * Source generator for class-based migration files.\n */\nexport class MigrationGenerator {\n static readonly BRAND = 'tango.migrations.generator' as const;\n readonly __tangoBrand: typeof MigrationGenerator.BRAND = MigrationGenerator.BRAND;\n\n /**\n * Narrow an unknown value to `MigrationGenerator`.\n */\n static isMigrationGenerator(value: unknown): value is MigrationGenerator {\n return (\n typeof value === 'object' &&\n value !== null &&\n (value as { __tangoBrand?: unknown }).__tangoBrand === MigrationGenerator.BRAND\n );\n }\n\n /**\n * Generate a migration file and write it to disk.\n * Returns the file path of the created migration.\n */\n async generate(options: GenerateMigrationOptions): Promise<string> {\n const { name, operations, directory } = options;\n\n if (operations.length === 0) {\n throw new Error('No operations to generate — models and database are in sync');\n }\n\n const timestamp = this.timestamp();\n const id = `${timestamp}_${name}`;\n const filename = `${id}.ts`;\n const filepath = join(directory, filename);\n\n const source = this.render(id, operations);\n\n await mkdir(directory, { recursive: true });\n await writeFile(filepath, source, 'utf-8');\n\n return filepath;\n }\n\n /**\n * Render migration operations to a TypeScript source string without writing to disk.\n */\n render(id: string, operations: MigrationOperation[]): string {\n const upOps = operations.map((operation) => this.renderOperation(operation));\n const downOps = operations.map((operation) => this.renderReverseOperation(operation));\n downOps.reverse();\n const className = this.renderClassName(id);\n\n const lines = [\n `import { Migration, op, trustedSql, type Builder } from '@danceroutine/tango-migrations';`,\n ``,\n `export default class ${className} extends Migration {`,\n ` id = '${id}';`,\n ``,\n ` up(m: Builder) {`,\n ` m.run(`,\n ...upOps.map((code: string, index: number) => {\n const comma = index < upOps.length - 1 ? ',' : '';\n return ` ${code}${comma}`;\n }),\n ` );`,\n ` }`,\n ``,\n ` down(m: Builder) {`,\n ` m.run(`,\n ...downOps.map((code: string, index: number) => {\n const comma = index < downOps.length - 1 ? ',' : '';\n return ` ${code}${comma}`;\n }),\n ` );`,\n ` }`,\n `}`,\n ``,\n ];\n\n return lines.join('\\n');\n }\n\n private renderClassName(id: string): string {\n const normalized = id.replace(/[^a-zA-Z0-9]+/g, '_').replace(/^(\\d)/, '_$1');\n return `Migration_${normalized}`;\n }\n\n private renderOperation(operation: MigrationOperation): string {\n switch (operation.kind) {\n case InternalOperationKind.TABLE_CREATE:\n return this.renderTableCreate(operation);\n case InternalOperationKind.TABLE_DROP:\n return this.renderTableDrop(operation);\n case InternalOperationKind.COLUMN_ADD:\n return this.renderColumnAdd(operation);\n case InternalOperationKind.COLUMN_DROP:\n return this.renderColumnDrop(operation);\n case InternalOperationKind.COLUMN_ALTER:\n return this.renderColumnAlter(operation);\n case InternalOperationKind.COLUMN_RENAME:\n return this.renderColumnRename(operation);\n case InternalOperationKind.INDEX_CREATE:\n return this.renderIndexCreate(operation);\n case InternalOperationKind.INDEX_DROP:\n return this.renderIndexDrop(operation);\n case InternalOperationKind.FK_CREATE:\n return this.renderForeignKeyCreate(operation);\n case InternalOperationKind.FK_DROP:\n return this.renderForeignKeyDrop(operation);\n case InternalOperationKind.FK_VALIDATE:\n return `op.foreignKeyValidate({ table: '${operation.table}', name: '${operation.name}' })`;\n case 'custom':\n return `/* custom operation '${operation.name}' cannot be code-generated */`;\n default:\n return `/* unsupported operation */`;\n }\n }\n\n private renderReverseOperation(operation: MigrationOperation): string {\n switch (operation.kind) {\n case InternalOperationKind.TABLE_CREATE:\n return `op.table('${operation.table}').drop()`;\n case InternalOperationKind.TABLE_DROP:\n return `/* manual reverse required: recreate dropped table '${operation.table}' */`;\n case InternalOperationKind.COLUMN_ADD:\n return `op.table('${operation.table}').dropColumn('${operation.column.name}')`;\n case InternalOperationKind.COLUMN_DROP:\n return `/* manual reverse required: restore dropped column '${operation.column}' */`;\n case InternalOperationKind.COLUMN_ALTER:\n return `/* manual reverse required: revert ALTER COLUMN '${operation.column}' on '${operation.table}' */`;\n case InternalOperationKind.COLUMN_RENAME:\n return `op.table('${operation.table}').renameColumn('${operation.to}', '${operation.from}')`;\n case InternalOperationKind.INDEX_CREATE:\n return `op.index.drop({ name: '${operation.name}', table: '${operation.table}' })`;\n case InternalOperationKind.INDEX_DROP:\n return `/* manual reverse required: recreate dropped index '${operation.name}' */`;\n case InternalOperationKind.FK_CREATE:\n return `op.foreignKeyDrop({ table: '${operation.table}', name: '${operation.name ?? `${operation.table}_${operation.columns.join('_')}_fkey`}' })`;\n case InternalOperationKind.FK_DROP:\n return `/* manual reverse required: recreate dropped FK '${operation.name}' */`;\n case InternalOperationKind.FK_VALIDATE:\n return `/* no reverse needed for FK_VALIDATE */`;\n case 'custom':\n return `/* manual reverse required: custom operation '${operation.name}' */`;\n default:\n return `/* unsupported reverse operation */`;\n }\n }\n\n private renderTableCreate(operation: TableCreate): string {\n const columnLines = operation.columns.map((col) => {\n const chain = this.renderColumnChain(col);\n return ` cols.add('${col.name}', (b) => b${chain});`;\n });\n\n return [`op.table('${operation.table}').create((cols) => {`, ...columnLines, ` })`].join('\\n');\n }\n\n private renderTableDrop(operation: TableDrop): string {\n if (operation.cascade) {\n return `op.table('${operation.table}').drop({ cascade: true })`;\n }\n return `op.table('${operation.table}').drop()`;\n }\n\n private renderColumnAdd(operation: ColumnAdd): string {\n const chain = this.renderColumnChain(operation.column);\n return `op.table('${operation.table}').addColumn('${operation.column.name}', (b) => b${chain})`;\n }\n\n private renderColumnDrop(operation: ColumnDrop): string {\n return `op.table('${operation.table}').dropColumn('${operation.column}')`;\n }\n\n private renderColumnAlter(operation: ColumnAlter): string {\n const parts: string[] = [];\n if (operation.to.type) {\n parts.push(`type: '${operation.to.type}'`);\n }\n if (operation.to.notNull !== undefined) {\n parts.push(`notNull: ${operation.to.notNull}`);\n }\n if (operation.to.default !== undefined) {\n if (operation.to.default === null) {\n parts.push(`default: null`);\n } else if (this.isNowDefault(operation.to.default)) {\n parts.push(`default: { now: true }`);\n } else if (isTrustedSqlFragment(operation.to.default)) {\n parts.push(`default: trustedSql(${JSON.stringify(operation.to.default.sql)})`);\n }\n }\n return `op.table('${operation.table}').alterColumn('${operation.column}', { ${parts.join(', ')} })`;\n }\n\n private renderColumnRename(operation: ColumnRename): string {\n return `op.table('${operation.table}').renameColumn('${operation.from}', '${operation.to}')`;\n }\n\n private renderIndexCreate(operation: IndexCreate): string {\n const parts: string[] = [\n `name: '${operation.name}'`,\n `table: '${operation.table}'`,\n `on: [${operation.on.map((c) => `'${c}'`).join(', ')}]`,\n ];\n if (operation.unique) {\n parts.push(`unique: true`);\n }\n if (operation.where) {\n parts.push(`where: trustedSql(${JSON.stringify(operation.where.sql)})`);\n }\n if (operation.concurrently) {\n parts.push(`concurrently: true`);\n }\n return `op.index.create({ ${parts.join(', ')} })`;\n }\n\n private renderIndexDrop(operation: IndexDrop): string {\n return `op.index.drop({ name: '${operation.name}', table: '${operation.table}' })`;\n }\n\n private renderForeignKeyCreate(operation: ForeignKeyCreate): string {\n const parts: string[] = [\n `table: '${operation.table}'`,\n `columns: [${operation.columns.map((c) => `'${c}'`).join(', ')}]`,\n `references: { table: '${operation.refTable}', columns: [${operation.refColumns.map((c) => `'${c}'`).join(', ')}] }`,\n ];\n if (operation.name) {\n parts.push(`name: '${operation.name}'`);\n }\n if (operation.onDelete) {\n parts.push(`onDelete: '${operation.onDelete}'`);\n }\n if (operation.onUpdate) {\n parts.push(`onUpdate: '${operation.onUpdate}'`);\n }\n if (operation.notValid) {\n parts.push(`notValid: true`);\n }\n return `op.foreignKey({ ${parts.join(', ')} })`;\n }\n\n private renderForeignKeyDrop(operation: ForeignKeyDrop): string {\n return `op.foreignKeyDrop({ table: '${operation.table}', name: '${operation.name}' })`;\n }\n\n private renderColumnChain(col: ColumnSpec): string {\n const parts: string[] = [];\n\n if (col.type) {\n parts.push(`.${col.type}()`);\n }\n if (col.notNull) {\n parts.push(`.notNull()`);\n }\n if (col.default !== undefined && col.default !== null) {\n if (this.isNowDefault(col.default)) {\n parts.push(`.defaultNow()`);\n } else if (isTrustedSqlFragment(col.default)) {\n parts.push(`.default(trustedSql(${JSON.stringify(col.default.sql)}))`);\n }\n } else if (col.default === null) {\n parts.push(`.default(null)`);\n }\n if (col.primaryKey) {\n parts.push(`.primaryKey()`);\n }\n if (col.unique) {\n parts.push(`.unique()`);\n }\n if (col.references) {\n const refParts: string[] = [];\n if (col.references.onDelete) {\n refParts.push(`onDelete: '${col.references.onDelete}'`);\n }\n if (col.references.onUpdate) {\n refParts.push(`onUpdate: '${col.references.onUpdate}'`);\n }\n const opts = refParts.length > 0 ? `, { ${refParts.join(', ')} }` : '';\n parts.push(`.references('${col.references.table}', '${col.references.column}'${opts})`);\n }\n\n return parts.join('');\n }\n\n private timestamp(): string {\n const now = new Date();\n const year = now.getFullYear();\n const month = String(now.getMonth() + 1).padStart(2, '0');\n const day = String(now.getDate()).padStart(2, '0');\n const hours = String(now.getHours()).padStart(2, '0');\n const minutes = String(now.getMinutes()).padStart(2, '0');\n const seconds = String(now.getSeconds()).padStart(2, '0');\n return `${year}${month}${day}${hours}${minutes}${seconds}`;\n }\n\n private isNowDefault(value: ColumnSpec['default']): value is { now: true } {\n return typeof value === 'object' && value !== null && 'now' in value && value.now === true;\n }\n}\n"],"mappings":";;;;;;;;AAkCA,IAAa,qBAAb,MAAa,mBAAmB;CAC5B,OAAgB,QAAQ;CACxB,eAA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