Added release country support

This commit is contained in:
emeric
2025-02-08 15:29:57 +01:00
parent 4cb6a70d2b
commit bebe384376
14 changed files with 300 additions and 10 deletions
+26 -1
View File
@@ -35,7 +35,7 @@ namespace lms::db
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 81 };
static constexpr Version LMS_DATABASE_VERSION{ 82 };
}
VersionInfo::VersionInfo()
@@ -1072,6 +1072,30 @@ FROM tracklist)");
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET scan_version = scan_version + 1");
}
void migrateFromV81(Session& session)
{
// Add country + release country
utils::executeCommand(*session.getDboSession(), R"(CREATE TABLE IF NOT EXISTS "country" (
"id" integer primary key autoincrement,
"version" integer not null,
"name" text not null
))");
utils::executeCommand(*session.getDboSession(), R"(CREATE TABLE IF NOT EXISTS "release_country" (
"country_id" bigint,
"release_id" bigint,
primary key ("country_id", "release_id"),
constraint "fk_release_country_key1" foreign key ("country_id") references "country" ("id") on delete cascade deferrable initially deferred,
constraint "fk_release_country_key2" foreign key ("release_id") references "release" ("id") on delete cascade deferrable initially deferred
))");
utils::executeCommand(*session.getDboSession(), R"(CREATE INDEX "release_country_country" on "release_country" ("country_id"))");
utils::executeCommand(*session.getDboSession(), R"(CREATE INDEX "release_country_release" on "release_country" ("release_id"))");
// Just increment the scan version of the settings to make the next scan rescan everything
utils::executeCommand(*session.getDboSession(), "UPDATE scan_settings SET scan_version = scan_version + 1");
}
bool doDbMigration(Session& session)
{
constexpr std::string_view outdatedMsg{ "Outdated database, please rebuild it (delete the .db file and restart)" };
@@ -1129,6 +1153,7 @@ FROM tracklist)");
{ 78, migrateFromV78 },
{ 79, migrateFromV79 },
{ 80, migrateFromV80 },
{ 81, migrateFromV81 },
};
bool migrationPerformed{};