From 4996965b3482c338229482bacdf829afd7170c87 Mon Sep 17 00:00:00 2001 From: Julien BLACHE Date: Fri, 19 Mar 2010 19:14:34 +0100 Subject: [PATCH] Handle database upgrade v8 -> v9 --- src/db.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/db.c b/src/db.c index 598a5ff4..5d37e8f6 100644 --- a/src/db.c +++ b/src/db.c @@ -3743,6 +3743,7 @@ static struct db_init_query db_upgrade_v7_queries[] = }; /* Upgrade from schema v7 to v8 */ + #define U_V8_GROUPS \ "CREATE TABLE IF NOT EXISTS groups (" \ " id INTEGER PRIMARY KEY NOT NULL," \ @@ -3775,6 +3776,28 @@ static struct db_init_query db_upgrade_v8_queries[] = { U_V8_SCVER, "set schema_version to 8" }, }; +/* Upgrade from schema v8 to v9 */ + +#define U_V9_INOTIFY1 \ + "DROP TABLE inotify;" + +#define U_V9_INOTIFY2 \ + "CREATE TABLE inotify (" \ + " wd INTEGER PRIMARY KEY NOT NULL," \ + " cookie INTEGER NOT NULL," \ + " path VARCHAR(4096) NOT NULL" \ + ");" + +#define U_V9_SCVER \ + "UPDATE admin SET value = '9' WHERE key = 'schema_version';" + +static struct db_init_query db_upgrade_v9_queries[] = + { + { U_V9_INOTIFY1, "drop table inotify" }, + { U_V9_INOTIFY2, "create new table inotify" }, + { U_V9_SCVER, "set schema_version to 9" }, + }; + static int db_check_version(void) { @@ -3860,6 +3883,13 @@ db_check_version(void) if (ret < 0) return -1; + /* FALLTHROUGH */ + + case 8: + ret = db_generic_upgrade(db_upgrade_v9_queries, sizeof(db_upgrade_v9_queries) / sizeof(db_upgrade_v9_queries[0])); + if (ret < 0) + return -1; + break; default: