Skip to content
Permalink
Browse files

migrateStrongsTranslations: Added try/catch block around migration

  • Loading branch information
tobias-klein committed Nov 1, 2019
1 parent 8c17e1c commit 994eaef67386af0939ad31ab0ffffff62ec6fbd0
Showing with 28 additions and 24 deletions.
  1. +28 −24 migrations/20191027174828-migrateStrongsTranslations.js
@@ -2,36 +2,40 @@

module.exports = {
up: async (queryInterface, Sequelize) => {
const NodeSwordInterface = require('node-sword-interface');
const nsi = new NodeSwordInterface();
const models = require('../models')(dbDir);

var localSwordModules = nsi.getAllLocalModules();
var dbModules = await models.BibleTranslation.findAndCountAll();

for (var dbTranslation of dbModules.rows) {
if (dbTranslation.hasStrongs) {
var swordModuleFound = false;

for (var i = 0; i < localSwordModules.length; i++) {
if (localSwordModules[i].name == dbTranslation.id) {
swordModuleFound = true;
break;
try {
const NodeSwordInterface = require('node-sword-interface');
const nsi = new NodeSwordInterface();
const models = require('../models')(dbDir);

var localSwordModules = nsi.getAllLocalModules();
var dbModules = await models.BibleTranslation.findAndCountAll();

for (var dbTranslation of dbModules.rows) {
if (dbTranslation.hasStrongs) {
var swordModuleFound = false;

for (var i = 0; i < localSwordModules.length; i++) {
if (localSwordModules[i].name == dbTranslation.id) {
swordModuleFound = true;
break;
}
}
}

if (swordModuleFound) {
console.log("Re-synchronizing translation: " + dbTranslation.name);
if (swordModuleFound) {
console.log("Re-synchronizing translation: " + dbTranslation.name);

await models.Verse.destroy({
where: {
bibleTranslationId: dbTranslation.id
}
});
await models.Verse.destroy({
where: {
bibleTranslationId: dbTranslation.id
}
});

await models.BibleTranslation.importSwordTranslation(dbTranslation.id, models);
await models.BibleTranslation.importSwordTranslation(dbTranslation.id, models);
}
}
}
} catch (e) {

}
},

0 comments on commit 994eaef

Please sign in to comment.
You can’t perform that action at this time.