@danceroutine/tango-migrations 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/CollectingBuilder-C6qnwyrb.js +28 -0
- package/dist/CollectingBuilder-C6qnwyrb.js.map +1 -0
- package/dist/CompilerStrategy-Cv1woBmO.js +55 -0
- package/dist/CompilerStrategy-Cv1woBmO.js.map +1 -0
- package/dist/InternalColumnType-_YAz7RqI.js +17 -0
- package/dist/InternalColumnType-_YAz7RqI.js.map +1 -0
- package/dist/InternalOperationKind-BPVoOQwD.js +20 -0
- package/dist/InternalOperationKind-BPVoOQwD.js.map +1 -0
- package/dist/IntrospectorStrategy-BM1Eizfc.js +38 -0
- package/dist/IntrospectorStrategy-BM1Eizfc.js.map +1 -0
- package/dist/Migration-D9J6ZbLP.js +25 -0
- package/dist/Migration-D9J6ZbLP.js.map +1 -0
- package/dist/MigrationGenerator-Z39LTKmC.js +199 -0
- package/dist/MigrationGenerator-Z39LTKmC.js.map +1 -0
- package/dist/MigrationRunner-CCFuPUlr.js +144 -0
- package/dist/MigrationRunner-CCFuPUlr.js.map +1 -0
- package/dist/SqliteCompilerFactory-DwMwO7xY.js +303 -0
- package/dist/SqliteCompilerFactory-DwMwO7xY.js.map +1 -0
- package/dist/SqliteIntrospector-BRdNt6KG.js +121 -0
- package/dist/SqliteIntrospector-BRdNt6KG.js.map +1 -0
- package/dist/builder/contracts/Builder.d.ts +11 -0
- package/dist/builder/contracts/ColumnSpec.d.ts +19 -0
- package/dist/builder/contracts/ColumnType.d.ts +2 -0
- package/dist/builder/contracts/DeleteReferentialAction.d.ts +2 -0
- package/dist/builder/contracts/UpdateReferentialAction.d.ts +2 -0
- package/dist/builder/contracts/index.d.ts +8 -0
- package/dist/builder/index.d.ts +10 -0
- package/dist/builder/index.js +6 -0
- package/dist/builder/ops/OpBuilder.d.ts +88 -0
- package/dist/builder/ops/OpBuilder.js +173 -0
- package/dist/builder/ops/index.d.ts +4 -0
- package/dist/builder/runtime/CollectingBuilder.d.ts +21 -0
- package/dist/builder/runtime/index.d.ts +4 -0
- package/dist/builder-Dtk8oP_Y.js +236 -0
- package/dist/builder-Dtk8oP_Y.js.map +1 -0
- package/dist/chunk-BkvOhyD0.js +12 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.js +178 -0
- package/dist/cli.js.map +1 -0
- package/dist/compilers/contracts/CompilerFactory.d.ts +4 -0
- package/dist/compilers/contracts/SQL.d.ts +4 -0
- package/dist/compilers/contracts/SQLCompiler.d.ts +5 -0
- package/dist/compilers/contracts/index.d.ts +6 -0
- package/dist/compilers/dialects/PostgresCompiler.d.ts +17 -0
- package/dist/compilers/dialects/SqliteCompiler.d.ts +10 -0
- package/dist/compilers/dialects/index.d.ts +5 -0
- package/dist/compilers/factories/PostgresCompilerFactory.d.ts +8 -0
- package/dist/compilers/factories/SqliteCompilerFactory.d.ts +8 -0
- package/dist/compilers/factories/index.d.ts +5 -0
- package/dist/compilers/index.d.ts +10 -0
- package/dist/compilers/index.js +6 -0
- package/dist/compilers-D8DJuTnQ.js +38 -0
- package/dist/compilers-D8DJuTnQ.js.map +1 -0
- package/dist/diff/diffSchema.d.ts +33 -0
- package/dist/diff/index.d.ts +4 -0
- package/dist/diff/index.js +8 -0
- package/dist/diff-Cs0TPEGR.js +10 -0
- package/dist/diff-Cs0TPEGR.js.map +1 -0
- package/dist/diffSchema-KgGHP-s3.js +86 -0
- package/dist/diffSchema-KgGHP-s3.js.map +1 -0
- package/dist/domain/Dialect.d.ts +2 -0
- package/dist/domain/Migration.d.ts +12 -0
- package/dist/domain/MigrationMode.d.ts +2 -0
- package/dist/domain/MigrationOperation.d.ts +76 -0
- package/dist/domain/MigrationOperation.js +1 -0
- package/dist/domain/index.d.ts +7 -0
- package/dist/domain/index.js +4 -0
- package/dist/domain/internal/InternalColumnType.d.ts +10 -0
- package/dist/domain/internal/InternalDialect.d.ts +4 -0
- package/dist/domain/internal/InternalMigrationMode.d.ts +4 -0
- package/dist/domain/internal/InternalOperationKind.d.ts +13 -0
- package/dist/domain/internal/InternalReferentialAction.d.ts +6 -0
- package/dist/domain-BXVlG0C0.js +10 -0
- package/dist/domain-BXVlG0C0.js.map +1 -0
- package/dist/generator/MigrationGenerator.d.ts +35 -0
- package/dist/generator/index.d.ts +4 -0
- package/dist/generator/index.js +5 -0
- package/dist/generator-3yC60b1u.js +10 -0
- package/dist/generator-3yC60b1u.js.map +1 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +21 -0
- package/dist/introspect/DatabaseIntrospector.d.ts +9 -0
- package/dist/introspect/PostgresIntrospector.d.ts +42 -0
- package/dist/introspect/SqliteIntrospector.d.ts +40 -0
- package/dist/introspect/index.d.ts +6 -0
- package/dist/introspect/index.js +4 -0
- package/dist/introspect-ks-QSodq.js +13 -0
- package/dist/introspect-ks-QSodq.js.map +1 -0
- package/dist/runner/MigrationRunner.d.ts +73 -0
- package/dist/runner/index.d.ts +4 -0
- package/dist/runner/index.js +10 -0
- package/dist/runner-BOs-tItW.js +10 -0
- package/dist/runner-BOs-tItW.js.map +1 -0
- package/dist/strategies/CompilerStrategy.d.ts +20 -0
- package/dist/strategies/IntrospectorStrategy.d.ts +19 -0
- package/dist/strategies/index.d.ts +5 -0
- package/dist/strategies/index.js +9 -0
- package/dist/strategies-BvHwf4as.js +16 -0
- package/dist/strategies-BvHwf4as.js.map +1 -0
- package/package.json +101 -0
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Domain boundary barrel: centralizes this subdomain's public contract.
|
|
3
|
+
*/
|
|
4
|
+
export type { Dialect } from './Dialect';
|
|
5
|
+
export { Migration } from './Migration';
|
|
6
|
+
export type { MigrationMode } from './MigrationMode';
|
|
7
|
+
export type { MigrationOperation } from './MigrationOperation';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare enum InternalOperationKind {
|
|
2
|
+
TABLE_CREATE = "table.create",
|
|
3
|
+
TABLE_DROP = "table.drop",
|
|
4
|
+
COLUMN_ADD = "column.add",
|
|
5
|
+
COLUMN_DROP = "column.drop",
|
|
6
|
+
COLUMN_ALTER = "column.alter",
|
|
7
|
+
COLUMN_RENAME = "column.rename",
|
|
8
|
+
INDEX_CREATE = "index.create",
|
|
9
|
+
INDEX_DROP = "index.drop",
|
|
10
|
+
FK_CREATE = "fk.create",
|
|
11
|
+
FK_VALIDATE = "fk.validate",
|
|
12
|
+
FK_DROP = "fk.drop"
|
|
13
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
import { Migration } from "./Migration-D9J6ZbLP.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-BXVlG0C0.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"domain-BXVlG0C0.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":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { MigrationOperation } from '../domain/MigrationOperation';
|
|
2
|
+
export interface GenerateMigrationOptions {
|
|
3
|
+
name: string;
|
|
4
|
+
operations: MigrationOperation[];
|
|
5
|
+
directory: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class MigrationGenerator {
|
|
8
|
+
static readonly BRAND: "tango.migrations.generator";
|
|
9
|
+
readonly __tangoBrand: typeof MigrationGenerator.BRAND;
|
|
10
|
+
static isMigrationGenerator(value: unknown): value is MigrationGenerator;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a migration file and write it to disk.
|
|
13
|
+
* Returns the file path of the created migration.
|
|
14
|
+
*/
|
|
15
|
+
generate(options: GenerateMigrationOptions): Promise<string>;
|
|
16
|
+
/**
|
|
17
|
+
* Render migration operations to a TypeScript source string without writing to disk.
|
|
18
|
+
*/
|
|
19
|
+
render(id: string, operations: MigrationOperation[]): string;
|
|
20
|
+
private renderClassName;
|
|
21
|
+
private renderOperation;
|
|
22
|
+
private renderReverseOperation;
|
|
23
|
+
private renderTableCreate;
|
|
24
|
+
private renderTableDrop;
|
|
25
|
+
private renderColumnAdd;
|
|
26
|
+
private renderColumnDrop;
|
|
27
|
+
private renderColumnAlter;
|
|
28
|
+
private renderColumnRename;
|
|
29
|
+
private renderIndexCreate;
|
|
30
|
+
private renderIndexDrop;
|
|
31
|
+
private renderForeignKeyCreate;
|
|
32
|
+
private renderForeignKeyDrop;
|
|
33
|
+
private renderColumnChain;
|
|
34
|
+
private timestamp;
|
|
35
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
import { MigrationGenerator } from "./MigrationGenerator-Z39LTKmC.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-3yC60b1u.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator-3yC60b1u.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":""}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bundled exports for Django-style domain drill-down imports, plus curated
|
|
3
|
+
* top-level symbols for TS-native ergonomic imports.
|
|
4
|
+
*/
|
|
5
|
+
export * as domain from './domain/index';
|
|
6
|
+
export * as builder from './builder/index';
|
|
7
|
+
export * as runner from './runner/index';
|
|
8
|
+
export * as generator from './generator/index';
|
|
9
|
+
export * as diff from './diff/index';
|
|
10
|
+
export * as compilers from './compilers/index';
|
|
11
|
+
export * as introspect from './introspect/index';
|
|
12
|
+
export * as strategies from './strategies/index';
|
|
13
|
+
export { Migration } from './domain/index';
|
|
14
|
+
export type { Dialect, MigrationMode, MigrationOperation } from './domain/index';
|
|
15
|
+
export type { Builder, ColumnSpec, ColumnType, DeleteReferentialAction, UpdateReferentialAction, } from './builder/index';
|
|
16
|
+
export { CollectingBuilder, OpBuilder, op, applyFieldType } from './builder/index';
|
|
17
|
+
export { MigrationRunner } from './runner/index';
|
|
18
|
+
export { MigrationGenerator, type GenerateMigrationOptions } from './generator/index';
|
|
19
|
+
export { diffSchema } from './diff/index';
|
|
20
|
+
export { PostgresCompiler, SqliteCompiler } from './compilers/index';
|
|
21
|
+
export type { CompilerFactory, SQL, SQLCompiler } from './compilers/index';
|
|
22
|
+
export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy, } from './strategies/index';
|
|
23
|
+
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';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { CollectingBuilder } from "./CollectingBuilder-C6qnwyrb.js";
|
|
2
|
+
import { Migration } from "./Migration-D9J6ZbLP.js";
|
|
3
|
+
import "./InternalOperationKind-BPVoOQwD.js";
|
|
4
|
+
import "./InternalColumnType-_YAz7RqI.js";
|
|
5
|
+
import { PostgresCompiler, SqliteCompiler } from "./SqliteCompilerFactory-DwMwO7xY.js";
|
|
6
|
+
import { CompilerStrategy, createDefaultCompilerStrategy } from "./CompilerStrategy-Cv1woBmO.js";
|
|
7
|
+
import { MigrationRunner } from "./MigrationRunner-CCFuPUlr.js";
|
|
8
|
+
import { MigrationGenerator } from "./MigrationGenerator-Z39LTKmC.js";
|
|
9
|
+
import { OpBuilder, applyFieldType, builder_exports } from "./builder-Dtk8oP_Y.js";
|
|
10
|
+
import { diffSchema } from "./diffSchema-KgGHP-s3.js";
|
|
11
|
+
import { PostgresIntrospector, SqliteIntrospector } from "./SqliteIntrospector-BRdNt6KG.js";
|
|
12
|
+
import { IntrospectorStrategy, createDefaultIntrospectorStrategy } from "./IntrospectorStrategy-BM1Eizfc.js";
|
|
13
|
+
import { domain_exports } from "./domain-BXVlG0C0.js";
|
|
14
|
+
import { runner_exports } from "./runner-BOs-tItW.js";
|
|
15
|
+
import { generator_exports } from "./generator-3yC60b1u.js";
|
|
16
|
+
import { diff_exports } from "./diff-Cs0TPEGR.js";
|
|
17
|
+
import { compilers_exports } from "./compilers-D8DJuTnQ.js";
|
|
18
|
+
import { introspect_exports } from "./introspect-ks-QSodq.js";
|
|
19
|
+
import { strategies_exports } from "./strategies-BvHwf4as.js";
|
|
20
|
+
|
|
21
|
+
export { CollectingBuilder, CompilerStrategy, IntrospectorStrategy, Migration, MigrationGenerator, MigrationRunner, OpBuilder, PostgresCompiler, PostgresIntrospector, SqliteCompiler, SqliteIntrospector, applyFieldType, builder_exports as builder, 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, runner_exports as runner, strategies_exports as strategies };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { DbSchema } from './PostgresIntrospector';
|
|
2
|
+
export interface DBClient {
|
|
3
|
+
query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{
|
|
4
|
+
rows: T[];
|
|
5
|
+
}>;
|
|
6
|
+
}
|
|
7
|
+
export interface DatabaseIntrospector {
|
|
8
|
+
introspect(client: DBClient): Promise<DbSchema>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { DBClient, DatabaseIntrospector } from './DatabaseIntrospector';
|
|
2
|
+
export interface DbColumn {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
notNull: boolean;
|
|
6
|
+
default: string | null;
|
|
7
|
+
isPk: boolean;
|
|
8
|
+
isUnique: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DbIndex {
|
|
11
|
+
name: string;
|
|
12
|
+
table: string;
|
|
13
|
+
unique: boolean;
|
|
14
|
+
columns: string[];
|
|
15
|
+
where: string | null;
|
|
16
|
+
}
|
|
17
|
+
export interface DbForeignKey {
|
|
18
|
+
name: string;
|
|
19
|
+
table: string;
|
|
20
|
+
columns: string[];
|
|
21
|
+
refTable: string;
|
|
22
|
+
refColumns: string[];
|
|
23
|
+
onDelete: string | null;
|
|
24
|
+
onUpdate: string | null;
|
|
25
|
+
validated: boolean;
|
|
26
|
+
}
|
|
27
|
+
export interface DbTable {
|
|
28
|
+
name: string;
|
|
29
|
+
columns: Record<string, DbColumn>;
|
|
30
|
+
pks: string[];
|
|
31
|
+
indexes: Record<string, DbIndex>;
|
|
32
|
+
fks: Record<string, DbForeignKey>;
|
|
33
|
+
}
|
|
34
|
+
export interface DbSchema {
|
|
35
|
+
tables: Record<string, DbTable>;
|
|
36
|
+
}
|
|
37
|
+
export declare class PostgresIntrospector implements DatabaseIntrospector {
|
|
38
|
+
static readonly BRAND: "tango.migrations.postgres_introspector";
|
|
39
|
+
readonly __tangoBrand: typeof PostgresIntrospector.BRAND;
|
|
40
|
+
static isPostgresIntrospector(value: unknown): value is PostgresIntrospector;
|
|
41
|
+
introspect(client: DBClient): Promise<DbSchema>;
|
|
42
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { DBClient, DatabaseIntrospector } from './DatabaseIntrospector';
|
|
2
|
+
export interface DbColumn {
|
|
3
|
+
name: string;
|
|
4
|
+
type: string;
|
|
5
|
+
notNull: boolean;
|
|
6
|
+
default: string | null;
|
|
7
|
+
isPk: boolean;
|
|
8
|
+
isUnique: boolean;
|
|
9
|
+
}
|
|
10
|
+
export interface DbTable {
|
|
11
|
+
name: string;
|
|
12
|
+
columns: Record<string, DbColumn>;
|
|
13
|
+
pks: string[];
|
|
14
|
+
indexes: Record<string, {
|
|
15
|
+
name: string;
|
|
16
|
+
table: string;
|
|
17
|
+
unique: boolean;
|
|
18
|
+
columns: string[];
|
|
19
|
+
where: string | null;
|
|
20
|
+
}>;
|
|
21
|
+
fks: Record<string, {
|
|
22
|
+
name: string;
|
|
23
|
+
table: string;
|
|
24
|
+
columns: string[];
|
|
25
|
+
refTable: string;
|
|
26
|
+
refColumns: string[];
|
|
27
|
+
onDelete: string | null;
|
|
28
|
+
onUpdate: string | null;
|
|
29
|
+
validated: boolean;
|
|
30
|
+
}>;
|
|
31
|
+
}
|
|
32
|
+
export interface DbSchema {
|
|
33
|
+
tables: Record<string, DbTable>;
|
|
34
|
+
}
|
|
35
|
+
export declare class SqliteIntrospector implements DatabaseIntrospector {
|
|
36
|
+
static readonly BRAND: "tango.migrations.sqlite_introspector";
|
|
37
|
+
readonly __tangoBrand: typeof SqliteIntrospector.BRAND;
|
|
38
|
+
static isSqliteIntrospector(value: unknown): value is SqliteIntrospector;
|
|
39
|
+
introspect(client: DBClient): Promise<DbSchema>;
|
|
40
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
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';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
import { PostgresIntrospector, SqliteIntrospector } from "./SqliteIntrospector-BRdNt6KG.js";
|
|
3
|
+
|
|
4
|
+
//#region src/introspect/index.ts
|
|
5
|
+
var introspect_exports = {};
|
|
6
|
+
__export(introspect_exports, {
|
|
7
|
+
PostgresIntrospector: () => PostgresIntrospector,
|
|
8
|
+
SqliteIntrospector: () => SqliteIntrospector
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
//#endregion
|
|
12
|
+
export { introspect_exports };
|
|
13
|
+
//# sourceMappingURL=introspect-ks-QSodq.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"introspect-ks-QSodq.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":""}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import type { Dialect } from '../domain/Dialect';
|
|
2
|
+
import type { CompilerStrategy } from '../strategies/CompilerStrategy';
|
|
3
|
+
interface DBClient {
|
|
4
|
+
query<T = unknown>(sql: string, params?: readonly unknown[]): Promise<{
|
|
5
|
+
rows: T[];
|
|
6
|
+
}>;
|
|
7
|
+
close(): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Manages the lifecycle of database migrations: applying, planning, and tracking status.
|
|
11
|
+
*
|
|
12
|
+
* The runner reads migration files from a directory, compiles operations to SQL
|
|
13
|
+
* for the target dialect, and maintains a journal table to track which migrations
|
|
14
|
+
* have been applied. Each applied migration is checksummed to detect tampering.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const runner = new MigrationRunner(client, 'postgres', './migrations');
|
|
19
|
+
*
|
|
20
|
+
* // Apply all pending migrations
|
|
21
|
+
* await runner.apply();
|
|
22
|
+
*
|
|
23
|
+
* // Apply up to a specific migration
|
|
24
|
+
* await runner.apply('003_add_indexes');
|
|
25
|
+
*
|
|
26
|
+
* // Preview the SQL that would be generated
|
|
27
|
+
* const sql = await runner.plan();
|
|
28
|
+
*
|
|
29
|
+
* // Check which migrations are applied
|
|
30
|
+
* const statuses = await runner.status();
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export declare class MigrationRunner {
|
|
34
|
+
private client;
|
|
35
|
+
private dialect;
|
|
36
|
+
private migrationsDir;
|
|
37
|
+
static readonly BRAND: "tango.migrations.runner";
|
|
38
|
+
private compilerStrategy;
|
|
39
|
+
readonly __tangoBrand: typeof MigrationRunner.BRAND;
|
|
40
|
+
constructor(client: DBClient, dialect: Dialect, migrationsDir?: string, compilerStrategy?: CompilerStrategy);
|
|
41
|
+
static isMigrationRunner(value: unknown): value is MigrationRunner;
|
|
42
|
+
/**
|
|
43
|
+
* Apply all pending migrations, optionally stopping at a specific migration ID.
|
|
44
|
+
* Migrations are applied in file-sort order. Already-applied migrations are skipped.
|
|
45
|
+
* Non-online migrations are wrapped in a transaction on Postgres.
|
|
46
|
+
*/
|
|
47
|
+
apply(toId?: string): Promise<void>;
|
|
48
|
+
/**
|
|
49
|
+
* Generate a dry-run SQL plan for all migrations without executing anything.
|
|
50
|
+
* Useful for reviewing what SQL would be run before applying.
|
|
51
|
+
*/
|
|
52
|
+
plan(): Promise<string>;
|
|
53
|
+
/**
|
|
54
|
+
* Return the applied/pending status of every migration found on disk.
|
|
55
|
+
*/
|
|
56
|
+
status(): Promise<{
|
|
57
|
+
id: string;
|
|
58
|
+
applied: boolean;
|
|
59
|
+
}[]>;
|
|
60
|
+
private ensureJournal;
|
|
61
|
+
private listApplied;
|
|
62
|
+
private loadMigrations;
|
|
63
|
+
private applyMigration;
|
|
64
|
+
/**
|
|
65
|
+
* Compute a simple hash of the migration's operation list.
|
|
66
|
+
* Stored alongside each applied migration in the journal table to detect
|
|
67
|
+
* if a migration file has been modified after it was already applied.
|
|
68
|
+
* Uses a djb2-like hash over the JSON-serialized operations.
|
|
69
|
+
*/
|
|
70
|
+
private hashJSON;
|
|
71
|
+
private compileOperation;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import "../CollectingBuilder-C6qnwyrb.js";
|
|
2
|
+
import "../Migration-D9J6ZbLP.js";
|
|
3
|
+
import "../InternalOperationKind-BPVoOQwD.js";
|
|
4
|
+
import "../InternalColumnType-_YAz7RqI.js";
|
|
5
|
+
import "../SqliteCompilerFactory-DwMwO7xY.js";
|
|
6
|
+
import "../CompilerStrategy-Cv1woBmO.js";
|
|
7
|
+
import { MigrationRunner } from "../MigrationRunner-CCFuPUlr.js";
|
|
8
|
+
import "../runner-BOs-tItW.js";
|
|
9
|
+
|
|
10
|
+
export { MigrationRunner };
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
import { MigrationRunner } from "./MigrationRunner-CCFuPUlr.js";
|
|
3
|
+
|
|
4
|
+
//#region src/runner/index.ts
|
|
5
|
+
var runner_exports = {};
|
|
6
|
+
__export(runner_exports, { MigrationRunner: () => MigrationRunner });
|
|
7
|
+
|
|
8
|
+
//#endregion
|
|
9
|
+
export { runner_exports };
|
|
10
|
+
//# sourceMappingURL=runner-BOs-tItW.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner-BOs-tItW.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":""}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { CompilerFactory } from '../compilers/contracts/CompilerFactory';
|
|
2
|
+
import type { Dialect } from '../domain/Dialect';
|
|
3
|
+
import type { CustomMigrationOperation, MigrationOperation } from '../domain/MigrationOperation';
|
|
4
|
+
import type { SQL } from '../compilers/contracts/SQL';
|
|
5
|
+
import type { SQLCompiler } from '../compilers/contracts/SQLCompiler';
|
|
6
|
+
type CompilerFactoryRegistry = Record<Dialect, CompilerFactory>;
|
|
7
|
+
export declare class CompilerStrategy {
|
|
8
|
+
private readonly factories;
|
|
9
|
+
static readonly BRAND: "tango.migrations.compiler_strategy";
|
|
10
|
+
private readonly compilerCache;
|
|
11
|
+
private readonly customHandlers;
|
|
12
|
+
readonly __tangoBrand: typeof CompilerStrategy.BRAND;
|
|
13
|
+
constructor(factories: CompilerFactoryRegistry);
|
|
14
|
+
static isCompilerStrategy(value: unknown): value is CompilerStrategy;
|
|
15
|
+
compile(dialect: Dialect, operation: MigrationOperation): SQL[];
|
|
16
|
+
registerCustomHandler<TName extends string, TArgs extends object>(name: TName, handler: (dialect: Dialect, op: CustomMigrationOperation<TName, TArgs>) => SQL[]): this;
|
|
17
|
+
getCompiler(dialect: Dialect): SQLCompiler;
|
|
18
|
+
}
|
|
19
|
+
export declare function createDefaultCompilerStrategy(): CompilerStrategy;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { DBClient, DatabaseIntrospector } from '../introspect/DatabaseIntrospector';
|
|
2
|
+
import type { Dialect } from '../domain/Dialect';
|
|
3
|
+
import type { DbSchema } from '../introspect/PostgresIntrospector';
|
|
4
|
+
type IntrospectorFactory = {
|
|
5
|
+
create(): DatabaseIntrospector;
|
|
6
|
+
};
|
|
7
|
+
type IntrospectorFactoryRegistry = Record<Dialect, IntrospectorFactory>;
|
|
8
|
+
export declare class IntrospectorStrategy {
|
|
9
|
+
private readonly factories;
|
|
10
|
+
static readonly BRAND: "tango.migrations.introspector_strategy";
|
|
11
|
+
private readonly introspectorCache;
|
|
12
|
+
readonly __tangoBrand: typeof IntrospectorStrategy.BRAND;
|
|
13
|
+
constructor(factories: IntrospectorFactoryRegistry);
|
|
14
|
+
static isIntrospectorStrategy(value: unknown): value is IntrospectorStrategy;
|
|
15
|
+
introspect(dialect: Dialect, client: DBClient): Promise<DbSchema>;
|
|
16
|
+
getIntrospector(dialect: Dialect): DatabaseIntrospector;
|
|
17
|
+
}
|
|
18
|
+
export declare function createDefaultIntrospectorStrategy(): IntrospectorStrategy;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import "../InternalOperationKind-BPVoOQwD.js";
|
|
2
|
+
import "../InternalColumnType-_YAz7RqI.js";
|
|
3
|
+
import "../SqliteCompilerFactory-DwMwO7xY.js";
|
|
4
|
+
import { CompilerStrategy, createDefaultCompilerStrategy } from "../CompilerStrategy-Cv1woBmO.js";
|
|
5
|
+
import "../SqliteIntrospector-BRdNt6KG.js";
|
|
6
|
+
import { IntrospectorStrategy, createDefaultIntrospectorStrategy } from "../IntrospectorStrategy-BM1Eizfc.js";
|
|
7
|
+
import "../strategies-BvHwf4as.js";
|
|
8
|
+
|
|
9
|
+
export { CompilerStrategy, IntrospectorStrategy, createDefaultCompilerStrategy, createDefaultIntrospectorStrategy };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { __export } from "./chunk-BkvOhyD0.js";
|
|
2
|
+
import { CompilerStrategy, createDefaultCompilerStrategy } from "./CompilerStrategy-Cv1woBmO.js";
|
|
3
|
+
import { IntrospectorStrategy, createDefaultIntrospectorStrategy } from "./IntrospectorStrategy-BM1Eizfc.js";
|
|
4
|
+
|
|
5
|
+
//#region src/strategies/index.ts
|
|
6
|
+
var strategies_exports = {};
|
|
7
|
+
__export(strategies_exports, {
|
|
8
|
+
CompilerStrategy: () => CompilerStrategy,
|
|
9
|
+
IntrospectorStrategy: () => IntrospectorStrategy,
|
|
10
|
+
createDefaultCompilerStrategy: () => createDefaultCompilerStrategy,
|
|
11
|
+
createDefaultIntrospectorStrategy: () => createDefaultIntrospectorStrategy
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
export { strategies_exports };
|
|
16
|
+
//# sourceMappingURL=strategies-BvHwf4as.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"strategies-BvHwf4as.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":""}
|
package/package.json
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@danceroutine/tango-migrations",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Auto-migration system with ops DSL for Tango",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"bin": {
|
|
9
|
+
"tango": "./dist/cli.js"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js"
|
|
15
|
+
},
|
|
16
|
+
"./compilers": {
|
|
17
|
+
"types": "./dist/index.d.ts",
|
|
18
|
+
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./strategies": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"import": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"./introspect": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./domain": {
|
|
29
|
+
"types": "./dist/index.d.ts",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./builder": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"import": "./dist/index.js"
|
|
35
|
+
},
|
|
36
|
+
"./runner": {
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"import": "./dist/index.js"
|
|
39
|
+
},
|
|
40
|
+
"./generator": {
|
|
41
|
+
"types": "./dist/index.d.ts",
|
|
42
|
+
"import": "./dist/index.js"
|
|
43
|
+
},
|
|
44
|
+
"./diff": {
|
|
45
|
+
"types": "./dist/index.d.ts",
|
|
46
|
+
"import": "./dist/index.js"
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
"files": [
|
|
50
|
+
"dist"
|
|
51
|
+
],
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsdown",
|
|
54
|
+
"test": "vitest run --coverage",
|
|
55
|
+
"test:integration": "vitest run src/tests/integration",
|
|
56
|
+
"test:watch": "vitest",
|
|
57
|
+
"typecheck": "tsc --noEmit"
|
|
58
|
+
},
|
|
59
|
+
"keywords": [
|
|
60
|
+
"tango",
|
|
61
|
+
"migrations",
|
|
62
|
+
"database",
|
|
63
|
+
"orm"
|
|
64
|
+
],
|
|
65
|
+
"author": "Pedro Del Moral Lopez",
|
|
66
|
+
"license": "MIT",
|
|
67
|
+
"repository": {
|
|
68
|
+
"type": "git",
|
|
69
|
+
"url": "https://github.com/danceroutine/tango.git",
|
|
70
|
+
"directory": "packages/migrations"
|
|
71
|
+
},
|
|
72
|
+
"dependencies": {
|
|
73
|
+
"@danceroutine/tango-schema": "workspace:*",
|
|
74
|
+
"kleur": "^4.1.5",
|
|
75
|
+
"yargs": "^17.7.2"
|
|
76
|
+
},
|
|
77
|
+
"peerDependencies": {
|
|
78
|
+
"pg": "^8.13.1",
|
|
79
|
+
"better-sqlite3": "^11.7.0"
|
|
80
|
+
},
|
|
81
|
+
"peerDependenciesMeta": {
|
|
82
|
+
"pg": {
|
|
83
|
+
"optional": true
|
|
84
|
+
},
|
|
85
|
+
"better-sqlite3": {
|
|
86
|
+
"optional": true
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"devDependencies": {
|
|
90
|
+
"@danceroutine/tango-testing": "workspace:*",
|
|
91
|
+
"@types/better-sqlite3": "^7.6.12",
|
|
92
|
+
"@types/node": "^22.9.0",
|
|
93
|
+
"@types/pg": "^8.11.10",
|
|
94
|
+
"@types/yargs": "^17.0.33",
|
|
95
|
+
"better-sqlite3": "^11.7.0",
|
|
96
|
+
"pg": "^8.13.1",
|
|
97
|
+
"tsdown": "^0.4.0",
|
|
98
|
+
"typescript": "^5.6.3",
|
|
99
|
+
"vitest": "^4.0.6"
|
|
100
|
+
}
|
|
101
|
+
}
|