Added release_group_mbid field to listenbrainz, fixes #416

This commit is contained in:
emeric
2024-03-02 23:47:23 +01:00
parent 9cccf33f05
commit ba180ea847
8 changed files with 30 additions and 6 deletions
+10 -1
View File
@@ -32,7 +32,7 @@ namespace Database
{
namespace
{
static constexpr Version LMS_DATABASE_VERSION{ 53 };
static constexpr Version LMS_DATABASE_VERSION{ 54 };
}
VersionInfo::VersionInfo()
@@ -419,6 +419,14 @@ SELECT
session.getDboSession().execute("UPDATE scan_settings SET scan_version = scan_version + 1");
}
void migrateFromV53(Session& session)
{
// Add release group mbid
session.getDboSession().execute("ALTER TABLE release ADD group_mbid TEXT NOT NULL DEFAULT ''");
// Just increment the scan version of the settings to make the next scheduled scan rescan everything
session.getDboSession().execute("UPDATE scan_settings SET scan_version = scan_version + 1");
}
void doDbMigration(Session& session)
{
@@ -450,6 +458,7 @@ SELECT
{50, migrateFromV50},
{51, migrateFromV51},
{52, migrateFromV52},
{53, migrateFromV53},
};
{
@@ -146,6 +146,7 @@ namespace Database
std::string_view getName() const { return _name; }
std::string_view getSortName() const { return _sortName; }
std::optional<UUID> getMBID() const { return UUID::fromString(_MBID); }
std::optional<UUID> getGroupMBID() const { return UUID::fromString(_groupMBID); }
std::optional<std::size_t> getTotalDisc() const { return _totalDisc; }
std::size_t getDiscCount() const; // may not be total disc (if incomplete for example)
std::vector<DiscInfo> getDiscs() const;
@@ -160,6 +161,7 @@ namespace Database
void setName(std::string_view name) { _name = name; }
void setSortName(std::string_view sortName) { _sortName = sortName; }
void setMBID(const std::optional<UUID>& mbid) { _MBID = mbid ? mbid->getAsString() : ""; }
void setGroupMBID(const std::optional<UUID>& mbid) { _groupMBID = mbid ? mbid->getAsString() : ""; }
void setTotalDisc(std::optional<int> totalDisc) { _totalDisc = totalDisc; }
void setArtistDisplayName(std::string_view name) { _artistDisplayName = name; }
void clearReleaseTypes();
@@ -177,6 +179,7 @@ namespace Database
Wt::Dbo::field(a, _name, "name");
Wt::Dbo::field(a, _sortName, "sort_name");
Wt::Dbo::field(a, _MBID, "mbid");
Wt::Dbo::field(a, _groupMBID, "group_mbid");
Wt::Dbo::field(a, _totalDisc, "total_disc");
Wt::Dbo::field(a, _artistDisplayName, "artist_display_name");
Wt::Dbo::hasMany(a, _tracks, Wt::Dbo::ManyToOne, "release");
@@ -196,6 +199,7 @@ namespace Database
std::string _name;
std::string _sortName;
std::string _MBID;
std::string _groupMBID;
std::optional<int> _totalDisc{};
std::string _artistDisplayName;