mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-10-04 08:47:41 +03:00
Fixed data generator in SQLite
This commit is contained in:
parent
70b991cc1c
commit
4c9d08bf03
@ -7,6 +7,7 @@ const {faker} = require('@faker-js/faker');
|
|||||||
const {faker: americanFaker} = require('@faker-js/faker/locale/en_US');
|
const {faker: americanFaker} = require('@faker-js/faker/locale/en_US');
|
||||||
const crypto = require('crypto');
|
const crypto = require('crypto');
|
||||||
const {Buffer} = require('node:buffer');
|
const {Buffer} = require('node:buffer');
|
||||||
|
const DatabaseInfo = require('@tryghost/database-info');
|
||||||
|
|
||||||
const importers = require('./importers').reduce((acc, val) => {
|
const importers = require('./importers').reduce((acc, val) => {
|
||||||
acc[val.table] = val;
|
acc[val.table] = val;
|
||||||
@ -153,8 +154,10 @@ class DataGenerator {
|
|||||||
async importData() {
|
async importData() {
|
||||||
await this.knex.transaction(async (transaction) => {
|
await this.knex.transaction(async (transaction) => {
|
||||||
// Performance improvements
|
// Performance improvements
|
||||||
await this.knex.raw('SET FOREIGN_KEY_CHECKS=0;').transacting(transaction);
|
if (!DatabaseInfo.isSQLite(this.knex)) {
|
||||||
await this.knex.raw('SET unique_checks=0;').transacting(transaction);
|
await this.knex.raw('SET FOREIGN_KEY_CHECKS=0;').transacting(transaction);
|
||||||
|
await this.knex.raw('SET unique_checks=0;').transacting(transaction);
|
||||||
|
}
|
||||||
|
|
||||||
// Add default tables if none are specified
|
// Add default tables if none are specified
|
||||||
if (this.tableList.length === 0) {
|
if (this.tableList.length === 0) {
|
||||||
@ -249,8 +252,10 @@ class DataGenerator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Performance improvements
|
// Performance improvements
|
||||||
await this.knex.raw('SET FOREIGN_KEY_CHECKS=1;').transacting(transaction);
|
if (!DatabaseInfo.isSQLite(this.knex)) {
|
||||||
await this.knex.raw('SET unique_checks=1;').transacting(transaction);
|
await this.knex.raw('SET FOREIGN_KEY_CHECKS=1;').transacting(transaction);
|
||||||
|
await this.knex.raw('SET unique_checks=1;').transacting(transaction);
|
||||||
|
}
|
||||||
}, {isolationLevel: 'read committed'});
|
}, {isolationLevel: 'read committed'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user