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 25573f2
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
Expand Up @@ -266,3 +266,4 @@ export { PgType } from './types';
export type { MigrationBuilder, RunnerOption } from './types';
export { PgLiteral, isPgLiteral } from './utils';
export type { PgLiteralValue } from './utils';
export { createMigrationBuilder } from './migrationBuilder';

Check failure on line 269 in src/index.ts

View workflow job for this annotation

GitHub Actions / Lint: node-20, ubuntu-latest

Delete `export·{·createMigrationBuilder·}·from·'./migrationBuilder';⏎`
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 25573f2

Please sign in to comment.