Handle database upgrade v8 -> v9
This commit is contained in:
parent
19b6780a3c
commit
4996965b34
30
src/db.c
30
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:
|
||||
|
|
Loading…
Reference in New Issue