postgres-schema-migrations 6.0.1 → 6.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgres-schema-migrations",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Stack Overflow style database migrations for PostgreSQL",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -5,6 +5,7 @@ const sql_template_strings_1 = require("sql-template-strings");
5
5
  const noop = () => {
6
6
  //
7
7
  };
8
+ const asyncNoop = () => Promise.resolve();
8
9
  const insertMigration = async (migrationTableName, client, migration, log) => {
9
10
  log(`Saving migration to '${migrationTableName}': ${migration.id} | ${migration.name} | ${migration.hash}`);
10
11
  const sql = sql_template_strings_1.default `INSERT INTO `
@@ -16,14 +17,18 @@ const runMigration = (migrationTableName, client, log = noop) => async (migratio
16
17
  const inTransaction = migration.sql.includes("-- postgres-migrations disable-transaction") ===
17
18
  false;
18
19
  log(`Running migration in transaction: ${inTransaction}`);
19
- const begin = inTransaction ? () => client.query("START TRANSACTION") : noop;
20
- const end = inTransaction ? () => client.query("COMMIT") : noop;
21
- const cleanup = inTransaction ? () => client.query("ROLLBACK") : noop;
20
+ const begin = inTransaction
21
+ ? () => client.query("START TRANSACTION")
22
+ : asyncNoop;
23
+ const end = inTransaction ? () => client.query("COMMIT") : asyncNoop;
24
+ const cleanup = inTransaction ? () => client.query("ROLLBACK") : asyncNoop;
22
25
  try {
23
26
  await begin();
24
27
  await client.query(migration.sql);
28
+ log("Ran migration " + migration.fileName);
25
29
  await insertMigration(migrationTableName, client, migration, log);
26
- await end();
30
+ log("inserted migration in migrations table" + migrationTableName);
31
+ end();
27
32
  return migration;
28
33
  }
29
34
  catch (err) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "postgres-schema-migrations",
3
- "version": "6.0.1",
3
+ "version": "6.0.3",
4
4
  "description": "Stack Overflow style database migrations for PostgreSQL",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",