diff --git a/src/db_init.c b/src/db_init.c index 73dd8b27..e1b62bea 100644 --- a/src/db_init.c +++ b/src/db_init.c @@ -114,7 +114,8 @@ " parent_id INTEGER DEFAULT 0," \ " directory_id INTEGER DEFAULT 0," \ " query_order VARCHAR(1024)," \ - " query_limit INTEGER DEFAULT -1" \ + " query_limit INTEGER DEFAULT -1," \ + " media_kind INTEGER DEFAULT 1" \ ");" #define T_PLITEMS \ diff --git a/src/db_init.h b/src/db_init.h index c0e1f965..8c9c0996 100644 --- a/src/db_init.h +++ b/src/db_init.h @@ -26,7 +26,7 @@ * is a major upgrade. In other words minor version upgrades permit downgrading * forked-daapd after the database was upgraded. */ #define SCHEMA_VERSION_MAJOR 21 -#define SCHEMA_VERSION_MINOR 01 +#define SCHEMA_VERSION_MINOR 02 int db_init_indices(sqlite3 *hdl); diff --git a/src/db_upgrade.c b/src/db_upgrade.c index fc12a402..9981a151 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -1020,6 +1020,22 @@ static const struct db_upgrade_query db_upgrade_v2101_queries[] = { U_v2101_SCVER_MINOR, "set schema_version_minor to 01" }, }; +// This column added because Apple Music makes a DAAP request for playlists +// that has a query condition on extended-media-kind. We set the default value +// to 1 to signify music. +#define U_v2102_ALTER_PLAYLISTS_ADD_MEDIA_KIND \ + "ALTER TABLE playlists ADD COLUMN media_kind INTEGER DEFAULT 1;" + +#define U_v2102_SCVER_MINOR \ + "UPDATE admin SET value = '02' WHERE key = 'schema_version_minor';" + +static const struct db_upgrade_query db_upgrade_v2102_queries[] = + { + { U_v2102_ALTER_PLAYLISTS_ADD_MEDIA_KIND, "alter table playlists add column media_kind" }, + + { U_v2102_SCVER_MINOR, "set schema_version_minor to 02" }, + }; + int db_upgrade(sqlite3 *hdl, int db_ver) @@ -1175,6 +1191,12 @@ db_upgrade(sqlite3 *hdl, int db_ver) if (ret < 0) return -1; + /* FALLTHROUGH */ + + case 2101: + ret = db_generic_upgrade(hdl, db_upgrade_v2102_queries, ARRAY_SIZE(db_upgrade_v2102_queries)); + if (ret < 0) + return -1; break; default: