Skip to content

Commit 5b6b2d8

Browse files
authored
Merge pull request #187 from thesamiroli/fail-on-sync-error
Fail synchronization if any error occurs while running sql scripts
2 parents f351d6b + e9d137f commit 5b6b2d8

File tree

4 files changed

+13
-11
lines changed

4 files changed

+13
-11
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@leapfrogtechnology/sync-db",
33
"description": "Command line utility to synchronize and version control relational database objects across databases",
4-
"version": "1.1.0",
4+
"version": "1.1.1",
55
"license": "MIT",
66
"main": "lib/index.js",
77
"types": "lib/index.d.ts",

src/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ export async function resolveConnections(config: Configuration, resolver?: strin
119119
} else if (resolver || config.connectionResolver) {
120120
connections = await resolveConnectionsUsingResolver(resolver || config.connectionResolver, config);
121121
} else {
122-
log('Connections file not provided.');
122+
log('Connections file not provided. Loading connection details from env.');
123123

124124
connections = resolveConnectionsFromEnv();
125125
}

src/service/sync.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ async function setup(trx: Knex.Transaction, context: SynchronizeContext): Promis
4141
log('PRE-SYNC: End');
4242
}
4343

44-
// Run the migration scripts.
44+
// Run the synchronization scripts.
4545
await sqlRunner.runSequentially(trx, sqlScripts, connectionId);
4646

4747
if (postMigrationScripts.length > 0) {

src/util/promise.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,17 @@ export async function runSequentially<T>(promisers: Promiser<T>[]): Promise<T[]>
2525

2626
result.push(value);
2727
} catch (err) {
28-
const errors = err as any;
29-
30-
if (errors.originalError) {
31-
result.push(errors.originalError);
32-
} else if (errors.error) {
33-
result.push(errors.error);
34-
} else {
35-
throw err;
28+
const error = err as any;
29+
30+
if (error.error) {
31+
throw error.error;
32+
}
33+
34+
if (error.originalError) {
35+
throw error.originalError;
3636
}
37+
38+
throw error;
3739
}
3840
}
3941

0 commit comments

Comments
 (0)