0
Fork 0
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:
Princi Vershwal 2023-06-23 13:16:41 +05:30 committed by GitHub
parent cc95c39dbb
commit 2798d43663
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,6 @@ const debug = require('@tryghost/debug')('test:dbUtils');
// Utility Packages
const fs = require('fs-extra');
const Promise = require('bluebird');
const KnexMigrator = require('knex-migrator');
const knexMigrator = new KnexMigrator();
const DatabaseInfo = require('@tryghost/database-info');
@ -12,6 +11,7 @@ const config = require('../../core/shared/config');
const db = require('../../core/server/data/db');
const schema = require('../../core/server/data/schema').tables;
const schemaTables = Object.keys(schema);
const {sequence} = require('@tryghost/promise');
// Other Test Utilities
const urlServiceUtils = require('./url-service-utils');
@ -139,7 +139,9 @@ const truncateAll = async () => {
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) {
await db.knex.raw('PRAGMA foreign_keys = ON;');
@ -161,7 +163,7 @@ const truncateAll = async () => {
await db.knex.transaction(async (trx) => {
try {
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);
} catch (err) {
// CASE: table does not exist || DB does not exist