From 0e9a8674d97b8cc3712a983035c7790afa895b92 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Sat, 6 Mar 2010 17:29:10 +0100 Subject: [PATCH] Handle database upgrade v6 -> v7 --- src/db.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/db.c b/src/db.c index e5f7381d..9c188f68 100644 --- a/src/db.c +++ b/src/db.c @@ -3435,6 +3435,24 @@ static struct db_init_query db_upgrade_v6_queries[] = { U_V6_SCVER, "set schema_version to 6" }, }; +/* Upgrade from schema v6 to v7 */ + +#define U_V7_FILES \ + "ALTER TABLE files ADD COLUMN songalbumid INTEGER NOT NULL DEFAULT 0;" + +#define U_V7_RESCAN \ + "UPDATE files SET db_timestamp = 1;" + +#define U_V7_SCVER \ + "UPDATE admin SET value = '7' WHERE key = 'schema_version';" + +static struct db_init_query db_upgrade_v7_queries[] = + { + { U_V7_FILES, "upgrade table files" }, + { U_V7_RESCAN, "force library rescan" }, + { U_V7_SCVER, "set schema_version to 7" }, + }; + static int db_check_version(void) { @@ -3506,6 +3524,13 @@ db_check_version(void) if (ret < 0) return -1; + /* FALLTHROUGH */ + + case 6: + ret = db_generic_upgrade(db_upgrade_v7_queries, sizeof(db_upgrade_v7_queries) / sizeof(db_upgrade_v7_queries[0])); + if (ret < 0) + return -1; + break; default: