@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
@@ -0,0 +1,180 @@
1
+ import { n as MigrationMode, t as Builder } from "./Builder-y8vj7XXN.js";
2
+ import { _ as ColumnType, a as CustomMigrationOperation, c as ForeignKeyValidate, d as MigrationOperation, f as TableCreate, g as DeleteReferentialAction, h as UpdateReferentialAction, i as ColumnRename, l as IndexCreate, m as ColumnSpec, n as ColumnAlter, o as ForeignKeyCreate, p as TableDrop, r as ColumnDrop, s as ForeignKeyDrop, t as ColumnAdd, u as IndexDrop } from "./MigrationOperation-qpdhPEs9.js";
3
+ import { TrustedSqlFragment } from "@danceroutine/tango-core";
4
+
5
+ //#region src/builder/contracts/index.d.ts
6
+ declare namespace index_d_exports$3 {
7
+ export { Builder, ColumnSpec, ColumnType, DeleteReferentialAction, UpdateReferentialAction };
8
+ }
9
+ //#endregion
10
+ //#region src/builder/ops/OpBuilder.d.ts
11
+ /**
12
+ * Fluent builder for column specifications used by table operations.
13
+ */
14
+ declare class ColumnBuilder {
15
+ static readonly BRAND: "tango.migrations.column_builder";
16
+ readonly __tangoBrand: typeof ColumnBuilder.BRAND;
17
+ private spec;
18
+ constructor(name: string);
19
+ static isColumnBuilder(value: unknown): value is ColumnBuilder;
20
+ /** Set column type to serial/auto-increment. */
21
+ serial(): ColumnBuilder;
22
+ /** Set column type to integer. */
23
+ int(): ColumnBuilder;
24
+ /** Set column type to bigint. */
25
+ bigint(): ColumnBuilder;
26
+ /** Set column type to text. */
27
+ text(): ColumnBuilder;
28
+ /** Set column type to boolean. */
29
+ bool(): ColumnBuilder;
30
+ /** Set column type to timestamptz. */
31
+ timestamptz(): ColumnBuilder;
32
+ /** Set column type to JSONB. */
33
+ jsonb(): ColumnBuilder;
34
+ /** Set column type to UUID. */
35
+ uuid(): ColumnBuilder;
36
+ /** Mark column as NOT NULL. */
37
+ notNull(): ColumnBuilder;
38
+ /** Set default to current timestamp. */
39
+ defaultNow(): ColumnBuilder;
40
+ /** Set reviewed raw SQL default expression. */
41
+ default(v: TrustedSqlFragment | null): ColumnBuilder;
42
+ /** Mark column as part of primary key. */
43
+ primaryKey(): ColumnBuilder;
44
+ /** Mark column as unique. */
45
+ unique(): ColumnBuilder;
46
+ /** Configure foreign key reference metadata. */
47
+ references(table: string, column: string, opts?: {
48
+ onDelete?: DeleteReferentialAction;
49
+ onUpdate?: UpdateReferentialAction;
50
+ }): ColumnBuilder;
51
+ _done(): ColumnSpec;
52
+ }
53
+ type TableOperationBuilder = {
54
+ create(def: (cols: {
55
+ add: (name: string, cb: (b: ColumnBuilder) => ColumnBuilder) => void;
56
+ }) => void): TableCreate;
57
+ drop(opts?: {
58
+ cascade?: boolean;
59
+ }): TableDrop;
60
+ addColumn(name: string, cb: (b: ColumnBuilder) => ColumnBuilder): ColumnAdd;
61
+ dropColumn(name: string): ColumnDrop;
62
+ alterColumn(name: string, to: Partial<ColumnSpec>): ColumnAlter;
63
+ renameColumn(from: string, to: string): ColumnRename;
64
+ };
65
+ /**
66
+ * Static factory for migration operations.
67
+ */
68
+ declare class OpBuilder {
69
+ static readonly BRAND: "tango.migrations.op_builder";
70
+ static index: {
71
+ /** Build an index create operation. */create(p: {
72
+ name: string;
73
+ table: string;
74
+ on: string[];
75
+ unique?: boolean;
76
+ where?: TrustedSqlFragment;
77
+ concurrently?: boolean;
78
+ }): IndexCreate; /** Build an index drop operation. */
79
+ drop(p: {
80
+ name: string;
81
+ table: string;
82
+ concurrently?: boolean;
83
+ }): IndexDrop;
84
+ };
85
+ private static customOperations;
86
+ readonly __tangoBrand: typeof OpBuilder.BRAND;
87
+ /**
88
+ * Narrow an unknown value to the shared migration operation builder type.
89
+ */
90
+ static isOpBuilder(value: unknown): value is OpBuilder;
91
+ /**
92
+ * Build table-scoped migration operations.
93
+ */
94
+ static table(table: string): TableOperationBuilder;
95
+ /** Build a foreign key create operation. */
96
+ static foreignKey(p: {
97
+ table: string;
98
+ name?: string;
99
+ columns: string[];
100
+ references: {
101
+ table: string;
102
+ columns: string[];
103
+ };
104
+ onDelete?: string;
105
+ onUpdate?: string;
106
+ notValid?: boolean;
107
+ }): ForeignKeyCreate;
108
+ /** Build a foreign key validation operation. */
109
+ static foreignKeyValidate(p: {
110
+ table: string;
111
+ name: string;
112
+ }): ForeignKeyValidate;
113
+ /** Build a foreign key drop operation. */
114
+ static foreignKeyDrop(p: {
115
+ table: string;
116
+ name: string;
117
+ }): ForeignKeyDrop;
118
+ /**
119
+ * Register a custom migration operation builder.
120
+ */
121
+ static registerCustomOperation<TName extends string, TArgs extends object>(name: TName, builder: (args: TArgs) => CustomMigrationOperation<TName, TArgs>): void;
122
+ /**
123
+ * Resolve a previously registered custom operation builder.
124
+ */
125
+ static getCustomOperation<TName extends string, TArgs extends object>(name: TName): ((args: TArgs) => CustomMigrationOperation<TName, TArgs>) | undefined;
126
+ }
127
+ /**
128
+ * Apply a domain field type to a column builder.
129
+ */
130
+ declare function applyFieldType(builder: ColumnBuilder, fieldType: ColumnType): ColumnBuilder;
131
+ declare namespace index_d_exports$2 {
132
+ export { OpBuilder, applyFieldType, OpBuilder as op };
133
+ }
134
+ //#endregion
135
+ //#region src/builder/runtime/CollectingBuilder.d.ts
136
+ /**
137
+ * In-memory builder that collects migration operations and data callbacks.
138
+ */
139
+ declare class CollectingBuilder implements Builder {
140
+ static readonly BRAND: "tango.migrations.collecting_builder";
141
+ readonly __tangoBrand: typeof CollectingBuilder.BRAND;
142
+ ops: MigrationOperation[];
143
+ dataFns: Array<(ctx: {
144
+ query(sql: string, params?: readonly unknown[]): Promise<void>;
145
+ }) => Promise<void>>;
146
+ private mode?;
147
+ /**
148
+ * Narrow an unknown value to the in-memory builder used during migration collection.
149
+ */
150
+ static isCollectingBuilder(value: unknown): value is CollectingBuilder;
151
+ /**
152
+ * Append schema operations to the collection.
153
+ */
154
+ run(...ops: MigrationOperation[]): void;
155
+ /**
156
+ * Register a data migration callback.
157
+ */
158
+ data(fn: (ctx: {
159
+ query(sql: string, params?: readonly unknown[]): Promise<void>;
160
+ }) => Promise<void>): void;
161
+ /**
162
+ * Set execution options for the migration.
163
+ */
164
+ options(o: {
165
+ mode?: MigrationMode;
166
+ }): void;
167
+ /**
168
+ * Get the currently configured migration mode.
169
+ */
170
+ getMode(): MigrationMode | undefined;
171
+ }
172
+ declare namespace index_d_exports$1 {
173
+ export { CollectingBuilder };
174
+ }
175
+ declare namespace index_d_exports {
176
+ export { Builder, CollectingBuilder, ColumnSpec, ColumnType, DeleteReferentialAction, OpBuilder, UpdateReferentialAction, applyFieldType, index_d_exports$3 as contracts, OpBuilder as op, index_d_exports$2 as ops, index_d_exports$1 as runtime };
177
+ }
178
+ //#endregion
179
+ export { OpBuilder as a, index_d_exports$2 as i, index_d_exports$1 as n, applyFieldType as o, CollectingBuilder as r, index_d_exports$3 as s, index_d_exports as t };
180
+ //# sourceMappingURL=index-CzpjLzoS.d.ts.map
@@ -0,0 +1,13 @@
1
+ import { Argv } from "yargs";
2
+
3
+ //#region src/commands/cli.d.ts
4
+ /**
5
+ * Register Tango's migration commands on an existing yargs parser.
6
+ */
7
+ declare function registerMigrationsCommands(yargsBuilder: Argv): Argv;
8
+ declare namespace index_d_exports {
9
+ export { registerMigrationsCommands };
10
+ }
11
+ //#endregion
12
+ export { registerMigrationsCommands as n, index_d_exports as t };
13
+ //# sourceMappingURL=index-D7qe9iKG.d.ts.map
@@ -0,0 +1,38 @@
1
+ import { n as MigrationMode, t as Builder } from "./Builder-y8vj7XXN.js";
2
+ import { d as MigrationOperation } from "./MigrationOperation-qpdhPEs9.js";
3
+ import { t as Dialect } from "./Dialect-Cp4r7UfW.js";
4
+
5
+ //#region src/domain/Migration.d.ts
6
+ /**
7
+ * Base migration contract.
8
+ *
9
+ * Concrete migrations provide a stable `id` and define reversible schema/data
10
+ * operations through `up` and `down`.
11
+ */
12
+ declare abstract class Migration {
13
+ static readonly BRAND: "tango.migration";
14
+ static readonly CONSTRUCTOR_BRAND: "tango.migration.constructor";
15
+ static readonly __tangoConstructorBrand: typeof Migration.CONSTRUCTOR_BRAND;
16
+ readonly __tangoBrand: typeof Migration.BRAND;
17
+ abstract id: string;
18
+ /** Optional execution mode override (`online`/`offline`). */
19
+ mode?: MigrationMode;
20
+ /** Apply migration operations. */
21
+ abstract up(m: Builder): void | Promise<void>;
22
+ /** Revert migration operations. */
23
+ abstract down(m: Builder): void | Promise<void>;
24
+ /**
25
+ * Narrow an unknown value to a migration instance.
26
+ */
27
+ static isMigration(value: unknown): value is Migration;
28
+ /**
29
+ * Narrow an unknown value to a migration constructor.
30
+ */
31
+ static isMigrationConstructor(value: unknown): value is new () => Migration;
32
+ }
33
+ declare namespace index_d_exports {
34
+ export { Dialect, Migration, MigrationMode, MigrationOperation };
35
+ }
36
+ //#endregion
37
+ export { Migration as n, index_d_exports as t };
38
+ //# sourceMappingURL=index-DdCF5yCg.d.ts.map
@@ -0,0 +1,41 @@
1
+ import { c as DatabaseIntrospector, i as DbSchema, s as DBClient } from "./PostgresIntrospector-DQDTZUW_.js";
2
+ import { t as Dialect } from "./Dialect-Cp4r7UfW.js";
3
+ import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "./CompilerStrategy-DqmcqAC-.js";
4
+
5
+ //#region src/strategies/IntrospectorStrategy.d.ts
6
+ type IntrospectorFactory = {
7
+ create(): DatabaseIntrospector;
8
+ };
9
+ type IntrospectorFactoryRegistry = Record<Dialect, IntrospectorFactory>;
10
+ /**
11
+ * Dialect-aware schema introspection orchestration.
12
+ */
13
+ declare class IntrospectorStrategy {
14
+ private readonly factories;
15
+ static readonly BRAND: "tango.migrations.introspector_strategy";
16
+ readonly __tangoBrand: typeof IntrospectorStrategy.BRAND;
17
+ private readonly introspectorCache;
18
+ constructor(factories: IntrospectorFactoryRegistry);
19
+ /**
20
+ * Narrow an unknown value to the dialect-aware schema introspection strategy.
21
+ */
22
+ static isIntrospectorStrategy(value: unknown): value is IntrospectorStrategy;
23
+ /**
24
+ * Introspect database schema using a dialect-specific introspector.
25
+ */
26
+ introspect(dialect: Dialect, client: DBClient): Promise<DbSchema>;
27
+ /**
28
+ * Resolve and cache an introspector instance for a dialect.
29
+ */
30
+ getIntrospector(dialect: Dialect): DatabaseIntrospector;
31
+ }
32
+ /**
33
+ * Create the default introspector strategy with built-in dialect support.
34
+ */
35
+ declare function createDefaultIntrospectorStrategy(): IntrospectorStrategy;
36
+ declare namespace index_d_exports {
37
+ export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy };
38
+ }
39
+ //#endregion
40
+ export { IntrospectorStrategy as n, createDefaultIntrospectorStrategy as r, index_d_exports as t };
41
+ //# sourceMappingURL=index-a1Y--85Y.d.ts.map
@@ -0,0 +1,86 @@
1
+ import { t as Dialect } from "./Dialect-Cp4r7UfW.js";
2
+ import { t as CompilerStrategy } from "./CompilerStrategy-DqmcqAC-.js";
3
+
4
+ //#region src/runner/MigrationRunner.d.ts
5
+ /** DB client contract required by migration execution. */
6
+ interface DBClient {
7
+ /** Execute SQL with optional parameters. */
8
+ query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{
9
+ rows: T[];
10
+ }>;
11
+ /** Release underlying database resources. */
12
+ close(): Promise<void>;
13
+ }
14
+ /**
15
+ * Manages the lifecycle of database migrations: applying, planning, and tracking status.
16
+ *
17
+ * The runner reads migration files from a directory, compiles operations to SQL
18
+ * for the target dialect, and maintains a journal table to track which migrations
19
+ * have been applied. Each applied migration is checksummed to detect tampering.
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * const runner = new MigrationRunner(client, 'postgres', './migrations');
24
+ *
25
+ * // Apply all pending migrations
26
+ * await runner.apply();
27
+ *
28
+ * // Apply up to a specific migration
29
+ * await runner.apply('003_add_indexes');
30
+ *
31
+ * // Preview the SQL that would be generated
32
+ * const sql = await runner.plan();
33
+ *
34
+ * // Check which migrations are applied
35
+ * const statuses = await runner.status();
36
+ * ```
37
+ */
38
+ declare class MigrationRunner {
39
+ private client;
40
+ private dialect;
41
+ private migrationsDir;
42
+ static readonly BRAND: "tango.migrations.runner";
43
+ readonly __tangoBrand: typeof MigrationRunner.BRAND;
44
+ private compilerStrategy;
45
+ constructor(client: DBClient, dialect: Dialect, migrationsDir?: string, compilerStrategy?: CompilerStrategy);
46
+ /**
47
+ * Narrow an unknown value to `MigrationRunner`.
48
+ */
49
+ static isMigrationRunner(value: unknown): value is MigrationRunner;
50
+ /**
51
+ * Apply all pending migrations, optionally stopping at a specific migration ID.
52
+ * Migrations are applied in file-sort order. Already-applied migrations are skipped.
53
+ * Non-online migrations are wrapped in a transaction on Postgres.
54
+ */
55
+ apply(toId?: string): Promise<void>;
56
+ /**
57
+ * Generate a dry-run SQL plan for all migrations without executing anything.
58
+ * Useful for reviewing what SQL would be run before applying.
59
+ */
60
+ plan(): Promise<string>;
61
+ /**
62
+ * Return the applied/pending status of every migration found on disk.
63
+ */
64
+ status(): Promise<{
65
+ id: string;
66
+ applied: boolean;
67
+ }[]>;
68
+ private ensureJournal;
69
+ private listApplied;
70
+ private loadMigrations;
71
+ private applyMigration;
72
+ /**
73
+ * Compute a simple hash of the migration's operation list.
74
+ * Stored alongside each applied migration in the journal table to detect
75
+ * if a migration file has been modified after it was already applied.
76
+ * Uses a djb2-like hash over the JSON-serialized operations.
77
+ */
78
+ private hashJSON;
79
+ private compileOperation;
80
+ }
81
+ declare namespace index_d_exports {
82
+ export { MigrationRunner };
83
+ }
84
+ //#endregion
85
+ export { MigrationRunner as n, index_d_exports as t };
86
+ //# sourceMappingURL=index-ni7Db8Lv.d.ts.map
@@ -0,0 +1,61 @@
1
+ import { a as DbTable$1, c as DatabaseIntrospector, i as DbSchema$1, n as DbForeignKey, o as PostgresIntrospector, r as DbIndex, s as DBClient, t as DbColumn$1 } from "./PostgresIntrospector-DQDTZUW_.js";
2
+
3
+ //#region src/introspect/SqliteIntrospector.d.ts
4
+ /** Introspected column metadata. */
5
+ interface DbColumn {
6
+ name: string;
7
+ type: string;
8
+ notNull: boolean;
9
+ default: string | null;
10
+ isPk: boolean;
11
+ isUnique: boolean;
12
+ }
13
+ /** Introspected table metadata. */
14
+ interface DbTable {
15
+ name: string;
16
+ columns: Record<string, DbColumn>;
17
+ pks: string[];
18
+ indexes: Record<string, {
19
+ name: string;
20
+ table: string;
21
+ unique: boolean;
22
+ columns: string[];
23
+ where: string | null;
24
+ }>;
25
+ fks: Record<string, {
26
+ name: string;
27
+ table: string;
28
+ columns: string[];
29
+ refTable: string;
30
+ refColumns: string[];
31
+ onDelete: string | null;
32
+ onUpdate: string | null;
33
+ validated: boolean;
34
+ }>;
35
+ }
36
+ /** Introspected schema metadata. */
37
+ interface DbSchema {
38
+ tables: Record<string, DbTable>;
39
+ }
40
+ /**
41
+ * SQLite implementation of schema introspection.
42
+ */
43
+ declare class SqliteIntrospector implements DatabaseIntrospector {
44
+ static readonly BRAND: "tango.migrations.sqlite_introspector";
45
+ readonly __tangoBrand: typeof SqliteIntrospector.BRAND;
46
+ private readonly sqlSafety;
47
+ /**
48
+ * Narrow an unknown value to the SQLite schema introspector.
49
+ */
50
+ static isSqliteIntrospector(value: unknown): value is SqliteIntrospector;
51
+ /**
52
+ * Read table/column/index metadata from SQLite pragmas.
53
+ */
54
+ introspect(client: DBClient): Promise<DbSchema>;
55
+ }
56
+ declare namespace index_d_exports {
57
+ export { DBClient, DatabaseIntrospector, DbColumn$1 as PostgresDbColumn, DbForeignKey as PostgresDbForeignKey, DbIndex as PostgresDbIndex, DbSchema$1 as PostgresDbSchema, DbTable$1 as PostgresDbTable, PostgresIntrospector, DbColumn as SqliteDbColumn, DbSchema as SqliteDbSchema, DbTable as SqliteDbTable, SqliteIntrospector };
58
+ }
59
+ //#endregion
60
+ export { SqliteIntrospector as a, DbTable as i, DbColumn as n, DbSchema as r, index_d_exports as t };
61
+ //# sourceMappingURL=index-sywIP4pt.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,27 +1,17 @@
1
- export { trustedSql } from '@danceroutine/tango-core';
2
- export type { TrustedSqlFragment } from '@danceroutine/tango-core';
3
- /**
4
- * Bundled exports for Django-style domain drill-down imports, plus curated
5
- * top-level symbols for TS-native ergonomic imports.
6
- */
7
- export * as domain from './domain/index';
8
- export * as builder from './builder/index';
9
- export * as runner from './runner/index';
10
- export * as generator from './generator/index';
11
- export * as diff from './diff/index';
12
- export * as compilers from './compilers/index';
13
- export * as introspect from './introspect/index';
14
- export * as strategies from './strategies/index';
15
- export * as commands from './commands/index';
16
- export { Migration } from './domain/index';
17
- export type { Dialect, MigrationMode, MigrationOperation } from './domain/index';
18
- export type { Builder, ColumnSpec, ColumnType, DeleteReferentialAction, UpdateReferentialAction, } from './builder/index';
19
- export { CollectingBuilder, OpBuilder, op, applyFieldType } from './builder/index';
20
- export { MigrationRunner } from './runner/index';
21
- export { MigrationGenerator, type GenerateMigrationOptions } from './generator/index';
22
- export { diffSchema } from './diff/index';
23
- export { PostgresCompiler, SqliteCompiler } from './compilers/index';
24
- export type { CompilerFactory, SQL, SQLCompiler } from './compilers/index';
25
- export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy, } from './strategies/index';
26
- export { registerMigrationsCommands } from './commands/index';
27
- export { PostgresIntrospector, SqliteIntrospector, type DatabaseIntrospector, type DBClient, type PostgresDbColumn, type PostgresDbForeignKey, type PostgresDbIndex, type PostgresDbSchema, type PostgresDbTable, type SqliteDbColumn, type SqliteDbSchema, type SqliteDbTable, } from './introspect/index';
1
+ import { n as MigrationMode, t as Builder } from "./Builder-y8vj7XXN.js";
2
+ import { _ as ColumnType, d as MigrationOperation, g as DeleteReferentialAction, h as UpdateReferentialAction, m as ColumnSpec } from "./MigrationOperation-qpdhPEs9.js";
3
+ import { a as OpBuilder, o as applyFieldType, r as CollectingBuilder, t as index_d_exports } from "./index-CzpjLzoS.js";
4
+ import { n as registerMigrationsCommands, t as index_d_exports$1 } from "./index-D7qe9iKG.js";
5
+ import { n as SQLCompiler, r as SQL, t as CompilerFactory } from "./CompilerFactory-Czv-zEOS.js";
6
+ import { o as SqliteCompiler, s as PostgresCompiler, t as index_d_exports$2 } from "./index-CsTGwtZ0.js";
7
+ import { a as DbTable, c as DatabaseIntrospector, i as DbSchema, n as DbForeignKey, o as PostgresIntrospector, r as DbIndex, s as DBClient, t as DbColumn } from "./PostgresIntrospector-DQDTZUW_.js";
8
+ import { r as diffSchema, t as index_d_exports$3 } from "./index-CzdR_Ig9.js";
9
+ import { t as Dialect } from "./Dialect-Cp4r7UfW.js";
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";
12
+ import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "./CompilerStrategy-DqmcqAC-.js";
13
+ import { n as MigrationRunner, t as index_d_exports$7 } from "./index-ni7Db8Lv.js";
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";
15
+ import { n as IntrospectorStrategy, r as createDefaultIntrospectorStrategy, t as index_d_exports$8 } from "./index-a1Y--85Y.js";
16
+ import { TrustedSqlFragment, trustedSql } from "@danceroutine/tango-core";
17
+ export { type Builder, CollectingBuilder, type ColumnSpec, type ColumnType, type CompilerFactory, CompilerStrategy, type DBClient, type DatabaseIntrospector, type DeleteReferentialAction, type Dialect, type GenerateMigrationOptions, IntrospectorStrategy, Migration, MigrationGenerator, type MigrationMode, type MigrationOperation, MigrationRunner, OpBuilder, OpBuilder as op, PostgresCompiler, type DbColumn as PostgresDbColumn, type DbForeignKey as PostgresDbForeignKey, type DbIndex as PostgresDbIndex, type DbSchema as PostgresDbSchema, type DbTable as PostgresDbTable, PostgresIntrospector, type SQL, type SQLCompiler, SqliteCompiler, type DbColumn$1 as SqliteDbColumn, type DbSchema$1 as SqliteDbSchema, type DbTable$1 as SqliteDbTable, SqliteIntrospector, type TrustedSqlFragment, type UpdateReferentialAction, applyFieldType, index_d_exports as builder, index_d_exports$1 as commands, index_d_exports$2 as compilers, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy, index_d_exports$3 as diff, diffSchema, index_d_exports$4 as domain, index_d_exports$5 as generator, index_d_exports$6 as introspect, registerMigrationsCommands, index_d_exports$7 as runner, index_d_exports$8 as strategies, trustedSql };
package/dist/index.js CHANGED
@@ -1,24 +1,20 @@
1
- import { CollectingBuilder } from "./CollectingBuilder--4fqDQdE.js";
2
- import { Migration } from "./Migration-DYQ0hUG7.js";
3
- import "./InternalOperationKind-Bt6Weuon.js";
4
- import "./InternalColumnType-G9zV9StN.js";
5
- import "./MigrationSqlSafetyAdapter-CGRbB2k2.js";
6
- import { PostgresCompiler, SqliteCompiler } from "./SqliteCompilerFactory-BvdJ0kBl.js";
7
- import { CompilerStrategy, createDefaultCompilerStrategy } from "./CompilerStrategy-_AiXiyjS.js";
8
- import { MigrationRunner } from "./MigrationRunner-DomrOZIn.js";
9
- import { MigrationGenerator } from "./MigrationGenerator-B1p0jHnx.js";
10
- import { OpBuilder, applyFieldType, builder_exports } from "./builder-xJ-Bq2pk.js";
11
- import { diffSchema, diff_exports } from "./diff-B9MhagJF.js";
12
- import { PostgresIntrospector, SqliteIntrospector } from "./SqliteIntrospector-CWwPWhmA.js";
13
- import { IntrospectorStrategy, createDefaultIntrospectorStrategy } from "./IntrospectorStrategy-BEIG5GqA.js";
14
- import { registerMigrationsCommands } from "./cli-7j3R1Y1r.js";
15
- import { domain_exports } from "./domain-CwR-kUNS.js";
16
- import { runner_exports } from "./runner-C97xT8_W.js";
17
- import { generator_exports } from "./generator-DK-_f-PF.js";
18
- import { compilers_exports } from "./compilers-C-GiumJB.js";
19
- import { introspect_exports } from "./introspect-DD3fm15e.js";
20
- import { strategies_exports } from "./strategies-HwUWvmLC.js";
21
- import { commands_exports } from "./commands-Cl2MU7tq.js";
1
+ import { t as Migration } from "./Migration-DxHHPyzn.js";
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";
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";
8
+ import { t as runner_exports } from "./runner/index.js";
9
+ import { t as MigrationGenerator } from "./MigrationGenerator-BmmerPXJ.js";
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";
13
+ import { n as PostgresIntrospector, t as SqliteIntrospector } from "./SqliteIntrospector-CfItmGgA.js";
14
+ import { t as introspect_exports } from "./introspect/index.js";
15
+ import { n as createDefaultIntrospectorStrategy, t as IntrospectorStrategy } from "./IntrospectorStrategy-BijuyIaN.js";
16
+ import { t as strategies_exports } from "./strategies/index.js";
17
+ import { t as registerMigrationsCommands } from "./cli-e8I1-dab.js";
18
+ import { t as commands_exports } from "./commands/index.js";
22
19
  import { trustedSql } from "@danceroutine/tango-core";
23
-
24
- export { CollectingBuilder, CompilerStrategy, IntrospectorStrategy, Migration, MigrationGenerator, MigrationRunner, OpBuilder, 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, OpBuilder as op, registerMigrationsCommands, runner_exports as runner, strategies_exports as strategies, trustedSql };
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,6 +1,3 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export type { DBClient, DatabaseIntrospector } from './DatabaseIntrospector';
5
- export { PostgresIntrospector, type DbColumn as PostgresDbColumn, type DbForeignKey as PostgresDbForeignKey, type DbIndex as PostgresDbIndex, type DbSchema as PostgresDbSchema, type DbTable as PostgresDbTable, } from './PostgresIntrospector';
6
- export { SqliteIntrospector, type DbColumn as SqliteDbColumn, type DbSchema as SqliteDbSchema, type DbTable as SqliteDbTable, } from './SqliteIntrospector';
1
+ import { a as DbTable, c as DatabaseIntrospector, i as DbSchema, n as DbForeignKey, o as PostgresIntrospector, r as DbIndex, s as DBClient, t as DbColumn } from "../PostgresIntrospector-DQDTZUW_.js";
2
+ import { a as SqliteIntrospector, i as DbTable$1, n as DbColumn$1, r as DbSchema$1 } from "../index-sywIP4pt.js";
3
+ export { type DBClient, type DatabaseIntrospector, type DbColumn as PostgresDbColumn, type DbForeignKey as PostgresDbForeignKey, type DbIndex as PostgresDbIndex, type DbSchema as PostgresDbSchema, type DbTable as PostgresDbTable, PostgresIntrospector, type DbColumn$1 as SqliteDbColumn, type DbSchema$1 as SqliteDbSchema, type DbTable$1 as SqliteDbTable, SqliteIntrospector };
@@ -1,5 +1,11 @@
1
- import "../MigrationSqlSafetyAdapter-CGRbB2k2.js";
2
- import { PostgresIntrospector, SqliteIntrospector } from "../SqliteIntrospector-CWwPWhmA.js";
3
- import "../introspect-DD3fm15e.js";
1
+ import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
+ import { n as PostgresIntrospector, t as SqliteIntrospector } from "../SqliteIntrospector-CfItmGgA.js";
3
+ //#region src/introspect/index.ts
4
+ var introspect_exports = /* @__PURE__ */ __exportAll({
5
+ PostgresIntrospector: () => PostgresIntrospector,
6
+ SqliteIntrospector: () => SqliteIntrospector
7
+ });
8
+ //#endregion
9
+ export { PostgresIntrospector, SqliteIntrospector, introspect_exports as t };
4
10
 
