Repository: knex/knex
Pull request #4047 (2020-09-24 00:16:54)

Override knexfile options with CLI options
This PR allows overriding options in a passed knexfile with other options passed to the CLI.

kibertoad: There's a test failing, could you please take a look?
kibertoad: @KoryNunn Could you please also update documentation in https://github.com/knex/documentation?
kibertoad: @KoryNunn Do you need any help with this?
KoryNunn: Hi just a quick update. I no longer use knex, and as such have no capability for valuable input. I'll leave this PR open in case it is of use to anyone else, but also not against it being closed.
OlivierCavadenti: > Hi just a quick update. I no longer use knex, and as such have no capability for valuable input. I'll leave this PR open in case it is of use to anyone else, but also not against it being closed.

It's ok no problem at all, I will finish it ! 

Patch:
diff --git a/bin/cli.js b/bin/cli.js
index 60341860..c3e3268d 100755
--- a/bin/cli.js
+++ b/bin/cli.js
@@ -1,5 +1,6 @@
 #!/usr/bin/env node
 const rechoir = require('rechoir');
+const merge = require('lodash/merge');
 const interpret = require('interpret');
 const resolveFrom = require('resolve-from');
 const path = require('path');
@@ -9,6 +10,7 @@ const color = require('colorette');
 const argv = require('getopts')(process.argv.slice(2));
 const cliPkg = require('../package');
 const {
+  parseConfigObj,
   mkConfigObj,
   resolveEnvironmentConfig,
   exit,
@@ -59,8 +61,17 @@ async function initKnex(env, opts) {
     env.configuration,
     env.configPath
   );
+
+  const optionsConfig = parseConfigObj(opts);
+  const config = merge(resolvedConfig, optionsConfig);
+
+  // Migrations directory gets defaulted if it is undefined.
+  if (!env.configPath && !config.migrations.directory) {
+    config.migrations.directory = null;
+  }
+
   const knex = require(env.modulePath);
-  return knex(resolvedConfig);
+  return knex(config);
 }
 
 function invoke() {
@@ -138,16 +149,10 @@ function invoke() {
     .option('--knexfile [path]', 'Specify the knexfile path.')
     .option('--knexpath [path]', 'Specify the path to knex instance.')
     .option('--cwd [path]', 'Specify the working directory.')
-    .option('--client [name]', 'Set DB client without a knexfile.')
-    .option('--connection [address]', 'Set DB connection without a knexfile.')
-    .option(
-      '--migrations-directory [path]',
-      'Set migrations directory without a knexfile.'
-    )
-    .option(
-      '--migrations-table-name [path]',
-      'Set migrations table name without a knexfile.'
-    )
+    .option('--client [name]', 'Set DB client.')
+    .option('--connection [address]', 'Set DB connection.')
+    .option('--migrations-directory [path]', 'Set migrations directory.')
+    .option('--migrations-table-name [path]', 'Set migrations table name.')
     .option(
       '--env [name]',
       'environment, default: process.env.NODE_ENV || development'
diff --git a/bin/utils/cli-config-utils.js b/bin/utils/cli-config-utils.js
index d447ba8d..fb98ffcd 100644
--- a/bin/utils/cli-config-utils.js
+++ b/bin/utils/cli-config-utils.js
@@ -1,12 +1,39 @@
 const { DEFAULT_EXT, DEFAULT_TABLE_NAME } = require('./constants');
 const { resolveClientNameWithAliases } = require('../../lib/util/helpers');
-const fs = require('fs');
 const path = require('path');
 const escalade = require('escalade/sync');
 const tildify = require('tildify');
 const color = require('colorette');
 const argv = require('getopts')(process.argv.slice(2));
 
+function findCaseInsensitiveProperty(propertyName, object) {
+  return Object.keys(object).find(
+    (key) => key.toLowerCase() === propertyName.toLowerCase()
+  );
+}
+
+function parseConfigObj(opts) {
+  const config = { migrations: {} };
+
+  if (opts.client) {
+    config.client = opts.client;
+  }
+
+  if (opts.connection) {
+    config.connection = opts.connection;
+  }
+
+  if (opts.migrationsDirectory) {
+    config.migrations.directory = opts.migrationsDirectory;
+  }
+
+  if (opts.migrationsTableName) {
+    config.migrations.tableName = opts.migrationsTableName;
+  }
+
+  return config;
+}
+
 function mkConfigObj(opts) {
   if (!opts.client) {
     throw new Error(
@@ -17,16 +44,14 @@ function mkConfigObj(opts) {
   const envName = opts.env || process.env.NODE_ENV || 'development';
   const resolvedClientName = resolveClientNameWithAliases(opts.client);
   const useNullAsDefault = resolvedClientName === 'sqlite3';
+  const parsedConfig = parseConfigObj(opts);
+
   return {
     ext: DEFAULT_EXT,
     [envName]: {
+      ...parsedConfig,
       useNullAsDefault,
-      client: opts.client,
-      connection: opts.connection,
-      migrations: {
-        directory: opts.migrationsDirectory,
-        tableName: opts.migrationsTableName || DEFAULT_TABLE_NAME,
-      },
+      tableName: parsedConfig.tableName || DEFAULT_TABLE_NAME,
     },
   };
 }
@@ -174,6 +199,7 @@ function findUpConfig(cwd, name, extensions) {
 }
 
 module.exports = {
+  parseConfigObj,
   mkConfigObj,
   resolveEnvironmentConfig,
   exit,


Test patch:
diff --git a/test/cli/cli-test-utils.js b/test/cli/cli-test-utils.js
index 39b69b0b..b4533952 100644
--- a/test/cli/cli-test-utils.js
+++ b/test/cli/cli-test-utils.js
@@ -75,10 +75,20 @@ function setupFileHelper() {
   return fileHelper;
 }
 
+function createTable(db, ddl) {
+  return new Promise((resolve, reject) =>
+    db.exec(`create TABLE if not exists ${ddl};`, (err) => {
+      if (err) reject(err);
+      else resolve();
+    })
+  );
+}
+
 module.exports = {
   expectContentMatchesStub,
   getRootDir,
   migrationStubOptionSetup,
   seedStubOptionSetup,
   setupFileHelper,
+  createTable,
 };
diff --git a/test/cli/esm-interop.spec.js b/test/cli/esm-interop.spec.js
index f3b24800..3607f743 100644
--- a/test/cli/esm-interop.spec.js
+++ b/test/cli/esm-interop.spec.js
@@ -5,6 +5,7 @@ const fs = require('fs');
 const { execCommand } = require('cli-testlab');
 const sqlite3 = require('@vscode/sqlite3');
 const semver = require('semver');
+const { createTable } = require('./cli-test-utils');
 const KNEX = path.normalize(__dirname + '/../../bin/cli.js');
 const TEST_BASE = '../test/jake-util';
 
@@ -734,15 +735,6 @@ describe('esm interop and mjs support', () => {
   }
 });
 
-function createTable(db, ddl) {
-  return new Promise((resolve, reject) =>
-    db.exec(`create TABLE if not exists ${ddl};`, (err) => {
-      if (err) reject(err);
-      else resolve();
-    })
-  );
-}
-
 function getSchema(db) {
   return new Promise((resolve, reject) => {
     db.all('SELECT name from SQLITE_MASTER', (err, rows) => {
diff --git a/test/cli/migrate-make.spec.js b/test/cli/migrate-make.spec.js
index ae5a08bb..ce9032d0 100644
--- a/test/cli/migrate-make.spec.js
+++ b/test/cli/migrate-make.spec.js
@@ -124,7 +124,7 @@ module.exports = {
   migrations: {
     directory: __dirname + '/test/jake-util/knexfile_migrations',
   },
-};    
+};
     `,
         { isPathAbsolute: true }
       );
@@ -152,7 +152,7 @@ module.exports = {
   migrations: {
     directory: __dirname + '/test/jake-util/knexfile_migrations',
   },
-};    
+};
     `,
         { isPathAbsolute: true }
       );
@@ -187,7 +187,7 @@ module.exports = {
       directory: __dirname + '/test/jake-util/knexfile_migrations',
     }
   }
-};    
+};
     `,
         { isPathAbsolute: true }
       );
@@ -237,7 +237,7 @@ module.exports = {
     extension: 'ts',
     directory: __dirname + '/test/jake-util/knexfile_migrations',
   },
-};    
+};
     `,
         { isPathAbsolute: true }
       );
@@ -272,7 +272,7 @@ development: {
     directory: __dirname + '/test/jake-util/knexfile_migrations',
   },
   }
-};    
+};
     `,
         { isPathAbsolute: true }
       );
diff --git a/test/cli/migrate.spec.js b/test/cli/migrate.spec.js
index 435c1928..ecd060c3 100644
--- a/test/cli/migrate.spec.js
+++ b/test/cli/migrate.spec.js
@@ -56,4 +56,55 @@ describe('migrate:latest', () => {
     expect(row.name).to.equal('000_create_rule_table.js');
     db.close();
   });
+
+  it('CLI Options override knexfile', async () => {
+    const path = process.cwd() + '/knexfile.js';
+    fileHelper.createFile(
+      path,
+      `
+module.exports = {
+  client: 'sqlite3',
+  connection: {
+    filename: '${dbPath}',
+  },
+  migrations: {
+    directory: __dirname + '/test//jake-util/knexfile_migrations',
+  },
+};
+      `,
+      { isPathAbsolute: true }
+    );
+
+    fileHelper.createFile(
+      'migrations/subdirectory/000_create_rule_table.js',
+      `
+            exports.up = (knex)=> knex.schema.createTable('rules', (table)=> {
+                table.string('name');
+            });
+            exports.down = (knex)=> knex.schema.dropTable('rules');
+        `,
+      { willBeCleanedUp: true, isPathAbsolute: false }
+    );
+
+    expect(fileHelper.fileExists(dbPath)).to.equal(false);
+
+    await execCommand(`node ${KNEX} migrate:latest \
+                 --knexpath=../knexfile.js \
+                 --migrations-directory=${rootDir}/migrations/subdirectory/ \
+                 --migrations-table-name=migration_table \
+                 create_rule_table`);
+    expect(fileHelper.fileExists(dbPath)).to.equal(true);
+
+    const db = await new sqlite3.Database(dbPath);
+    const row = await new Promise((resolve, reject) => {
+      db.get('SELECT name FROM migration_table', {}, (err, row) => {
+        if (err) {
+          reject(err);
+        }
+        resolve(row);
+      });
+    });
+    expect(row.name).to.equal('000_create_rule_table.js');
+    db.close();
+  });
 });
diff --git a/test/integration2/query/insert/inserts.spec.js b/test/integration2/query/insert/inserts.spec.js
index d3c45186..476e7786 100644
--- a/test/integration2/query/insert/inserts.spec.js
+++ b/test/integration2/query/insert/inserts.spec.js
@@ -57,8 +57,8 @@ describe('Inserts', function () {
         await knex('test_table_two').truncate();
       });
 
-      it('should handle simple inserts', function () {
-        return knex('accounts')
+      it('should handle simple inserts', async function () {
+        await knex('accounts')
           .insert(
             {
               first_name: 'Test',
@@ -162,8 +162,8 @@ describe('Inserts', function () {
           });
       });
 
-      it('should handle multi inserts', function () {
-        return knex('accounts')
+      it('should handle multi inserts', async function () {
+        await knex('accounts')
           .insert(
             [
               {
@@ -380,8 +380,8 @@ describe('Inserts', function () {
           });
       });
 
-      it('should take hashes passed into insert and keep them in the correct order', function () {
-        return knex('accounts')
+      it('should take hashes passed into insert and keep them in the correct order', async function () {
+        await knex('accounts')
           .insert(
             [
               {
@@ -653,8 +653,8 @@ describe('Inserts', function () {
           );
       });
 
-      it('should drop any where clause bindings', function () {
-        return knex('accounts')
+      it('should drop any where clause bindings', async function () {
+        await knex('accounts')
           .where('id', '>', 1)
           .orWhere('x', 2)
           .insert(
@@ -760,8 +760,8 @@ describe('Inserts', function () {
           });
       });
 
-      it('should not allow inserting invalid values into enum fields', function () {
-        return knex('datatype_test')
+      it('should not allow inserting invalid values into enum fields', async function () {
+        await knex('datatype_test')
           .insert({ enum_value: 'd' })
           .testSql(function (tester) {
             tester(
@@ -810,8 +810,8 @@ describe('Inserts', function () {
           );
       });
 
-      it('should not allow invalid uuids in postgresql', function () {
-        return knex('datatype_test')
+      it('should not allow invalid uuids in postgresql', async function () {
+        await knex('datatype_test')
           .insert({
             enum_value: 'c',
             uuid: 'c39d8fcf-68a0-4902-b192-1ebb6310d9ad',
@@ -836,7 +836,7 @@ describe('Inserts', function () {
           );
       });
 
-      it('should not mutate the array passed in', function () {
+      it('should not mutate the array passed in', async function () {
         const a = {
           enum_value: 'a',
           uuid: '00419fc1-7eed-442c-9c01-cf757e74b8f0',
@@ -847,11 +847,8 @@ describe('Inserts', function () {
         };
         const x = [a, b];
 
-        return knex('datatype_test')
-          .insert(x)
-          .then(function () {
-            expect(x).to.eql([a, b]);
-          });
+        await knex('datatype_test').insert(x);
+        expect(x).to.eql([a, b]);
       });
 
       it('should throw an error if the array passed in is empty', async function () {
@@ -861,126 +858,120 @@ describe('Inserts', function () {
         );
       });
 
-      it('should handle empty inserts', function () {
-        return knex.schema
-          .createTable('test_default_table', function (qb) {
-            qb.increments().primary();
-            qb.string('string').defaultTo('hello');
-            qb.tinyint('tinyint').defaultTo(0);
-            qb.text('text').nullable();
-          })
-          .then(function () {
-            return knex('test_default_table')
-              .insert({}, 'id')
-              .testSql(function (tester) {
-                tester(
-                  'mysql',
-                  'insert into `test_default_table` () values ()',
-                  [],
-                  [1]
-                );
-                tester(
-                  'pg',
-                  'insert into "test_default_table" default values returning "id"',
-                  [],
-                  [{ id: 1 }]
-                );
-                tester(
-                  'pg-redshift',
-                  'insert into "test_default_table" default values',
-                  [],
-                  1
-                );
-                tester(
-                  'sqlite3',
-                  'insert into `test_default_table` default values',
-                  [],
-                  [1]
-                );
-                tester(
-                  'oracledb',
-                  'insert into "test_default_table" ("id") values (default) returning "id" into ?',
-                  [
-                    function (v) {
-                      return v.toString() === '[object ReturningHelper:id]';
-                    },
-                  ],
-                  [{ id: 1 }]
-                );
-                tester(
-                  'mssql',
-                  'insert into [test_default_table] output inserted.[id] default values',
-                  [],
-                  [{ id: 1 }]
-                );
-              });
+      it('should handle empty inserts', async function () {
+        await knex.schema.createTable('test_default_table', function (qb) {
+          qb.increments().primary();
+          qb.string('string').defaultTo('hello');
+          qb.tinyint('tinyint').defaultTo(0);
+          qb.text('text').nullable();
+        });
+        await knex('test_default_table')
+          .insert({}, 'id')
+          .testSql(function (tester) {
+            tester(
+              'mysql',
+              'insert into `test_default_table` () values ()',
+              [],
+              [1]
+            );
+            tester(
+              'pg',
+              'insert into "test_default_table" default values returning "id"',
+              [],
+              [{ id: 1 }]
+            );
+            tester(
+              'pg-redshift',
+              'insert into "test_default_table" default values',
+              [],
+              1
+            );
+            tester(
+              'sqlite3',
+              'insert into `test_default_table` default values',
+              [],
+              [1]
+            );
+            tester(
+              'oracledb',
+              'insert into "test_default_table" ("id") values (default) returning "id" into ?',
+              [
+                function (v) {
+                  return v.toString() === '[object ReturningHelper:id]';
+                },
+              ],
+              [{ id: 1 }]
+            );
+            tester(
+              'mssql',
+              'insert into [test_default_table] output inserted.[id] default values',
+              [],
+              [{ id: 1 }]
+            );
           });
       });
 
-      it('should handle empty arrays inserts', function () {
-        return knex.schema
-          .createTable('test_default_table2', function (qb) {
-            qb.increments().primary();
-            qb.string('string').defaultTo('hello');
-            qb.tinyint('tinyint').defaultTo(0);
-            qb.text('text').nullable();
-          })
-          .then(function () {
-            return knex('test_default_table2')
-              .insert([{}], 'id')
-              .testSql(function (tester) {
-                tester(
-                  'mysql',
-                  'insert into `test_default_table2` () values ()',
-                  [],
-                  [1]
-                );
-                tester(
-                  'pg',
-                  'insert into "test_default_table2" default values returning "id"',
-                  [],
-                  [{ id: 1 }]
-                );
-                tester(
-                  'pg-redshift',
-                  'insert into "test_default_table2" default values',
-                  [],
-                  1
-                );
-                tester(
-                  'sqlite3',
-                  'insert into `test_default_table2` default values',
-                  [],
-                  [1]
-                );
-                tester(
-                  'oracledb',
-                  'insert into "test_default_table2" ("id") values (default) returning "id" into ?',
-                  [
-                    function (v) {
-                      return v.toString() === '[object ReturningHelper:id]';
-                    },
-                  ],
-                  [{ id: 1 }]
-                );
-                tester(
-                  'mssql',
-                  'insert into [test_default_table2] output inserted.[id] default values',
-                  [],
-                  [{ id: 1 }]
-                );
-              });
+      it('should handle empty arrays inserts', async function () {
+        await knex.schema.createTable('test_default_table2', function (qb) {
+          qb.increments().primary();
+          qb.string('string').defaultTo('hello');
+          qb.tinyint('tinyint').defaultTo(0);
+          qb.text('text').nullable();
+        });
+        await knex('test_default_table2')
+          .insert([{}], 'id')
+          .testSql(function (tester) {
+            tester(
+              'mysql',
+              'insert into `test_default_table2` () values ()',
+              [],
+              [1]
+            );
+            tester(
+              'pg',
+              'insert into "test_default_table2" default values returning "id"',
+              [],
+              [{ id: 1 }]
+            );
+            tester(
+              'pg-redshift',
+              'insert into "test_default_table2" default values',
+              [],
+              1
+            );
+            tester(
+              'sqlite3',
+              'insert into `test_default_table2` default values',
+              [],
+              [1]
+            );
+            tester(
+              'oracledb',
+              'insert into "test_default_table2" ("id") values (default) returning "id" into ?',
+              [
+                function (v) {
+                  return v.toString() === '[object ReturningHelper:id]';
+                },
+              ],
+              [{ id: 1 }]
+            );
+            tester(
+              'mssql',
+              'insert into [test_default_table2] output inserted.[id] default values',
+              [],
+              [{ id: 1 }]
+            );
           });
       });
 
-      it('should take an array of columns to return in oracle or postgres', function () {
+      it('should take an array of columns to return in oracle or postgres', async function () {
         const insertData = {
           account_id: 10,
           details:
             'Lorem ipsum Minim nostrud Excepteur consectetur enim ut qui sint in veniam in nulla anim do cillum sunt voluptate Duis non incididunt.',
           status: 0,
         };
-        return knex('test_table_two')
+        const rows = await knex('test_table_two')
           .insert(insertData, ['account_id', 'details'])
           .testSql(function (tester) {
             tester(
@@ -1067,21 +1058,20 @@ describe('Inserts', function () {
                 },
               ]
             );
-          })
-          .then(function (rows) {
-            if (isRedshift(knex)) {
-              return expect(rows).to.equal(1);
-            }
-            expect(rows.length).to.equal(1);
-            if (isPostgreSQL(knex)) {
-              expect(_.keys(rows[0]).length).to.equal(2);
-              expect(rows[0].account_id).to.equal(insertData.account_id);
-              expect(rows[0].details).to.equal(insertData.details);
-            }
           });
+
+        if (isRedshift(knex)) {
+          return expect(rows).to.equal(1);
+        }
+        expect(rows.length).to.equal(1);
+        if (isPostgreSQL(knex)) {
+          expect(_.keys(rows[0]).length).to.equal(2);
+          expect(rows[0].account_id).to.equal(insertData.account_id);
+          expect(rows[0].details).to.equal(insertData.details);
+        }
       });
 
-      it('should allow a * for returning in postgres and oracle', function () {
+      it('should allow a * for returning in postgres and oracle', async function () {
         if (isRedshift(knex)) {
           return this.skip();
         }
@@ -1093,7 +1083,7 @@ describe('Inserts', function () {
         };
 
         const returningColumn = '*';
-        return knex('test_table_two')
+        const rows = await knex('test_table_two')
           .insert(insertData, returningColumn)
           .testSql(function (tester) {
             tester(
@@ -1153,16 +1143,15 @@ describe('Inserts', function () {
                 },
               ]
             );
-          })
-          .then(function (rows) {
-            expect(rows.length).to.equal(1);
-            if (isPgBased(knex)) {
-              expect(_.keys(rows[0]).length).to.equal(4);
-              assertNumber(knex, rows[0].account_id, insertData.account_id);
-              expect(rows[0].details).to.equal(insertData.details);
-              expect(rows[0].status).to.equal(insertData.status);
-            }
           });
+
+        expect(rows.length).to.equal(1);
+        if (isPgBased(knex)) {
+          expect(_.keys(rows[0]).length).to.equal(4);
+          assertNumber(knex, rows[0].account_id, insertData.account_id);
+          expect(rows[0].details).to.equal(insertData.details);
+          expect(rows[0].status).to.equal(insertData.status);
+        }
       });
 
       describe('batchInsert', function () {
@@ -1215,40 +1204,37 @@ describe('Inserts', function () {
 
           const fn = sinon.stub();
           process.on('unhandledRejection', fn);
-          await knex.schema
-            .dropTableIfExists('batchInsertDuplicateKey')
-            .then(function () {
-              return knex.schema.createTable(
-                'batchInsertDuplicateKey',
-                function (table) {
-                  table.string('col');
-                  table.primary('col');
-                }
-              );
-            })
-            .then(function () {
-              const rows = [{ col: 'a' }, { col: 'a' }];
-              return knex.batchInsert(
-                'batchInsertDuplicateKey',
-                rows,
-                rows.length
-              );
-            })
-            .then(function () {
-              expect.fail('Should not reach this point');
-            })
-            .catch(function (error) {
-              //Should reach this point before timeout of 10s
-              expect(error.message.toLowerCase()).to.include(
-                'batchinsertduplicatekey'
-              );
-            });
-          expect(fn).have.not.been.called;
-          process.removeListener('unhandledRejection', fn);
+          await knex.schema.dropTableIfExists('batchInsertDuplicateKey');
+
+          await knex.schema.createTable(
+            'batchInsertDuplicateKey',
+            function (table) {
+              table.string('col').notNullable();
+              table.primary('col');
+            }
+          );
+          const rows = [{ col: 'a' }, { col: 'a' }];
+
+          try {
+            await knex.batchInsert(
+              'batchInsertDuplicateKey',
+              rows,
+              rows.length
+            );
+          } catch (err) {
+            //Should reach this point before timeout of 10s
+            expect(err.message.toLowerCase()).to.include(
+              'batchinsertduplicatekey'
+            );
+            expect(fn).have.not.been.called;
+            process.removeListener('unhandledRejection', fn);
+            return;
+          }
+          expect.fail('Should not reach this point');
         });
 
-        it('knex.batchInsert with specified transaction', function () {
-          return knex.transaction(function (tr) {
+        it('knex.batchInsert with specified transaction', async function () {
+          await knex.transaction(function (tr) {
             knex
               .batchInsert('BatchInsert', items, 30)
               .returning(['Col1', 'Col2'])
@@ -1258,8 +1244,8 @@ describe('Inserts', function () {
           });
         });
 
-        it('transaction.batchInsert using specified transaction', function () {
-          return knex.transaction(function (tr) {
+        it('transaction.batchInsert using specified transaction', async function () {
+          await knex.transaction(function (tr) {
             return tr
               .batchInsert('BatchInsert', items, 30)
               .returning(['Col1', 'Col2']);
@@ -1267,78 +1253,72 @@ describe('Inserts', function () {
         });
       });
 
-      it('should validate batchInsert batchSize parameter', function () {
+      it('should validate batchInsert batchSize parameter', async function () {
         //Should not throw, batchSize default
-        return knex
-          .batchInsert('test', [])
-          .then(function () {
-            //Should throw, null not valid
-            return knex.batchInsert('test', [], null);
-          })
-          .catch(function (error) {
-            expect(error.message).to.equal('Invalid chunkSize: null');
+        await knex.batchInsert('test', []);
 
-            //Should throw, 0 is not a valid chunkSize
-            return knex.batchInsert('test', [], 0);
-          })
-          .catch(function (error) {
+        try {
+          knex.batchInsert('test', [], null);
+        } catch (error) {
+          expect(error.message).to.equal('Invalid chunkSize: null');
+          try {
+            knex.batchInsert('test', [], 0);
+          } catch (error) {
             expect(error.message).to.equal('Invalid chunkSize: 0');
-
-            //Also faulty
-            return knex.batchInsert('test', [], 'still no good');
-          })
-          .catch(function (error) {
-            expect(error.message).to.equal('Invalid chunkSize: still no good');
-
-            return true;
-          });
+            try {
+              //Also faulty
+              knex.batchInsert('test', [], 'still no good');
+            } catch (error) {
+              expect(error.message).to.equal(
+                'Invalid chunkSize: still no good'
+              );
+              return true;
+            }
+          }
+        }
       });
 
-      it('should replace undefined keys in multi insert with DEFAULT', function () {
+      it('should replace undefined keys in multi insert with DEFAULT', async function () {
         if (isSQLite(knex)) {
           return true;
         }
-        return knex('accounts')
-          .insert(
-            [
-              {
-                last_name: 'First Item',
-                email: 'single-test1@example.com',
-                about: 'Lorem ipsum Dolore labore incididunt enim.',
-                created_at: new Date(),
-                updated_at: new Date(),
-              },
-              {
-                last_name: 'Second Item',
-                email: 'double-test1@example.com',
-                logins: 2,
-                created_at: new Date(),
-                updated_at: new Date(),
-              },
-            ],
-            '*'
-          )
-          .then(function () {
-            return knex('accounts')
-              .whereIn('email', [
-                'single-test1@example.com',
-                'double-test1@example.com',
-              ])
-              .orderBy('email', 'desc');
-          })
-          .then(function (results) {
-            assertNumber(knex, results[0].logins, 1);
-            expect(results[1].about).to.equal(null);
-            // cleanup to prevent needs for too much changes to other tests
-            return knex('accounts')
-              .delete()
-              .whereIn(
-                'id',
-                results.map(function (row) {
-                  return row.id;
-                })
-              );
-          });
+        await knex('accounts').insert(
+          [
+            {
+              last_name: 'First Item',
+              email: 'single-test1@example.com',
+              about: 'Lorem ipsum Dolore labore incididunt enim.',
+              created_at: new Date(),
+              updated_at: new Date(),
+            },
+            {
+              last_name: 'Second Item',
+              email: 'double-test1@example.com',
+              logins: 2,
+              created_at: new Date(),
+              updated_at: new Date(),
+            },
+          ],
+          '*'
+        );
+        const results = await knex('accounts')
+          .whereIn('email', [
+            'single-test1@example.com',
+            'double-test1@example.com',
+          ])
+          .orderBy('email', 'desc');
+
+        assertNumber(knex, results[0].logins, 1);
+        expect(results[1].about).to.equal(null);
+        // cleanup to prevent needs for too much changes to other tests
+        await knex('accounts')
+          .delete()
+          .whereIn(
+            'id',
+            results.map(function (row) {
+              return row.id;
+            })
+          );
       });
 
       it('will silently do nothing when multiple inserts are made into a unique column and ignore is specified', async function () {
@@ -2090,11 +2070,11 @@ describe('Inserts', function () {
         ]);
       });
 
-      it('#1423 should replace undefined keys in single insert with DEFAULT also in transacting query', function () {
+      it('#1423 should replace undefined keys in single insert with DEFAULT also in transacting query', async function () {
         if (isSQLite(knex)) {
           return true;
         }
-        return knex.transaction(function (trx) {
+        await knex.transaction(function (trx) {
           return trx('accounts')
             .insert({
               last_name: 'First Item',
diff --git a/test/integration2/query/misc/additional.spec.js b/test/integration2/query/misc/additional.spec.js
index e438a091..30c92371 100644
--- a/test/integration2/query/misc/additional.spec.js
+++ b/test/integration2/query/misc/additional.spec.js
@@ -73,67 +73,53 @@ describe('Additional', function () {
           knex.client.config.postProcessResponse = null;
         });
 
-        it('should process normal response', () => {
-          return knex('accounts')
-            .limit(1)
-            .then((res) => {
-              expect(res.callCount).to.equal(1);
-            });
+        it('should process normal response', async () => {
+          const res = await knex('accounts').limit(1);
+          expect(res.callCount).to.equal(1);
         });
 
-        it('should pass query context to the custom handler', () => {
-          return knex('accounts')
+        it('should pass query context to the custom handler', async () => {
+          const res = await knex('accounts')
             .queryContext('the context')
-            .limit(1)
-            .then((res) => {
-              expect(res.queryContext).to.equal('the context');
-            });
+            .limit(1);
+          expect(res.queryContext).to.equal('the context');
         });
 
-        it('should process raw response', () => {
-          return knex.raw('select * from ??', ['accounts']).then((res) => {
-            expect(res.callCount).to.equal(1);
-          });
+        it('should process raw response', async () => {
+          const res = await knex.raw('select * from ??', ['accounts']);
+          expect(res.callCount).to.equal(1);
         });
 
-        it('should pass query context for raw responses', () => {
-          return knex
+        it('should pass query context for raw responses', async () => {
+          const res = await knex
             .raw('select * from ??', ['accounts'])
-            .queryContext('the context')
-            .then((res) => {
-              expect(res.queryContext).to.equal('the context');
-            });
+            .queryContext('the context');
+          expect(res.queryContext).to.equal('the context');
         });
 
-        it('should process response done in transaction', () => {
-          return knex
-            .transaction((trx) => {
-              return trx('accounts')
-                .limit(1)
-                .then((res) => {
-                  expect(res.callCount).to.equal(1);
-                  return res;
-                });
-            })
-            .then((res) => {
-              expect(res.callCount).to.equal(1);
-            });
+        it('should process response done in transaction', async () => {
+          const res = await knex.transaction((trx) => {
+            return trx('accounts')
+              .limit(1)
+              .then((res) => {
+                expect(res.callCount).to.equal(1);
+                return res;
+              });
+          });
+          expect(res.callCount).to.equal(1);
         });
 
-        it('should pass query context for responses from transactions', () => {
-          return knex
-            .transaction((trx) => {
-              return trx('accounts')
-                .queryContext('the context')
-                .limit(1)
-                .then((res) => {
-                  expect(res.queryContext).to.equal('the context');
-                  return res;
-                });
-            })
-            .then((res) => {
-              expect(res.queryContext).to.equal('the context');
-            });
+        it('should pass query context for responses from transactions', async () => {
+          const res = await knex.transaction((trx) => {
+            return trx('accounts')
+              .queryContext('the context')
+              .limit(1)
+              .then((res) => {
+                expect(res.queryContext).to.equal('the context');
+                return res;
+              });
+          });
+          expect(res.queryContext).to.equal('the context');
         });
 
         it('should handle error correctly in a stream', (done) => {
@@ -143,24 +129,25 @@ describe('Additional', function () {
           });
         });
 
-        it('should process response done through a stream', (done) => {
-          knex('accounts')
-            .truncate()
-            .then(() => {
-              return insertAccounts(knex, 'accounts');
-            })
-            .then(() => {
-              let response;
-              const stream = knex('accounts').limit(1).stream();
-
-              stream.on('data', (res) => {
-                response = res;
-              });
-              stream.on('finish', () => {
-                expect(response.callCount).to.equal(1);
-                done();
-              });
+        it('should process response done through a stream', async () => {
+          await knex('accounts').truncate();
+          await insertAccounts(knex, 'accounts');
+          let response;
+          let count = 0;
+          const stream = knex('accounts').limit(1).stream();
+          // Need to promise the stream to await it
+          await new Promise((done) => {
+            stream.on('data', (res) => {
+              count++;
+              response = res;
+            });
+            stream.on('finish', () => {
+              count++;
+              expect(response.callCount).to.equal(1);
+              done();
             });
+          });
+          expect(count).to.equal(2);
         });
 
         it('should pass query context for responses through a stream', (done) => {
@@ -208,30 +195,24 @@ describe('Additional', function () {
           knex.client.config.wrapIdentifier = null;
         });
 
-        it('should work using camelCased table name', () => {
-          return knex('testTableTwo')
-            .columnInfo()
-            .then((res) => {
-              expect(Object.keys(res)).to.have.all.members([
-                'id',
-                'accountId',
-                'details',
-                'status',
-              ]);
-            });
+        it('should work using camelCased table name', async () => {
+          const res = await knex('testTableTwo').columnInfo();
+          expect(Object.keys(res)).to.have.all.members([
+            'id',
+            'accountId',
+            'details',
+            'status',
+          ]);
         });
 
-        it('should work using snake_cased table name', () => {
-          return knex('test_table_two')
-            .columnInfo()
-            .then((res) => {
-              expect(Object.keys(res)).to.have.all.members([
-                'id',
-                'accountId',
-                'details',
-                'status',
-              ]);
-            });
+        it('should work using snake_cased table name', async () => {
+          const res = await knex('test_table_two').columnInfo();
+          expect(Object.keys(res)).to.have.all.members([
+            'id',
+            'accountId',
+            'details',
+            'status',
+          ]);
         });
       });
 
@@ -272,42 +253,37 @@ describe('Additional', function () {
           knex.client.config.wrapIdentifier = origHooks.wrapIdentifier;
         });
 
-        it('should return the correct column when a single property is given to returning', () => {
+        it('should return the correct column when a single property is given to returning', async function () {
           if (!isPostgreSQL(knex) && !isMssql(knex) && !isBetterSQLite3(knex)) {
-            return;
+            return this.skip();
           }
 
-          return knex('accounts_foo')
+          const res = await knex('accounts_foo')
             .insert({ balance_foo: 123 })
-            .returning('balance_foo')
-            .then((res) => {
-              expect(res).to.eql([
-                {
-                  balance_foo: 123,
-                },
-              ]);
-            });
+            .returning('balance_foo');
+          expect(res).to.eql([
+            {
+              balance_foo: 123,
+            },
+          ]);
         });
 
-        it('should return the correct columns when multiple properties are given to returning', () => {
+        it('should return the correct columns when multiple properties are given to returning', async function () {
           if (!isPostgreSQL(knex) && !isMssql(knex) && !isBetterSQLite3(knex)) {
-            return;
+            return this.skip();
           }
 
-          return knex('accounts_foo')
+          const res = await knex('accounts_foo')
             .insert({ balance_foo: 123, email_foo: 'foo@bar.com' })
-            .returning(['balance_foo', 'email_foo'])
-            .then((res) => {
-              expect(res).to.eql([
-                { balance_foo: 123, email_foo: 'foo@bar.com' },
-              ]);
-            });
+            .returning(['balance_foo', 'email_foo']);
+
+          expect(res).to.eql([{ balance_foo: 123, email_foo: 'foo@bar.com' }]);
         });
       });
 
       describe('other operations', () => {
-        it('should truncate a table with truncate', function () {
-          return knex('test_table_two')
+        it('should truncate a table with truncate', async function () {
+          await knex('test_table_two')
             .truncate()
             .testSql(function (tester) {
               tester('mysql', 'truncate `test_table_two`');
@@ -317,40 +293,28 @@ describe('Additional', function () {
               tester('sqlite3', 'delete from `test_table_two`');
               tester('oracledb', 'truncate table "test_table_two"');
               tester('mssql', 'truncate table [test_table_two]');
-            })
-            .then(() => {
-              return knex('test_table_two')
-                .select('*')
-                .then((resp) => {
-                  expect(resp).to.have.length(0);
-                });
-            })
-            .then(() => {
-              // Insert new data after truncate and make sure ids restart at 1.
-              // This doesn't currently work on oracle, where the created sequence
-              // needs to be manually reset.
-              // On redshift, one would need to create an entirely new table and do
-              //  `insert into ... (select ...); alter table rename...`
-              if (isOracle(knex) || isRedshift(knex)) {
-                return;
-              }
-              return knex('test_table_two')
-                .insert({ status: 1 })
-                .then((res) => {
-                  return knex('test_table_two')
-                    .select('id')
-                    .first()
-                    .then((res) => {
-                      expect(res).to.be.an('object');
-                      if (!isCockroachDB(knex)) {
-                        expect(res.id).to.equal(1);
-                      }
-                    });
-                });
             });
+
+          const resp = await knex('test_table_two').select('*');
+          expect(resp).to.have.length(0);
+
+          // Insert new data after truncate and make sure ids restart at 1.
+          // This doesn't currently work on oracle, where the created sequence
+          // needs to be manually reset.
+          // On redshift, one would need to create an entirely new table and do
+          //  `insert into ... (select ...); alter table rename...`
+          if (isOracle(knex) || isRedshift(knex)) {
+            return;
+          }
+          await knex('test_table_two').insert({ status: 1 });
+          const res = await knex('test_table_two').select('id').first();
+          expect(res).to.be.an('object');
+          if (!isCockroachDB(knex)) {
+            expect(res.id).to.equal(1);
+          }
         });
 
-        it('should allow raw queries directly with `knex.raw`', function () {
+        it('should allow raw queries directly with `knex.raw`', async function () {
           const tables = {
             [drivers.MySQL]: 'SHOW TABLES',
             [drivers.MySQL2]: 'SHOW TABLES',
@@ -370,7 +334,7 @@ describe('Additional', function () {
             [drivers.MsSQL]:
               "SELECT table_name FROM INFORMATION_SCHEMA.TABLES WHERE table_schema='dbo'",
           };
-          return knex
+          await knex
             .raw(tables[knex.client.driverName])
             .testSql(function (tester) {
               tester(knex.client.driverName, tables[knex.client.driverName]);
@@ -459,52 +423,43 @@ describe('Additional', function () {
           expect(expectedUuid).to.equal(originalUuid);
         });
 
-        it('#2184 - should properly escape table name for SQLite columnInfo', function () {
+        it('#2184 - should properly escape table name for SQLite columnInfo', async function () {
           if (!isSQLite(knex)) {
             return this.skip();
           }
 
-          return knex.schema
-            .dropTableIfExists('group')
-            .then(function () {
-              return knex.schema.createTable('group', function (table) {
-                table.integer('foo');
-              });
-            })
-            .then(function () {
-              return knex('group').columnInfo();
-            })
-            .then(function (columnInfo) {
-              expect(columnInfo).to.deep.equal({
-                foo: {
-                  type: 'integer',
-                  maxLength: null,
-                  nullable: true,
-                  defaultValue: null,
-                },
-              });
-            });
+          await knex.schema.dropTableIfExists('group');
+          await knex.schema.createTable('group', function (table) {
+            table.integer('foo');
+          });
+          const columnInfo = await knex('group').columnInfo();
+
+          expect(columnInfo).to.deep.equal({
+            foo: {
+              type: 'integer',
+              maxLength: null,
+              nullable: true,
+              defaultValue: null,
+            },
+          });
         });
 
         if (isOracle(knex)) {
           const oracledb = require('oracledb');
           describe('test oracle stored procedures', function () {
-            it('create stored procedure', function () {
-              return knex
-                .raw(
-                  `
+            it('create stored procedure', async function () {
+              const result = await knex.raw(
+                `
             CREATE OR REPLACE PROCEDURE SYSTEM.multiply (X IN NUMBER, Y IN NUMBER, OUTPUT OUT NUMBER)
               IS
               BEGIN
                 OUTPUT := X * Y;
               END;`
-                )
-                .then(function (result) {
-                  expect(result).to.be.an('array');
-                });
+              );
+              expect(result).to.be.an('array');
             });
 
-            it('get outbound values from stored procedure', function () {
+            it('get outbound values from stored procedure', async function () {
               const bindVars = {
                 x: 6,
                 y: 7,
@@ -512,22 +467,23 @@ describe('Additional', function () {
                   dir: oracledb.BIND_OUT,
                 },
               };
-              return knex
-                .raw('BEGIN SYSTEM.MULTIPLY(:x, :y, :output); END;', bindVars)
-                .then(function (result) {
-                  expect(result[0]).to.be.ok;
-                  expect(result[0]).to.equal('42');
-                });
+              const result = knex.raw(
+                'BEGIN SYSTEM.MULTIPLY(:x, :y, :output); END;',
+                bindVars
+              );
+
+              expect(result[0]).to.be.ok;
+              expect(result[0]).to.equal('42');
             });
 
-            it('drop stored procedure', function () {
+            it('drop stored procedure', async function () {
               const bindVars = { x: 6, y: 7 };
-              return knex
-                .raw('drop procedure SYSTEM.MULTIPLY', bindVars)
-                .then(function (result) {
-                  expect(result).to.be.ok;
-                  expect(result).to.be.an('array');
-                });
+              const result = await knex.raw(
+                'drop procedure SYSTEM.MULTIPLY',
+                bindVars
+              );
+              expect(result).to.be.ok;
+              expect(result).to.be.an('array');
             });
           });
         }
@@ -732,21 +688,18 @@ describe('Additional', function () {
 
           const query = testQueries[driverName]();
 
-          await query
-            .timeout(200)
-            .then(function () {
-              expect(true).to.equal(false);
-            })
-            .catch(function (error) {
-              expect(_.pick(error, 'timeout', 'name', 'message')).to.deep.equal(
-                {
-                  timeout: 200,
-                  name: 'KnexTimeoutError',
-                  message:
-                    'Defined query timeout of 200ms exceeded when running query.',
-                }
-              );
+          try {
+            await query.timeout(200);
+          } catch (error) {
+            expect(_.pick(error, 'timeout', 'name', 'message')).to.deep.equal({
+              timeout: 200,
+              name: 'KnexTimeoutError',
+              message:
+                'Defined query timeout of 200ms exceeded when running query.',
             });
+            return;
+          }
+          expect(true).to.equal(false);
         });
 
         it('.timeout(ms, {cancel: true}) should throw TimeoutError and cancel slow query', async function () {
@@ -802,7 +755,7 @@ describe('Additional', function () {
             expect(addTimeout).to.throw(
               'Query cancelling not supported for this dialect'
             );
-            return; // TODO: Use `this.skip()` here?
+            this.skip();
           }
 
           const getProcessesQueries = {
@@ -953,41 +906,37 @@ describe('Additional', function () {
 
           const getProcessesQuery = getProcessesQueries[driverName]();
 
-          await knex
-            .transaction((trx) => addTimeout().transacting(trx))
-            .then(function () {
-              expect(true).to.equal(false);
-            })
-            .catch(async function (error) {
-              expect(_.pick(error, 'timeout', 'name', 'message')).to.deep.equal(
-                {
-                  timeout: 200,
-                  name: 'KnexTimeoutError',
-                  message:
-                    'Defined query timeout of 200ms exceeded when running query.',
-                }
-              );
-
-              // Ensure sleep command is removed.
-              // This query will hang if a connection gets released back to the pool
-              // too early.
-              // 50ms delay since killing query doesn't seem to have immediate effect to the process listing
-              await delay(50);
-              const results = await getProcessesQuery;
-              let processes;
-              let sleepProcess;
-
-              if (_.startsWith(driverName, 'pg')) {
-                processes = results.rows;
-                sleepProcess = _.find(processes, { query: query.toString() });
-              } else {
-                processes = results[0];
-                sleepProcess = _.find(processes, {
-                  Info: 'SELECT SLEEP(10)',
-                });
-              }
-              expect(sleepProcess).to.equal(undefined);
+          try {
+            await knex.transaction((trx) => addTimeout().transacting(trx));
+            expect(true).to.equal(false);
+          } catch (error) {
+            expect(_.pick(error, 'timeout', 'name', 'message')).to.deep.equal({
+              timeout: 200,
+              name: 'KnexTimeoutError',
+              message:
+                'Defined query timeout of 200ms exceeded when running query.',
             });
+
+            // Ensure sleep command is removed.
+            // This query will hang if a connection gets released back to the pool
+            // too early.
+            // 50ms delay since killing query doesn't seem to have immediate effect to the process listing
+            await delay(50);
+            const results = await getProcessesQuery;
+            let processes;
+            let sleepProcess;
+
+            if (_.startsWith(driverName, 'pg')) {
+              processes = results.rows;
+              sleepProcess = _.find(processes, { query: query.toString() });
+            } else {
+              processes = results[0];
+              sleepProcess = _.find(processes, {
+                Info: 'SELECT SLEEP(10)',
+              });
+            }
+            expect(sleepProcess).to.equal(undefined);
+          }
         });
 
         it('.timeout(ms, {cancel: true}) should cancel slow query even if connection pool is exhausted', async function () {
@@ -1200,7 +1149,7 @@ describe('Additional', function () {
       });
 
       describe('Events', () => {
-        it('Event: query-response', function () {
+        it('Event: query-response', async function () {
           let queryCount = 0;
 
           const onQueryResponse = function (response, obj, builder) {
@@ -1213,23 +1162,17 @@ describe('Additional', function () {
           };
           knex.on('query-response', onQueryResponse);
 
-          return knex('accounts')
-            .select()
-            .on('query-response', onQueryResponse)
-            .then(function () {
-              return knex.transaction(function (tr) {
-                return tr('accounts')
-                  .select()
-                  .on('query-response', onQueryResponse); //Transactions should emit the event as well
-              });
-            })
-            .then(function () {
-              knex.removeListener('query-response', onQueryResponse);
-              expect(queryCount).to.equal(4);
-            });
+          await knex('accounts').select().on('query-response', onQueryResponse);
+          await knex.transaction(function (tr) {
+            return tr('accounts')
+              .select()
+              .on('query-response', onQueryResponse); //Transactions should emit the event as well
+          });
+          knex.removeListener('query-response', onQueryResponse);
+          expect(queryCount).to.equal(4);
         });
 
-        it('Event: preserves listeners on a copy with user params', function () {
+        it('Event: preserves listeners on a copy with user params', async function () {
           let queryCount = 0;
 
           const onQueryResponse = function (response, obj, builder) {
@@ -1243,26 +1186,22 @@ describe('Additional', function () {
           knex.on('query-response', onQueryResponse);
           const knexCopy = knex.withUserParams({});
 
-          return knexCopy('accounts')
+          await knexCopy('accounts')
             .select()
-            .on('query-response', onQueryResponse)
-            .then(function () {
-              return knexCopy.transaction(function (tr) {
-                return tr('accounts')
-                  .select()
-                  .on('query-response', onQueryResponse); //Transactions should emit the event as well
-              });
-            })
-            .then(function () {
-              expect(Object.keys(knex._events).length).to.equal(1);
-              expect(Object.keys(knexCopy._events).length).to.equal(1);
-              knex.removeListener('query-response', onQueryResponse);
-              expect(Object.keys(knex._events).length).to.equal(0);
-              expect(queryCount).to.equal(4);
-            });
+            .on('query-response', onQueryResponse);
+          await knexCopy.transaction(function (tr) {
+            return tr('accounts')
+              .select()
+              .on('query-response', onQueryResponse); //Transactions should emit the event as well
+          });
+          expect(Object.keys(knex._events).length).to.equal(1);
+          expect(Object.keys(knexCopy._events).length).to.equal(1);
+          knex.removeListener('query-response', onQueryResponse);
+          expect(Object.keys(knex._events).length).to.equal(0);
+          expect(queryCount).to.equal(4);
         });
 
-        it('Event: query-error', function () {
+        it('Event: query-error', async function () {
           let queryCountKnex = 0;
           let queryCountBuilder = 0;
           const onQueryErrorKnex = function (error, obj) {
@@ -1282,39 +1221,31 @@ describe('Additional', function () {
           };
 
           knex.on('query-error', onQueryErrorKnex);
-
-          return knex
-            .raw('Broken query')
-            .on('query-error', onQueryErrorBuilder)
-            .then(function () {
-              expect(true).to.equal(false); //Should not be resolved
-            })
-            .catch(function () {
-              knex.removeListener('query-error', onQueryErrorKnex);
-              knex.removeListener('query-error', onQueryErrorBuilder);
-              expect(queryCountBuilder).to.equal(1);
-              expect(queryCountKnex).to.equal(1);
-            });
+          try {
+            await knex
+              .raw('Broken query')
+              .on('query-error', onQueryErrorBuilder);
+            expect(true).to.equal(false); //Should not be resolved
+          } catch (err) {
+            knex.removeListener('query-error', onQueryErrorKnex);
+            knex.removeListener('query-error', onQueryErrorBuilder);
+            expect(queryCountBuilder).to.equal(1);
+            expect(queryCountKnex).to.equal(1);
+          }
         });
 
-        it('Event: start', function () {
-          return knex('accounts')
-            .insert({ last_name: 'Start event test' })
-            .then(function () {
-              const queryBuilder = knex('accounts').select();
-
-              queryBuilder.on('start', function (builder) {
-                //Alter builder prior to compilation
-                //Select only one row
-                builder.where('last_name', 'Start event test').first();
-              });
+        it('Event: start', async function () {
+          await knex('accounts').insert({ last_name: 'Start event test' });
+          const queryBuilder = knex('accounts').select();
 
-              return queryBuilder;
-            })
-            .then(function (row) {
-              expect(row).to.exist;
-              expect(row.last_name).to.equal('Start event test');
-            });
+          queryBuilder.on('start', function (builder) {
+            //Alter builder prior to compilation
+            //Select only one row
+            builder.where('last_name', 'Start event test').first();
+          });
+          const row = await queryBuilder;
+          expect(row).to.exist;
+          expect(row.last_name).to.equal('Start event test');
         });
 
         it("Event 'query' should not emit native sql string", function () {
@@ -1343,24 +1274,22 @@ describe('Additional', function () {
         after(() => {
           delete knex.client.config.asyncStackTraces;
         });
-        it('should capture stack trace on raw query', () => {
-          return knex
-            .raw('select * from some_nonexisten_table')
-            .catch((err) => {
-              expect(err.stack.split('\n')[2]).to.match(/at Object\.raw \(/); // the index 2 might need adjustment if the code is refactored
-              expect(typeof err.originalStack).to.equal('string');
-            });
+        it('should capture stack trace on raw query', async () => {
+          try {
+            await knex.raw('select * from some_nonexisten_table');
+          } catch (err) {
+            expect(err.stack.split('\n')[2]).to.match(/at Object\.raw \(/); // the index 2 might need adjustment if the code is refactored
+            expect(typeof err.originalStack).to.equal('string');
+          }
         });
 
-        it('should capture stack trace on schema builder', () => {
-          return knex.schema
-            .renameTable('some_nonexisten_table', 'whatever')
-            .catch((err) => {
-              expect(err.stack.split('\n')[1]).to.match(
-                /client\.schemaBuilder/
-              ); // the index 1 might need adjustment if the code is refactored
-              expect(typeof err.originalStack).to.equal('string');
-            });
+        it('should capture stack trace on schema builder', async () => {
+          try {
+            await knex.schema.renameTable('some_nonexisten_table', 'whatever');
+          } catch (err) {
+            expect(err.stack.split('\n')[1]).to.match(/client\.schemaBuilder/); // the index 1 might need adjustment if the code is refactored
+            expect(typeof err.originalStack).to.equal('string');
+          }
         });
       });
 
diff --git a/test/integration2/query/select/joins.spec.js b/test/integration2/query/select/joins.spec.js
index 2c178687..40cf70aa 100644
--- a/test/integration2/query/select/joins.spec.js
+++ b/test/integration2/query/select/joins.spec.js
@@ -48,8 +48,8 @@ describe('Joins', function () {
         await knex.destroy();
       });
 
-      it('uses inner join by default', function () {
-        return knex('accounts')
+      it('uses inner join by default', async function () {
+        await knex('accounts')
           .join(
             'test_table_two',
             'accounts.id',
@@ -350,8 +350,8 @@ describe('Joins', function () {
           });
       });
 
-      it('has a leftJoin method parameter to specify the join type', function () {
-        return knex('accounts')
+      it('has a leftJoin method parameter to specify the join type', async function () {
+        await knex('accounts')
           .leftJoin(
             'test_table_two',
             'accounts.id',
@@ -1042,8 +1042,8 @@ describe('Joins', function () {
           });
       });
 
-      it('accepts a callback as the second argument for advanced joins', function () {
-        return knex('accounts')
+      it('accepts a callback as the second argument for advanced joins', async function () {
+        await knex('accounts')
           .leftJoin('test_table_two', function (join) {
             join.on('accounts.id', '=', 'test_table_two.account_id');
             join.orOn('accounts.email', '=', 'test_table_two.details');
@@ -1699,9 +1699,9 @@ describe('Joins', function () {
           });
       });
 
-      it('supports join aliases', function () {
+      it('supports join aliases', async function () {
         //Expected output: all pairs of account emails, excluding pairs where the emails are the same.
-        return knex('accounts')
+        await knex('accounts')
           .join('accounts as a2', 'a2.email', '<>', 'accounts.email')
           .select(['accounts.email as e1', 'a2.email as e2'])
           .where('a2.email', 'test2@example.com')
@@ -1873,10 +1873,10 @@ describe('Joins', function () {
           });
       });
 
-      it('supports join aliases with advanced joins', function () {
+      it('supports join aliases with advanced joins', async function () {
         //Expected output: all pairs of account emails, excluding pairs where the emails are the same.
         //But also include the case where the emails are the same, for account 2.
-        return knex('accounts')
+        await knex('accounts')
           .join('accounts as a2', function () {
             this.on('accounts.email', '<>', 'a2.email').orOn(
               'accounts.id',
@@ -2054,8 +2054,8 @@ describe('Joins', function () {
           });
       });
 
-      it('supports cross join without arguments', function () {
-        return knex
+      it('supports cross join without arguments', async function () {
+        await knex
           .select('account_id')
           .from('accounts')
           .crossJoin('test_table_two')
@@ -2113,8 +2113,8 @@ describe('Joins', function () {
           });
       });
 
-      it('left join with subquery in on clause, #', function () {
-        return knex
+      it('left join with subquery in on clause, #', async function () {
+        await knex
           .select('account_id')
           .from('accounts')
           .leftJoin('test_table_two', (j) =>
@@ -2176,12 +2176,12 @@ describe('Joins', function () {
           });
       });
 
-      it('supports joins with overlapping column names', function () {
+      it('supports joins with overlapping column names', async function () {
         if (isOracle(knex)) {
           return this.skip();
         }
 
-        return knex('accounts as a1')
+        await knex('accounts as a1')
           .leftJoin('accounts as a2', function () {
             this.on('a1.email', '<>', 'a2.email');
           })
diff --git a/test/integration2/query/select/unions.spec.js b/test/integration2/query/select/unions.spec.js
index 429c1cd3..7226c44c 100644
--- a/test/integration2/query/select/unions.spec.js
+++ b/test/integration2/query/select/unions.spec.js
@@ -59,8 +59,8 @@ describe('unions', function () {
         await knex.destroy();
       });
 
-      it('handles unions with a callback', function () {
-        return knex('accounts')
+      it('handles unions with a callback', async () => {
+        await knex('accounts')
           .select(unionCols)
           .where('id', '=', 1)
           .union(function () {
@@ -68,8 +68,8 @@ describe('unions', function () {
           });
       });
 
-      it('handles unions with an array of callbacks', function () {
-        return knex('accounts')
+      it('handles unions with an array of callbacks', async () => {
+        await knex('accounts')
           .select(unionCols)
           .where('id', '=', 1)
           .union([
@@ -82,8 +82,8 @@ describe('unions', function () {
           ]);
       });
 
-      it('handles unions with a list of callbacks', function () {
-        return knex('accounts')
+      it('handles unions with a list of callbacks', async () => {
+        await knex('accounts')
           .select(unionCols)
           .where('id', '=', 1)
           .union(
@@ -96,8 +96,8 @@ describe('unions', function () {
           );
       });
 
-      it('handles unions with an array of builders', function () {
-        return knex('accounts')
+      it('handles unions with an array of builders', async () => {
+        await knex('accounts')
           .select(unionCols)
           .where('id', '=', 1)
           .union([
@@ -106,8 +106,8 @@ describe('unions', function () {
           ]);
       });
 
-      it('handles unions with a list of builders', function () {
-        return knex('accounts')
+      it('handles unions with a list of builders', async () => {
+        await knex('accounts')
           .select(unionCols)
           .where('id', '=', 1)
           .union(
@@ -116,8 +116,8 @@ describe('unions', function () {
           );
       });
 
-      it('handles unions with a raw query', function () {
-        return knex('union_raw_test')
+      it('handles unions with a raw query', async () => {
+        await knex('union_raw_test')
           .select('*')
           .where('id', '=', 1)
           .union(
@@ -129,8 +129,8 @@ describe('unions', function () {
           );
       });
 
-      it('handles unions with an array raw queries', function () {
-        return knex('union_raw_test')
+      it('handles unions with an array raw queries', async () => {
+        await knex('union_raw_test')
           .select('*')
           .where('id', '=', 1)
           .union([
@@ -147,8 +147,8 @@ describe('unions', function () {
           ]);
       });
 
-      it('handles unions with a list of raw queries', function () {
-        return knex('union_raw_test')
+      it('handles unions with a list of raw queries', async () => {
+        await knex('union_raw_test')
           .select('*')
           .where('id', '=', 1)
           .union(
@@ -515,8 +515,8 @@ describe('unions', function () {
           });
         });
 
-        beforeEach(function () {
-          return knex('intersect_test').insert([
+        beforeEach(async function () {
+          await knex('intersect_test').insert([
             {
               id: 1,
               test_col_1: 1,
@@ -550,8 +550,8 @@ describe('unions', function () {
           ]);
         });
 
-        after(function () {
-          return knex.schema.dropTable('intersect_test');
+        after(async function () {
+          await knex.schema.dropTable('intersect_test');
         });
 
         it('handles intersects with a callback', async function () {
diff --git a/test/integration2/query/select/where.spec.js b/test/integration2/query/select/where.spec.js
index 5c5a626e..e7968681 100644
--- a/test/integration2/query/select/where.spec.js
+++ b/test/integration2/query/select/where.spec.js
@@ -61,8 +61,8 @@ describe('Where', function () {
       });
 
       describe('simple "where" cases', function () {
-        it('allows key, value', function () {
-          return knex('accounts')
+        it('allows key, value', async function () {
+          await knex('accounts')
             .where('id', 1)
             .select('first_name', 'last_name')
             .testSql(function (tester) {
@@ -102,8 +102,8 @@ describe('Where', function () {
             });
         });
 
-        it('allows key, operator, value', function () {
-          return knex('accounts')
+        it('allows key, operator, value', async function () {
+          await knex('accounts')
             .where('id', 1)
             .select('first_name', 'last_name')
             .testSql(function (tester) {
@@ -143,8 +143,8 @@ describe('Where', function () {
             });
         });
 
-        it('allows selecting columns with an array', function () {
-          return knex('accounts')
+        it('allows selecting columns with an array', async function () {
+          await knex('accounts')
             .where('id', '>', 1)
             .select(['email', 'logins'])
             .testSql(function (tester) {
@@ -166,8 +166,8 @@ describe('Where', function () {
             });
         });
 
-        it('allows a hash of where attrs', function () {
-          return knex('accounts')
+        it('allows a hash of where attrs', async function () {
+          await knex('accounts')
             .where({ id: 1 })
             .select('*')
             .testSql(function (tester) {
@@ -231,8 +231,8 @@ describe('Where', function () {
             });
         });
 
-        it('allows where id: undefined or id: null as a where null clause', function () {
-          return knex('accounts')
+        it('allows where id: undefined or id: null as a where null clause', async function () {
+          await knex('accounts')
             .where({ id: null })
             .select('first_name', 'email')
             .testSql(function (tester) {
@@ -257,8 +257,8 @@ describe('Where', function () {
             });
         });
 
-        it('allows where id = 0', function () {
-          return knex('accounts')
+        it('allows where id = 0', async function () {
+          await knex('accounts')
             .where({ id: 0 })
             .select()
             .testSql(function (tester) {
@@ -284,39 +284,35 @@ describe('Where', function () {
         });
       });
 
-      it('does "orWhere" cases', function () {
-        return knex('accounts')
+      it('does "orWhere" cases', async function () {
+        await knex('accounts')
           .where('id', 1)
           .orWhere('id', '>', 2)
           .select('first_name', 'last_name');
       });
 
-      it('does "andWhere" cases', function () {
-        return knex('accounts')
+      it('does "andWhere" cases', async function () {
+        await knex('accounts')
           .select('first_name', 'last_name', 'about')
           .where('id', 1)
           .andWhere('email', 'test1@example.com');
       });
 
-      it('takes a function to wrap nested where statements', function () {
-        return Promise.all([
-          knex('accounts')
-            .where(function () {
-              this.where('id', 2);
-              this.orWhere('id', 3);
-            })
-            .select('*'),
-        ]);
+      it('takes a function to wrap nested where statements', async () => {
+        await knex('accounts')
+          .where(function () {
+            this.where('id', 2);
+            this.orWhere('id', 3);
+          })
+          .select('*');
       });
 
-      it('handles "where in" cases', function () {
-        return Promise.all([
-          knex('accounts').whereIn('id', [1, 2, 3]).select(),
-        ]);
+      it('handles "where in" cases', async () => {
+        await knex('accounts').whereIn('id', [1, 2, 3]).select();
       });
 
-      it('handles "or where in" cases', function () {
-        return knex('accounts')
+      it('handles "or where in" cases', async () => {
+        await knex('accounts')
           .where('email', 'test1@example.com')
           .orWhereIn('id', [2, 3, 4])
           .select();
@@ -436,9 +432,9 @@ describe('Where', function () {
         }
       });
 
-      it('handles multi-column "where in" cases with where', function () {
+      it('handles multi-column "where in" cases with where', async function () {
         if (!isSQLite(knex) && !isMssql(knex)) {
-          return knex('composite_key_test')
+          await knex('composite_key_test')
             .where('status', 1)
             .whereIn(
               ['column_a', 'column_b'],
@@ -492,29 +488,29 @@ describe('Where', function () {
         }
       });
 
-      it('handles "where exists"', function () {
-        return knex('accounts')
+      it('handles "where exists"', async () => {
+        await knex('accounts')
           .whereExists(function () {
             this.select('id').from('test_table_two').where({ id: 1 });
           })
           .select();
       });
 
-      it('handles "where between"', function () {
-        return knex('accounts').whereBetween('id', [1, 100]).select();
+      it('handles "where between"', async () => {
+        await knex('accounts').whereBetween('id', [1, 100]).select();
       });
 
-      it('handles "or where between"', function () {
-        return knex('accounts')
+      it('handles "or where between"', async () => {
+        await knex('accounts')
           .whereBetween('id', [1, 100])
           .orWhereBetween('id', [200, 300])
           .select();
       });
 
-      it('does where(raw)', function () {
+      it('does where(raw)', async function () {
         if (isOracle(knex)) {
           // special case for oracle
-          return knex('accounts')
+          await knex('accounts')
             .whereExists(function () {
               this.select(knex.raw(1))
                 .from('test_table_two')
@@ -524,7 +520,7 @@ describe('Where', function () {
             })
             .select();
         } else {
-          return knex('accounts')
+          await knex('accounts')
             .whereExists(function () {
               this.select(knex.raw(1))
                 .from('test_table_two')
@@ -534,31 +530,31 @@ describe('Where', function () {
         }
       });
 
-      it('does sub-selects', function () {
-        return knex('accounts')
+      it('does sub-selects', async () => {
+        await knex('accounts')
           .whereIn('id', function () {
             this.select('account_id').from('test_table_two').where('status', 1);
           })
           .select('first_name', 'last_name');
       });
 
-      it('supports the <> operator', function () {
-        return knex('accounts').where('id', '<>', 2).select('email', 'logins');
+      it('supports the <> operator', async () => {
+        await knex('accounts').where('id', '<>', 2).select('email', 'logins');
       });
 
-      it('Allows for knex.Raw passed to the `where` clause', function () {
+      it('Allows for knex.Raw passed to the `where` clause', async () => {
         if (isOracle(knex)) {
-          return knex('accounts')
+          await knex('accounts')
             .where(knex.raw('"id" = 2'))
             .select('email', 'logins');
         } else {
-          return knex('accounts')
+          await knex('accounts')
             .where(knex.raw('id = 2'))
             .select('email', 'logins');
         }
       });
 
-      describe('where like', function () {
+      describe('where like', async function () {
         beforeEach(function () {
           if (!(isPostgreSQL(knex) || isMssql(knex) || isMysql(knex))) {
             return this.skip();
diff --git a/test/integration2/query/update/updates.spec.js b/test/integration2/query/update/updates.spec.js
index 378a55d0..6bfbbef3 100644
--- a/test/integration2/query/update/updates.spec.js
+++ b/test/integration2/query/update/updates.spec.js
@@ -41,8 +41,8 @@ describe('Updates', function () {
         accountId1 = accounts[0].id;
       });
 
-      it('should handle updates', function () {
-        return knex('accounts')
+      it('should handle updates', async function () {
+        await knex('accounts')
           .where('id', 1)
           .update({
             first_name: 'User',
@@ -83,8 +83,8 @@ describe('Updates', function () {
           });
       });
 
-      it('should allow for null updates', function () {
-        return knex('accounts')
+      it('should allow for null updates', async function () {
+        await knex('accounts')
           .where('id', 1000)
           .update({
             email: 'test100@example.com',
@@ -107,199 +107,143 @@ describe('Updates', function () {
           });
       });
 
-      it('should immediately return updated value for other connections when updating row to DB returns', function () {
-        return knex('accounts').then((res) => {
-          function runTest() {
-            return Promise.all(
-              res.map((origRow) => {
-                return Promise.resolve()
-                  .then(() => {
-                    return knex.transaction((trx) =>
-                      trx('accounts')
-                        .where('id', origRow.id)
-                        .update({ balance: 654 })
-                    );
-                  })
-                  .then(() => {
-                    return knex('accounts')
-                      .where('id', origRow.id)
-                      .then((res) => res[0]);
-                  })
-                  .then((updatedRow) => {
-                    expect(updatedRow.balance).to.equal(654);
-                    return knex.transaction((trx) =>
-                      trx('accounts')
-                        .where('id', origRow.id)
-                        .update({ balance: origRow.balance })
-                    );
-                  })
-                  .then(() => {
-                    return knex('accounts')
-                      .where('id', origRow.id)
-                      .then((res) => res[0]);
-                  })
-                  .then((updatedRow) => {
-                    expect(updatedRow.balance).to.equal(origRow.balance);
-                  });
-              })
-            );
-          }
+      it('should immediately return updated value for other connections when updating row to DB returns', async function () {
+        const res = await knex('accounts');
 
-          // run few times to try to catch the problem
-          return runTest()
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest())
-            .then(() => runTest());
-        });
+        async function runTest() {
+          return Promise.all(
+            res.map(async (origRow) => {
+              await knex.transaction(
+                async (trx) =>
+                  await trx('accounts')
+                    .where('id', origRow.id)
+                    .update({ balance: 654 })
+              );
+
+              const updatedRow = await knex('accounts').where('id', origRow.id);
+
+              expect(updatedRow[0].balance).to.equal(654);
+
+              await knex.transaction(
+                async (trx) =>
+                  await trx('accounts')
+                    .where('id', origRow.id)
+                    .update({ balance: origRow.balance })
+              );
+
+              const updatedRow2 = await knex('accounts').where(
+                'id',
+                origRow.id
+              );
+
+              expect(updatedRow2[0].balance).to.equal(origRow.balance);
+            })
+          );
+        }
+
+        // run few times to try to catch the problem
+        for (let i = 0; i <= 20; i++) {
+          await runTest();
+        }
       });
 
-      it('should increment a value', function () {
-        return knex('accounts')
+      it('should increment a value', async function () {
+        const accounts = await knex('accounts')
           .select('logins')
+          .where('id', accountId1);
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .increment('logins')
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('logins')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                assertNumber(
-                  knex,
-                  accounts2[0].logins,
-                  parseInt(accounts[0].logins) + 1
-                );
-              });
-          });
+          .increment('logins');
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('logins')
+          .where('id', accountId1);
+        assertNumber(
+          knex,
+          accounts2[0].logins,
+          parseInt(accounts[0].logins) + 1
+        );
       });
 
-      it('should increment a negative value', function () {
-        return knex('accounts')
+      it('should increment a negative value', async function () {
+        const accounts = await knex('accounts')
           .select('logins')
+          .where('id', accountId1);
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .increment('logins', -2)
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('logins')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                assertNumber(knex, accounts2[0].logins, accounts[0].logins - 2);
-              });
-          });
+          .increment('logins', -2);
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('logins')
+          .where('id', accountId1);
+        assertNumber(knex, accounts2[0].logins, accounts[0].logins - 2);
       });
 
-      it('should increment a float value', function () {
-        return knex('accounts')
+      it('should increment a float value', async function () {
+        const accounts = await knex('accounts')
           .select('balance')
+          .where('id', accountId1);
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .increment('balance', 22.53)
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('balance')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                expect(accounts[0].balance + 22.53).to.be.closeTo(
-                  accounts2[0].balance,
-                  0.001
-                );
-              });
-          });
+          .increment('balance', 22.53);
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('balance')
+          .where('id', accountId1);
+        expect(accounts[0].balance + 22.53).to.be.closeTo(
+          accounts2[0].balance,
+          0.001
+        );
       });
 
-      it('should decrement a value', function () {
-        return knex('accounts')
+      it('should decrement a value', async function () {
+        const accounts = await knex('accounts')
           .select('logins')
+          .where('id', accountId1);
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .decrement('logins')
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('logins')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                assertNumber(knex, accounts2[0].logins, accounts[0].logins - 1);
-              });
-          });
+          .decrement('logins');
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('logins')
+          .where('id', accountId1);
+        assertNumber(knex, accounts2[0].logins, accounts[0].logins - 1);
       });
 
-      it('should decrement a negative value', function () {
-        return knex('accounts')
+      it('should decrement a negative value', async function () {
+        const accounts = await knex('accounts')
           .select('logins')
+          .where('id', accountId1);
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .decrement('logins', -2)
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('logins')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                assertNumber(
-                  knex,
-                  accounts2[0].logins,
-                  parseInt(accounts[0].logins) + 2
-                );
-              });
-          });
+          .decrement('logins', -2);
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('logins')
+          .where('id', accountId1);
+        assertNumber(
+          knex,
+          accounts2[0].logins,
+          parseInt(accounts[0].logins) + 2
+        );
       });
 
       it('should decrement a float value', async function () {
-        return knex('accounts')
+        const accounts = await knex('accounts')
           .select('balance')
+          .where('id', accountId1);
+
+        const rowsAffected = await knex('accounts')
           .where('id', accountId1)
-          .then(function (accounts) {
-            return knex('accounts')
-              .where('id', accountId1)
-              .decrement('balance', 10.29)
-              .then(function (rowsAffected) {
-                expect(rowsAffected).to.equal(1);
-                return knex('accounts')
-                  .select('balance')
-                  .where('id', accountId1);
-              })
-              .then(function (accounts2) {
-                expect(accounts[0].balance - 10.29).to.be.closeTo(
-                  accounts2[0].balance,
-                  0.001
-                );
-              });
-          });
+          .decrement('balance', 10.29);
+        expect(rowsAffected).to.equal(1);
+        const accounts2 = await knex('accounts')
+          .select('balance')
+          .where('id', accountId1);
+        expect(accounts[0].balance - 10.29).to.be.closeTo(
+          accounts2[0].balance,
+          0.001
+        );
       });
 
       it('should allow returning for updates', async function () {