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:
2022-09-07 19:04:05 +02:00
parent 307172762a
commit 0a7082ac0f

View File

@@ -10,6 +10,12 @@ const logger = new Console({
});
//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() {
const bandFiles = fs.readdirSync("./assets/import/bands").filter(file => file.endsWith(".json"));
@@ -77,10 +83,11 @@ async function importCharacters() {
}
logger.log("Importing...");
dbUtil.syncDb();
db = dbUtil.getDb();
importBands();
importCharacters();
runImport().then(() => {
logger.log("Import complete");
process.exit(0);
}).catch((err) => {
logger.error(err);
process.exit(1);
});