Import: Fix out of order import
Characters are only imported after Bands have finished. This fixes foreigh key contrains failing due to missing bands. Fixes #6
This commit is contained in:
19
import.js
19
import.js
@@ -10,6 +10,12 @@ const logger = new Console({
|
|||||||
});
|
});
|
||||||
|
|
||||||
//TODO: Fix ./data folders permission so wen can move out dataset in there
|
//TODO: Fix ./data folders permission so wen can move out dataset in there
|
||||||
|
async function runImport() {
|
||||||
|
dbUtil.syncDb();
|
||||||
|
db = dbUtil.getDb();
|
||||||
|
await importBands();
|
||||||
|
await importCharacters();
|
||||||
|
}
|
||||||
|
|
||||||
async function importBands() {
|
async function importBands() {
|
||||||
const bandFiles = fs.readdirSync("./assets/import/bands").filter(file => file.endsWith(".json"));
|
const bandFiles = fs.readdirSync("./assets/import/bands").filter(file => file.endsWith(".json"));
|
||||||
@@ -77,10 +83,11 @@ async function importCharacters() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
logger.log("Importing...");
|
logger.log("Importing...");
|
||||||
dbUtil.syncDb();
|
runImport().then(() => {
|
||||||
db = dbUtil.getDb();
|
logger.log("Import complete");
|
||||||
importBands();
|
process.exit(0);
|
||||||
importCharacters();
|
}).catch((err) => {
|
||||||
logger.log("Import complete");
|
logger.error(err);
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user