Skip to content

Commit 4467198

Browse files
committed
Use transaction and getConfig methods in migrator
1 parent fd7f447 commit 4467198

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/migrator.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,30 +19,30 @@ export function setup(config: SyncConfig): (connection: Connection) => Promise<v
1919
return async (connection: Connection) => {
2020
const logDb = dbLogger(connection);
2121

22-
logDb(`Running setup on connection id: ${connection.config.id}`);
22+
logDb(`Running setup on connection id: ${connection.getConfig().id}`);
2323

2424
const sqlScripts = await sqlRunner.resolveFiles(basePath, sql);
2525
const { pre_sync: preMigrationScripts, post_sync: postMigrationScripts } = hooks;
2626

27-
await connection.instance.transaction(async trx => {
27+
await connection.transaction(async t => {
2828
if (preMigrationScripts.length > 0) {
2929
const preHookScripts = await sqlRunner.resolveFiles(basePath, preMigrationScripts);
3030

3131
logDb('PRE-SYNC: Begin');
3232
// Run the pre hook scripts
33-
await sqlRunner.runSequentially(preHookScripts, connection);
33+
await sqlRunner.runSequentially(preHookScripts, t);
3434
logDb('PRE-SYNC: End');
3535
}
3636

3737
// Run the migration scripts.
38-
await sqlRunner.runSequentially(sqlScripts, connection);
38+
await sqlRunner.runSequentially(sqlScripts, t);
3939

4040
if (postMigrationScripts.length > 0) {
4141
const postHookScripts = await sqlRunner.resolveFiles(basePath, postMigrationScripts);
4242

4343
logDb('POST-SYNC: Begin');
4444
// Run the pre hook scripts
45-
await sqlRunner.runSequentially(postHookScripts, connection);
45+
await sqlRunner.runSequentially(postHookScripts, t);
4646
logDb('POST-SYNC: End');
4747
}
4848

@@ -65,7 +65,7 @@ export function teardown(config: SyncConfig): (connection: Connection) => Promis
6565
return async (connection: Connection) => {
6666
const logDb = dbLogger(connection);
6767

68-
logDb(`Running rollback on connection id: ${connection.config.id}`);
68+
logDb(`Running rollback on connection id: ${connection.getConfig().id}`);
6969

7070
const fileInfoList = sql.map(filePath => sqlRunner.extractSqlFileInfo(filePath.replace(`${basePath}/`, '')));
7171

0 commit comments

Comments
 (0)