[db] Upgrade db schema to 21.0

Commit b3bfb0a and e1993bc change the triggers and calculation of id's in a way
that is not backwards compatible, so we need to make major schema upgrade.
This commit is contained in:
ejurgensen 2019-05-17 23:07:48 +02:00
parent e1993bc7b6
commit b3d6211371
2 changed files with 10 additions and 7 deletions

View File

@ -25,8 +25,8 @@
* version of the database? If yes, then it is a minor upgrade, if no, then it * version of the database? If yes, then it is a minor upgrade, if no, then it
* is a major upgrade. In other words minor version upgrades permit downgrading * is a major upgrade. In other words minor version upgrades permit downgrading
* forked-daapd after the database was upgraded. */ * forked-daapd after the database was upgraded. */
#define SCHEMA_VERSION_MAJOR 20 #define SCHEMA_VERSION_MAJOR 21
#define SCHEMA_VERSION_MINOR 02 #define SCHEMA_VERSION_MINOR 00
int int
db_init_indices(sqlite3 *hdl); db_init_indices(sqlite3 *hdl);

View File

@ -983,13 +983,16 @@ static const struct db_upgrade_query db_upgrade_v2001_queries[] =
{ U_V2001_SCVER_MINOR, "set schema_version_minor to 01" }, { U_V2001_SCVER_MINOR, "set schema_version_minor to 01" },
}; };
#define U_V2002_SCVER_MINOR \ #define U_V2100_SCVER_MAJOR \
"UPDATE admin SET value = '02' WHERE key = 'schema_version_minor';" "UPDATE admin SET value = '21' WHERE key = 'schema_version_major';"
#define U_V2100_SCVER_MINOR \
"UPDATE admin SET value = '00' WHERE key = 'schema_version_minor';"
// This upgrade just changes triggers (will be done automatically by db_drop...) // This upgrade just changes triggers (will be done automatically by db_drop...)
static const struct db_upgrade_query db_upgrade_v2002_queries[] = static const struct db_upgrade_query db_upgrade_v2100_queries[] =
{ {
{ U_V2002_SCVER_MINOR, "set schema_version_minor to 02" }, { U_V2100_SCVER_MAJOR, "set schema_version_major to 21" },
{ U_V2100_SCVER_MINOR, "set schema_version_minor to 00" },
}; };
@ -1136,7 +1139,7 @@ db_upgrade(sqlite3 *hdl, int db_ver)
/* FALLTHROUGH */ /* FALLTHROUGH */
case 2001: case 2001:
ret = db_generic_upgrade(hdl, db_upgrade_v2002_queries, ARRAY_SIZE(db_upgrade_v2002_queries)); ret = db_generic_upgrade(hdl, db_upgrade_v2100_queries, ARRAY_SIZE(db_upgrade_v2100_queries));
if (ret < 0) if (ret < 0)
return -1; return -1;