tempest-db-js 0.2.0 → 0.3.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/README.md +2 -2
- package/dist/bin.cjs +89 -30
- package/dist/bin.cjs.map +1 -1
- package/dist/bin.js +2 -2
- package/dist/{chunk-QMW4NKMH.js → chunk-OP7FRDI5.js} +199 -34
- package/dist/chunk-OP7FRDI5.js.map +1 -0
- package/dist/{chunk-AGDD7K3F.js → chunk-Q32CBI2A.js} +133 -16
- package/dist/chunk-Q32CBI2A.js.map +1 -0
- package/dist/index.cjs +131 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +28 -6
- package/dist/index.d.ts +28 -6
- package/dist/index.js +1 -1
- package/dist/migrations/index.cjs +196 -30
- package/dist/migrations/index.cjs.map +1 -1
- package/dist/migrations/index.d.cts +42 -5
- package/dist/migrations/index.d.ts +42 -5
- package/dist/migrations/index.js +2 -2
- package/package.json +1 -1
- package/dist/chunk-AGDD7K3F.js.map +0 -1
- package/dist/chunk-QMW4NKMH.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnType, DefaultValue, ModelClass, Dialect,
|
|
1
|
+
import { ColumnType, DefaultValue, ModelClass, Dialect, AsyncDriver, SyncDriver } from '../index.cjs';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* tempest-db-js — Phase 6: the Schema IR (intermediate representation).
|
|
@@ -106,11 +106,11 @@ declare function invert(op: Operation): Operation;
|
|
|
106
106
|
declare function invertAll(ops: readonly Operation[]): Operation[];
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* tempest-db-js — Phase 6: DDL rendering.
|
|
109
|
+
* tempest-db-js — Phase 6/9: DDL rendering.
|
|
110
110
|
*
|
|
111
111
|
* Renders the dialect-neutral IR + operations to concrete SQL per dialect. This
|
|
112
112
|
* is the ONLY place migration SQL is produced — the same operation yields the
|
|
113
|
-
* right DDL for SQLite or
|
|
113
|
+
* right DDL for SQLite, PostgreSQL or MySQL.
|
|
114
114
|
*/
|
|
115
115
|
|
|
116
116
|
/** Map a column type to its SQL type string for the dialect. */
|
|
@@ -126,7 +126,7 @@ declare function renderColumnDef(col: ColumnIR, dialect: Dialect): string;
|
|
|
126
126
|
* @param dialect The target dialect.
|
|
127
127
|
* @returns The SQL statements (usually one).
|
|
128
128
|
* @throws Error When the operation is unsupported on the dialect (e.g. SQLite
|
|
129
|
-
* `alter_column`, which needs the
|
|
129
|
+
* `alter_column`, which needs the table-rebuild path).
|
|
130
130
|
*/
|
|
131
131
|
declare function renderOperation(op: Operation, dialect: Dialect): string[];
|
|
132
132
|
|
|
@@ -280,6 +280,43 @@ declare class MigrationRunner {
|
|
|
280
280
|
*/
|
|
281
281
|
downgrade(migrations: readonly Migration[], steps?: number): string[];
|
|
282
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Runs migrations against an **async** driver (PostgreSQL, or any async driver),
|
|
285
|
+
* tracking applied revisions. Mirrors {@link MigrationRunner} but every statement
|
|
286
|
+
* is awaited, and identifier quoting + placeholder style follow the dialect —
|
|
287
|
+
* so the version table and its bookkeeping are portable across SQLite/PG/MySQL.
|
|
288
|
+
*/
|
|
289
|
+
declare class AsyncMigrationRunner {
|
|
290
|
+
private readonly driver;
|
|
291
|
+
private readonly dialect;
|
|
292
|
+
private readonly vt;
|
|
293
|
+
constructor(driver: AsyncDriver, dialect: Dialect);
|
|
294
|
+
/** Create the version-tracking table if it does not exist. */
|
|
295
|
+
ensureVersionTable(): Promise<void>;
|
|
296
|
+
/** A portable "text" column type for the version table. */
|
|
297
|
+
private textType;
|
|
298
|
+
/** The set of applied revision ids. */
|
|
299
|
+
applied(): Promise<Set<string>>;
|
|
300
|
+
private runOps;
|
|
301
|
+
private record;
|
|
302
|
+
private forget;
|
|
303
|
+
/**
|
|
304
|
+
* Apply all pending migrations up to the head(s), in DAG order.
|
|
305
|
+
*
|
|
306
|
+
* @param migrations All known migrations.
|
|
307
|
+
* @param appliedAt Timestamp string to stamp on each applied revision.
|
|
308
|
+
* @returns The revision ids that were applied this run.
|
|
309
|
+
*/
|
|
310
|
+
upgrade(migrations: readonly Migration[], appliedAt: string): Promise<string[]>;
|
|
311
|
+
/**
|
|
312
|
+
* Revert the last `steps` applied migrations (default 1), newest first.
|
|
313
|
+
*
|
|
314
|
+
* @param migrations All known migrations.
|
|
315
|
+
* @param steps How many applied revisions to roll back.
|
|
316
|
+
* @returns The revision ids that were reverted.
|
|
317
|
+
*/
|
|
318
|
+
downgrade(migrations: readonly Migration[], steps?: number): Promise<string[]>;
|
|
319
|
+
}
|
|
283
320
|
|
|
284
321
|
/**
|
|
285
322
|
* tempest-db-js — Phase 6d: SQLite introspection + drift detection.
|
|
@@ -462,4 +499,4 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
|
|
|
462
499
|
*/
|
|
463
500
|
declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult;
|
|
464
501
|
|
|
465
|
-
export { type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
502
|
+
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ColumnType, DefaultValue, ModelClass, Dialect,
|
|
1
|
+
import { ColumnType, DefaultValue, ModelClass, Dialect, AsyncDriver, SyncDriver } from '../index.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* tempest-db-js — Phase 6: the Schema IR (intermediate representation).
|
|
@@ -106,11 +106,11 @@ declare function invert(op: Operation): Operation;
|
|
|
106
106
|
declare function invertAll(ops: readonly Operation[]): Operation[];
|
|
107
107
|
|
|
108
108
|
/**
|
|
109
|
-
* tempest-db-js — Phase 6: DDL rendering.
|
|
109
|
+
* tempest-db-js — Phase 6/9: DDL rendering.
|
|
110
110
|
*
|
|
111
111
|
* Renders the dialect-neutral IR + operations to concrete SQL per dialect. This
|
|
112
112
|
* is the ONLY place migration SQL is produced — the same operation yields the
|
|
113
|
-
* right DDL for SQLite or
|
|
113
|
+
* right DDL for SQLite, PostgreSQL or MySQL.
|
|
114
114
|
*/
|
|
115
115
|
|
|
116
116
|
/** Map a column type to its SQL type string for the dialect. */
|
|
@@ -126,7 +126,7 @@ declare function renderColumnDef(col: ColumnIR, dialect: Dialect): string;
|
|
|
126
126
|
* @param dialect The target dialect.
|
|
127
127
|
* @returns The SQL statements (usually one).
|
|
128
128
|
* @throws Error When the operation is unsupported on the dialect (e.g. SQLite
|
|
129
|
-
* `alter_column`, which needs the
|
|
129
|
+
* `alter_column`, which needs the table-rebuild path).
|
|
130
130
|
*/
|
|
131
131
|
declare function renderOperation(op: Operation, dialect: Dialect): string[];
|
|
132
132
|
|
|
@@ -280,6 +280,43 @@ declare class MigrationRunner {
|
|
|
280
280
|
*/
|
|
281
281
|
downgrade(migrations: readonly Migration[], steps?: number): string[];
|
|
282
282
|
}
|
|
283
|
+
/**
|
|
284
|
+
* Runs migrations against an **async** driver (PostgreSQL, or any async driver),
|
|
285
|
+
* tracking applied revisions. Mirrors {@link MigrationRunner} but every statement
|
|
286
|
+
* is awaited, and identifier quoting + placeholder style follow the dialect —
|
|
287
|
+
* so the version table and its bookkeeping are portable across SQLite/PG/MySQL.
|
|
288
|
+
*/
|
|
289
|
+
declare class AsyncMigrationRunner {
|
|
290
|
+
private readonly driver;
|
|
291
|
+
private readonly dialect;
|
|
292
|
+
private readonly vt;
|
|
293
|
+
constructor(driver: AsyncDriver, dialect: Dialect);
|
|
294
|
+
/** Create the version-tracking table if it does not exist. */
|
|
295
|
+
ensureVersionTable(): Promise<void>;
|
|
296
|
+
/** A portable "text" column type for the version table. */
|
|
297
|
+
private textType;
|
|
298
|
+
/** The set of applied revision ids. */
|
|
299
|
+
applied(): Promise<Set<string>>;
|
|
300
|
+
private runOps;
|
|
301
|
+
private record;
|
|
302
|
+
private forget;
|
|
303
|
+
/**
|
|
304
|
+
* Apply all pending migrations up to the head(s), in DAG order.
|
|
305
|
+
*
|
|
306
|
+
* @param migrations All known migrations.
|
|
307
|
+
* @param appliedAt Timestamp string to stamp on each applied revision.
|
|
308
|
+
* @returns The revision ids that were applied this run.
|
|
309
|
+
*/
|
|
310
|
+
upgrade(migrations: readonly Migration[], appliedAt: string): Promise<string[]>;
|
|
311
|
+
/**
|
|
312
|
+
* Revert the last `steps` applied migrations (default 1), newest first.
|
|
313
|
+
*
|
|
314
|
+
* @param migrations All known migrations.
|
|
315
|
+
* @param steps How many applied revisions to roll back.
|
|
316
|
+
* @returns The revision ids that were reverted.
|
|
317
|
+
*/
|
|
318
|
+
downgrade(migrations: readonly Migration[], steps?: number): Promise<string[]>;
|
|
319
|
+
}
|
|
283
320
|
|
|
284
321
|
/**
|
|
285
322
|
* tempest-db-js — Phase 6d: SQLite introspection + drift detection.
|
|
@@ -462,4 +499,4 @@ declare function defineMigrationConfig(config: CliConfig): CliConfig;
|
|
|
462
499
|
*/
|
|
463
500
|
declare function runMigrationCli(argv: readonly string[], config: CliConfig): CliResult;
|
|
464
501
|
|
|
465
|
-
export { type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
|
502
|
+
export { AsyncMigrationRunner, type CliConfig, type CliResult, type ColumnIR, CyclicMigrationGraph, type DefaultIR, IrreversibleMigration, type Migration, type MigrationDraft, MigrationRunner, Op, type Operation, type RenameCandidate, type RevisionNode, type SchemaIR, type SqliteAffinity, type TableIR, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder };
|
package/dist/migrations/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { CyclicMigrationGraph, IrreversibleMigration, MigrationRunner, Op, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
1
|
+
export { AsyncMigrationRunner, CyclicMigrationGraph, IrreversibleMigration, MigrationRunner, Op, UnknownRevision, applyOperation, applyRenames, checkDrift, checkDriftPostgres, defineMigrationConfig, detectRenames, diffSchema, emptySchema, generateMigration, heads, introspectPostgres, introspectSqlite, invert, invertAll, makeRevisionId, reflectSchema, reflectTable, renderColumnDef, renderColumnType, renderDefault, renderOperation, replaySchema, runMigrationCli, sqliteAffinity, topoOrder } from '../chunk-OP7FRDI5.js';
|
|
2
|
+
import '../chunk-Q32CBI2A.js';
|
|
3
3
|
//# sourceMappingURL=index.js.map
|
|
4
4
|
//# sourceMappingURL=index.js.map
|