mirror of
https://github.com/Tzahi12345/YoutubeDL-Material.git
synced 2026-03-26 06:30:58 +03:00
Added migration from old to new DB system
This commit is contained in:
@@ -220,6 +220,17 @@ async function checkMigrations() {
|
||||
else { logger.error('Migration failed: 4.1->4.2+'); }
|
||||
}
|
||||
|
||||
const new_db_system_migration_complete = db.get('new_db_system_migration_complete').value();
|
||||
if (!new_db_system_migration_complete) {
|
||||
logger.info('Beginning migration: 4.2->4.3+')
|
||||
let success = await db_api.importJSONToDB(db.value(), users_db.value());
|
||||
|
||||
// sets migration to complete
|
||||
db.set('new_db_system_migration_complete', true).write();
|
||||
if (success) { logger.info('4.2->4.3+ migration complete!'); }
|
||||
else { logger.error('Migration failed: 4.2->4.3+'); }
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -862,7 +862,8 @@ exports.generateJSONTables = async (db_json, users_json) => {
|
||||
}
|
||||
|
||||
exports.importJSONToDB = async (db_json, users_json) => {
|
||||
// TODO: backup db
|
||||
await fs.writeFile(`appdata/db.json.${Date.now()/1000}.bak`, db_json);
|
||||
await fs.writeFile(`appdata/users_db.json.${Date.now()/1000}.bak`, users_json);
|
||||
|
||||
// TODO: delete current records
|
||||
const tables_obj = await exports.generateJSONTables(db_json, users_json);
|
||||
|
||||
Reference in New Issue
Block a user