Made some UI states persistent across sessions, ref #484

This commit is contained in:
emeric
2024-09-12 14:01:03 +02:00
parent da22843272
commit c165ed9f2f
25 changed files with 486 additions and 101 deletions
+18 -1
View File
@@ -35,7 +35,7 @@ namespace lms::db
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 66 };
static constexpr Version LMS_DATABASE_VERSION{ 67 };
}
VersionInfo::VersionInfo()
@@ -744,6 +744,22 @@ SELECT
session.getDboSession()->execute("UPDATE scan_settings SET scan_version = scan_version + 1");
}
void migrateFromV66(Session& session)
{
// New way of handling UI settings
session.getDboSession()->execute(R"(CREATE TABLE IF NOT EXISTS "ui_state" (
"id" integer primary key autoincrement,
"version" integer not null,
"item" text not null,
"value" text not null,
"user_id" bigint,
constraint "fk_ui_state_user" foreign key ("user_id") references "user" ("id") on delete cascade deferrable initially deferred
))");
session.getDboSession()->execute("ALTER TABLE user DROP COLUMN repeat_all");
session.getDboSession()->execute("ALTER TABLE user DROP COLUMN radio");
}
bool doDbMigration(Session& session)
{
static const std::string outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
@@ -786,6 +802,7 @@ SELECT
{ 63, migrateFromV63 },
{ 64, migrateFromV64 },
{ 65, migrateFromV65 },
{ 66, migrateFromV66 },
};
bool migrationPerformed{};