From b3d62113712affea0c782bbf6b10914a7694a31c Mon Sep 17 00:00:00 2001 From: ejurgensen Date: Fri, 17 May 2019 23:07:48 +0200 Subject: [PATCH] [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. --- src/db_init.h | 4 ++-- src/db_upgrade.c | 13 ++++++++----- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/src/db_init.h b/src/db_init.h index f1399aca..bdfe40a2 100644 --- a/src/db_init.h +++ b/src/db_init.h @@ -25,8 +25,8 @@ * 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 * forked-daapd after the database was upgraded. */ -#define SCHEMA_VERSION_MAJOR 20 -#define SCHEMA_VERSION_MINOR 02 +#define SCHEMA_VERSION_MAJOR 21 +#define SCHEMA_VERSION_MINOR 00 int db_init_indices(sqlite3 *hdl); diff --git a/src/db_upgrade.c b/src/db_upgrade.c index 962560a8..21664e7b 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -983,13 +983,16 @@ static const struct db_upgrade_query db_upgrade_v2001_queries[] = { U_V2001_SCVER_MINOR, "set schema_version_minor to 01" }, }; -#define U_V2002_SCVER_MINOR \ - "UPDATE admin SET value = '02' WHERE key = 'schema_version_minor';" +#define U_V2100_SCVER_MAJOR \ + "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...) -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 */ 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) return -1;