5
- export { PostgresIntrospector, SqliteIntrospector };
11
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/introspect/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport type { DBClient, DatabaseIntrospector } from './DatabaseIntrospector';\nexport {\n PostgresIntrospector,\n type DbColumn as PostgresDbColumn,\n type DbForeignKey as PostgresDbForeignKey,\n type DbIndex as PostgresDbIndex,\n type DbSchema as PostgresDbSchema,\n type DbTable as PostgresDbTable,\n} from './PostgresIntrospector';\nexport {\n SqliteIntrospector,\n type DbColumn as SqliteDbColumn,\n type DbSchema as SqliteDbSchema,\n type DbTable as SqliteDbTable,\n} from './SqliteIntrospector';\n"],"mappings":""}
@@ -1,4 +1,2 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { MigrationRunner } from './MigrationRunner';
1
+ import { n as MigrationRunner } from "../index-ni7Db8Lv.js";
2
+ export { MigrationRunner };
@@ -1,11 +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 } from "../MigrationRunner-DomrOZIn.js";
9
- import "../runner-C97xT8_W.js";
1
+ import { t as __exportAll } from "../chunk-D7D4PA-g.js";
2
+ import { t as MigrationRunner } from "../MigrationRunner-B5AJel12.js";
3
+ //#region src/runner/index.ts
4
+ var runner_exports = /* @__PURE__ */ __exportAll({ MigrationRunner: () => MigrationRunner });
5
+ //#endregion
6
+ export { MigrationRunner, runner_exports as t };
10
7
 
