"use strict";var g=Object.defineProperty;var n=(t,e)=>g(t,"name",{value:e,configurable:true});const{convertToJSON:u}=require("../../jsUtils");const{ferdiumVersion:i}=require("../../environment-remote");const r=use("Database");const o=use("App/Models/User");const s=n(t=>{console.log("\x1B[36m%s\x1B[0m","Ferdium Migration:","\x1B[0m",t)},"migrateLog");module.exports=async()=>{s("\u{1F9D9}\u200D  Running database migration wizard");await r.raw("CREATE TABLE IF NOT EXISTS `users` (`id` integer not null primary key autoincrement, `settings` text, `created_at` datetime, `updated_at` datetime);");const t=await o.find(1);let e;if(t){e=u(t.settings)}else{s("\u{1F3A9}  Migrating from old Ferdium version as user doesn't exist");await r.raw(`INSERT INTO  "users" ("id") VALUES ('1');`)}if(!e||!e.db_version||e.db_version!==i){const d=e?.db_version||"5.4.0-beta.2";s(`\u{1F52E}  Migrating table from ${d} to ${i}`);if(!e)e={};e.db_version=i;const a=await o.find(1);a.settings=JSON.stringify(e);await a.save()}else{s("\u{1F527}  Nothing to migrate, already on the newest version")}};
