File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,3 +8,13 @@ export interface MigrationRunner {
88 up ( ) : Promise < void > ;
99 down ( ) : Promise < void > ;
1010}
11+
12+ export interface DbConnectionConfig {
13+ connectionString : string ;
14+ }
15+
16+ export * from "./migrations" ;
17+ export * from "./providers/postgres" ;
18+ export * from "./providers/sqlite" ;
19+ export * from "./providers/supabase" ;
20+ export * from "./providers/mongodb" ;
Original file line number Diff line number Diff line change 1+ import type { MigrationRunner } from "../index" ;
2+
3+ export interface MigrationDefinition {
4+ id : string ;
5+ upSql : string ;
6+ downSql : string ;
7+ }
8+
9+ export class InMemoryMigrationRunner implements MigrationRunner {
10+ private readonly applied : string [ ] = [ ] ;
11+
12+ public constructor ( private readonly migrations : MigrationDefinition [ ] ) { }
13+
14+ public async up ( ) : Promise < void > {
15+ this . applied . splice ( 0 , this . applied . length , ...this . migrations . map ( ( item ) => item . id ) ) ;
16+ }
17+
18+ public async down ( ) : Promise < void > {
19+ this . applied . splice ( 0 , this . applied . length ) ;
20+ }
21+
22+ public listApplied ( ) : string [ ] {
23+ return [ ...this . applied ] ;
24+ }
25+ }
Original file line number Diff line number Diff line change 1+ import type { DbConnectionConfig , DbProvider } from "../index" ;
2+
3+ export class MongoDbProvider implements DbProvider {
4+ public readonly name = "mongodb" ;
5+
6+ public constructor ( private readonly config : DbConnectionConfig ) { }
7+
8+ public async connect ( ) : Promise < void > {
9+ void this . config . connectionString ;
10+ }
11+
12+ public async disconnect ( ) : Promise < void > {
13+ return Promise . resolve ( ) ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ import type { DbConnectionConfig , DbProvider } from "../index" ;
2+
3+ export class PostgresProvider implements DbProvider {
4+ public readonly name = "postgres" ;
5+
6+ public constructor ( private readonly config : DbConnectionConfig ) { }
7+
8+ public async connect ( ) : Promise < void > {
9+ void this . config . connectionString ;
10+ }
11+
12+ public async disconnect ( ) : Promise < void > {
13+ return Promise . resolve ( ) ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ import type { DbConnectionConfig , DbProvider } from "../index" ;
2+
3+ export class SqliteProvider implements DbProvider {
4+ public readonly name = "sqlite" ;
5+
6+ public constructor ( private readonly config : DbConnectionConfig ) { }
7+
8+ public async connect ( ) : Promise < void > {
9+ void this . config . connectionString ;
10+ }
11+
12+ public async disconnect ( ) : Promise < void > {
13+ return Promise . resolve ( ) ;
14+ }
15+ }
Original file line number Diff line number Diff line change 1+ import type { DbConnectionConfig , DbProvider } from "../index" ;
2+
3+ export class SupabaseProvider implements DbProvider {
4+ public readonly name = "supabase" ;
5+
6+ public constructor ( private readonly config : DbConnectionConfig ) { }
7+
8+ public async connect ( ) : Promise < void > {
9+ void this . config . connectionString ;
10+ }
11+
12+ public async disconnect ( ) : Promise < void > {
13+ return Promise . resolve ( ) ;
14+ }
15+ }
You can’t perform that action at this time.
0 commit comments