11
- export { MigrationRunner };
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/runner/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { MigrationRunner } from './MigrationRunner';\n"],"mappings":""}
@@ -1,5 +1,3 @@
1
- /**
2
- * Domain boundary barrel: centralizes this subdomain's public contract.
3
- */
4
- export { CompilerStrategy, createDefaultCompilerStrategy } from './CompilerStrategy';
5
- export { IntrospectorStrategy, createDefaultIntrospectorStrategy } from './IntrospectorStrategy';
1
+ import { n as createDefaultCompilerStrategy, t as CompilerStrategy } from "../CompilerStrategy-DqmcqAC-.js";
2
+ import { n as IntrospectorStrategy, r as createDefaultIntrospectorStrategy } from "../index-a1Y--85Y.js";
3
+ export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy };
@@ -1,10 +1,14 @@
1
- import "../InternalOperationKind-Bt6Weuon.js";
2
- import "../InternalColumnType-G9zV9StN.js";
3
- import "../MigrationSqlSafetyAdapter-CGRbB2k2.js";
4
- import "../SqliteCompilerFactory-BvdJ0kBl.js";
5
- import { CompilerStrategy, createDefaultCompilerStrategy } from "../CompilerStrategy-_AiXiyjS.js";
6
- import "../SqliteIntrospector-CWwPWhmA.js";
7
- import { IntrospectorStrategy, createDefaultIntrospectorStrategy } from "../IntrospectorStrategy-BEIG5GqA.js";
8
- import "../strategies-HwUWvmLC.js";
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";
4
+ //#region src/strategies/index.ts
5
+ var strategies_exports = /* @__PURE__ */ __exportAll({
6
+ CompilerStrategy: () => CompilerStrategy,
7
+ IntrospectorStrategy: () => IntrospectorStrategy,
8
+ createDefaultCompilerStrategy: () => createDefaultCompilerStrategy,
9
+ createDefaultIntrospectorStrategy: () => createDefaultIntrospectorStrategy
10
+ });
11
+ //#endregion
12
+ export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy, strategies_exports as t };
9
13
 
10
- export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy };
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":[],"sources":["../../src/strategies/index.ts"],"sourcesContent":["/**\n * Domain boundary barrel: centralizes this subdomain's public contract.\n */\n\nexport { CompilerStrategy, createDefaultCompilerStrategy } from './CompilerStrategy';\nexport { IntrospectorStrategy, createDefaultIntrospectorStrategy } from './IntrospectorStrategy';\n"],"mappings":""}