mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-02-10 23:36:14 -05:00
Removed Bluebird Promise.each from db.utils (#17032)
refs https://github.com/TryGhost/Ghost/issues/14882 Co-authored-by: Princi Vershwal <princi.vershwal@Princis-MacBook-Pro.local> Co-authored-by: Daniel Lockyer <hi@daniellockyer.com>
This commit is contained in:
parent
cc95c39dbb
commit
2798d43663
1 changed files with 5 additions and 3 deletions
|
@ -2,7 +2,6 @@ const debug = require('@tryghost/debug')('test:dbUtils');
|
||||||
|
|
||||||
// Utility Packages
|
// Utility Packages
|
||||||
const fs = require('fs-extra');
|
const fs = require('fs-extra');
|
||||||
const Promise = require('bluebird');
|
|
||||||
const KnexMigrator = require('knex-migrator');
|
const KnexMigrator = require('knex-migrator');
|
||||||
const knexMigrator = new KnexMigrator();
|
const knexMigrator = new KnexMigrator();
|
||||||
const DatabaseInfo = require('@tryghost/database-info');
|
const DatabaseInfo = require('@tryghost/database-info');
|
||||||
|
@ -12,6 +11,7 @@ const config = require('../../core/shared/config');
|
||||||
const db = require('../../core/server/data/db');
|
const db = require('../../core/server/data/db');
|
||||||
const schema = require('../../core/server/data/schema').tables;
|
const schema = require('../../core/server/data/schema').tables;
|
||||||
const schemaTables = Object.keys(schema);
|
const schemaTables = Object.keys(schema);
|
||||||
|
const {sequence} = require('@tryghost/promise');
|
||||||
|
|
||||||
// Other Test Utilities
|
// Other Test Utilities
|
||||||
const urlServiceUtils = require('./url-service-utils');
|
const urlServiceUtils = require('./url-service-utils');
|
||||||
|
@ -139,7 +139,9 @@ const truncateAll = async () => {
|
||||||
await db.knex.raw('PRAGMA foreign_keys = OFF;');
|
await db.knex.raw('PRAGMA foreign_keys = OFF;');
|
||||||
}
|
}
|
||||||
|
|
||||||
await Promise.each(tables, table => db.knex.raw('DELETE FROM ' + table + ';'));
|
await sequence(tables.map(table => () => {
|
||||||
|
return db.knex.raw('DELETE FROM ' + table + ';');
|
||||||
|
}));
|
||||||
|
|
||||||
if (foreignKeysEnabled.foreign_keys) {
|
if (foreignKeysEnabled.foreign_keys) {
|
||||||
await db.knex.raw('PRAGMA foreign_keys = ON;');
|
await db.knex.raw('PRAGMA foreign_keys = ON;');
|
||||||
|
@ -161,7 +163,7 @@ const truncateAll = async () => {
|
||||||
await db.knex.transaction(async (trx) => {
|
await db.knex.transaction(async (trx) => {
|
||||||
try {
|
try {
|
||||||
await db.knex.raw('SET FOREIGN_KEY_CHECKS=0;').transacting(trx);
|
await db.knex.raw('SET FOREIGN_KEY_CHECKS=0;').transacting(trx);
|
||||||
await Promise.each(tables, table => db.knex.raw('DELETE FROM ' + table + ';').transacting(trx));
|
await sequence(tables.map(table => () => db.knex.raw('DELETE FROM ' + table + ';').transacting(trx)));
|
||||||
await db.knex.raw('SET FOREIGN_KEY_CHECKS=1;').transacting(trx);
|
await db.knex.raw('SET FOREIGN_KEY_CHECKS=1;').transacting(trx);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
// CASE: table does not exist || DB does not exist
|
// CASE: table does not exist || DB does not exist
|
||||||
|
|
Loading…
Add table
Reference in a new issue