Skip to content

Commit

Permalink
feat: expose createMigrationBuilder to allow using this lib as sql bu…
Browse files Browse the repository at this point in the history
…ilder
  • Loading branch information
wenerme committed Oct 10, 2024
1 parent 2b14645 commit 9df3929
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export { Migration } from './migration';
export { createMigrationBuilder } from './migrationBuilder';
export type {
CreateCast,
CreateCastFn,
Expand Down
26 changes: 26 additions & 0 deletions src/migrationBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -531,3 +531,29 @@ export default class MigrationBuilderImpl implements MigrationBuilder {
return this._REVERSE_MODE ? [...this._steps].reverse() : this._steps;
}
}

export function createMigrationBuilder({
db,
typeShorthands,
shouldDecamelize,
logger,
}: {
db?: DB;
typeShorthands: ColumnDefinitions | undefined;
shouldDecamelize: boolean;
logger: Logger;
}): MigrationBuilderImpl {
return new MigrationBuilderImpl(
db || {
select: () => {
throw new Error('Not implemented');
},
query: () => {
throw new Error('Not implemented');
},
},
typeShorthands,
shouldDecamelize,
logger
);
}

0 comments on commit 9df3929

Please sign in to comment.