From c08993e20bd471135a49bd53a811a7ff95fe5b74 Mon Sep 17 00:00:00 2001 From: Isaac Abadi Date: Thu, 24 Dec 2020 02:02:05 -0500 Subject: [PATCH] Old database files are now backed up prior to migration to simplified structure --- backend/app.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/app.js b/backend/app.js index 8c032c4..8730f36 100644 --- a/backend/app.js +++ b/backend/app.js @@ -260,6 +260,13 @@ async function runFilesToDBMigration() { } async function simplifyDBFileStructure() { + // back up db files + const old_db_file = fs.readJSONSync('./appdata/db.json'); + const old_users_db_file = fs.readJSONSync('./appdata/users.json'); + fs.writeJSONSync('appdata/db.old.json', old_db_file); + fs.writeJSONSync('appdata/users.old.json', old_users_db_file); + + // simplify let users = users_db.get('users').value(); for (let i = 0; i < users.length; i++) { const user = users[i];