Remove database upgrade for schema version before 10 (v0.12)

This commit is contained in:
Julien BLACHE 2011-03-15 21:24:39 +01:00
parent cb9dc5ad7c
commit 9759eeba71

269
src/db.c
View File

@ -3973,204 +3973,6 @@ db_generic_upgrade(const struct db_init_query *queries, int nqueries)
}
/* Upgrade from schema v1 to v2 */
#define U_V2_FILES \
"ALTER TABLE files ADD COLUMN media_kind INTEGER NOT NULL DEFAULT 0;" \
"ALTER TABLE files ADD COLUMN tv_series_name VARCHAR(1024) DEFAULT NULL;" \
"ALTER TABLE files ADD COLUMN tv_episode_num_str VARCHAR(1024) DEFAULT NULL;" \
"ALTER TABLE files ADD COLUMN tv_network_name VARCHAR(1024) DEFAULT NULL;" \
"ALTER TABLE files ADD COLUMN tv_episode_sort INTEGER NOT NULL DEFAULT 0;" \
"ALTER TABLE files ADD COLUMN tv_season_num INTEGER NOT NULL DEFAULT 0;"
#define U_V2_RESCAN \
"UPDATE files SET db_timestamp = 1;"
#define U_V2_SCVER \
"UPDATE admin SET value = '2' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v2_queries[] =
{
{ U_V2_FILES, "upgrade table files" },
{ U_V2_RESCAN, "force library rescan" },
{ U_V2_SCVER, "set schema_version to 2" },
};
/* Upgrade from schema v2 to v3 */
#define U_V3_FILES \
"UPDATE files SET album_artist = COALESCE(artist, '') WHERE album_artist IS NULL;"
#define U_V3_SCVER \
"UPDATE admin SET value = '3' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v3_queries[] =
{
{ U_V3_FILES, "upgrade table files" },
{ U_V3_SCVER, "set schema_version to 3" },
};
/* Upgrade from schema v3 to v4 */
#define U_V4_PLAYLISTS \
"ALTER TABLE playlists ADD COLUMN special_id INTEGER NOT NULL DEFAULT 0;"
#define U_V4_PL1 \
"UPDATE playlists SET query = '1 = 1' WHERE id = 1;"
#define U_V4_PL2 \
"INSERT INTO playlists (title, type, query, db_timestamp, path, idx, special_id)" \
" VALUES('Music', 1, 'media_kind = 1', 0, '', 0, 6);"
#define U_V4_PL3 \
"INSERT INTO playlists (title, type, query, db_timestamp, path, idx, special_id)" \
" VALUES('Movies', 1, 'media_kind = 32', 0, '', 0, 4);"
#define U_V4_PL4 \
"INSERT INTO playlists (title, type, query, db_timestamp, path, idx, special_id)" \
" VALUES('TV Shows', 1, 'media_kind = 64', 0, '', 0, 5);"
#define U_V4_SCVER \
"UPDATE admin SET value = '4' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v4_queries[] =
{
{ U_V4_PLAYLISTS, "upgrade table playlists" },
{ U_V4_PL1, "update playlist 1" },
{ U_V4_PL2, "add smart playlist 'Music'" },
{ U_V4_PL3, "add smart playlist 'Movies'" },
{ U_V4_PL4, "add smart playlist 'TV Shows'" },
{ U_V4_SCVER, "set schema_version to 4" },
};
/* Upgrade from schema v4 to v5 */
#define U_V5_FIXPL \
"UPDATE playlists SET query = 'media_kind = 2' WHERE title = 'Movies' and type = 1;"
#define U_V5_RESCAN \
"UPDATE files SET db_timestamp = 1;"
#define U_V5_SCVER \
"UPDATE admin SET value = '5' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v5_queries[] =
{
{ U_V5_FIXPL, "fix 'Movies' smart playlist" },
{ U_V5_RESCAN, "force library rescan" },
{ U_V5_SCVER, "set schema_version to 5" },
};
/* Upgrade from schema v5 to v6 */
#define U_V6_PAIRINGS \
"CREATE TABLE IF NOT EXISTS pairings(" \
" remote VARCHAR(64) PRIMARY KEY NOT NULL," \
" name VARCHAR(255) NOT NULL," \
" guid VARCHAR(16) NOT NULL" \
");"
#define U_V6_PAIRINGGUID \
"CREATE INDEX IF NOT EXISTS idx_pairingguid ON pairings(guid);"
#define U_V6_SCVER \
"UPDATE admin SET value = '6' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v6_queries[] =
{
{ U_V6_PAIRINGS, "create pairings table" },
{ U_V6_PAIRINGGUID, "create pairing guid index" },
{ 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 const 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" },
};
/* Upgrade from schema v7 to v8 */
#define U_V8_GROUPS \
"CREATE TABLE IF NOT EXISTS groups (" \
" id INTEGER PRIMARY KEY NOT NULL," \
" type INTEGER NOT NULL," \
" name VARCHAR(1024) NOT NULL," \
" persistentid INTEGER NOT NULL," \
"CONSTRAINT groups_type_unique_persistentid UNIQUE (type, persistentid)" \
");"
#define U_V8_TRG1 \
"CREATE TRIGGER update_groups_new_file AFTER INSERT ON files FOR EACH ROW" \
" BEGIN" \
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \
" END;"
#define U_V8_TRG2 \
"CREATE TRIGGER update_groups_update_file AFTER UPDATE OF songalbumid ON files FOR EACH ROW" \
" BEGIN" \
" INSERT OR IGNORE INTO groups (type, name, persistentid) VALUES (1, NEW.album, NEW.songalbumid);" \
" END;"
#define U_V8_SCVER \
"UPDATE admin SET value = '8' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v8_queries[] =
{
{ U_V8_GROUPS, "create groups table" },
{ U_V8_TRG1, "create trigger update_groups_new_file" },
{ U_V8_TRG2, "create trigger update_groups_update_file" },
{ 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 const 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" },
};
/* Upgrade from schema v9 to v10 */
#define U_V10_PLVOL \
"INSERT INTO admin (key, value) VALUES ('player:volume', '75');"
#define U_V10_SCVER \
"UPDATE admin SET value = '10' WHERE key = 'schema_version';"
static const struct db_init_query db_upgrade_v10_queries[] =
{
{ U_V10_PLVOL, "store player start volume" },
{ U_V10_SCVER, "set schema_version to 10" },
};
/* Upgrade from schema v10 to v11 */
#define U_V11_SPEAKERS \
@ -4381,75 +4183,18 @@ db_check_version(void)
sqlite3_finalize(stmt);
if (cur_ver < SCHEMA_VERSION)
if (cur_ver < 10)
{
DPRINTF(E_FATAL, L_DB, "Database schema v%d too old, cannot upgrade\n", cur_ver);
return -1;
}
else if (cur_ver < SCHEMA_VERSION)
{
DPRINTF(E_LOG, L_DB, "Database schema outdated, schema upgrade needed v%d -> v%d\n", cur_ver, SCHEMA_VERSION);
switch (cur_ver)
{
case 1:
ret = db_generic_upgrade(db_upgrade_v2_queries, sizeof(db_upgrade_v2_queries) / sizeof(db_upgrade_v2_queries[0]));
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 2:
ret = db_generic_upgrade(db_upgrade_v3_queries, sizeof(db_upgrade_v3_queries) / sizeof(db_upgrade_v3_queries[0]));
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 3:
ret = db_generic_upgrade(db_upgrade_v4_queries, sizeof(db_upgrade_v4_queries) / sizeof(db_upgrade_v4_queries[0]));
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 4:
ret = db_generic_upgrade(db_upgrade_v5_queries, sizeof(db_upgrade_v5_queries) / sizeof(db_upgrade_v5_queries[0]));
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 5:
ret = db_generic_upgrade(db_upgrade_v6_queries, sizeof(db_upgrade_v6_queries) / sizeof(db_upgrade_v6_queries[0]));
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;
/* FALLTHROUGH */
case 7:
ret = db_generic_upgrade(db_upgrade_v8_queries, sizeof(db_upgrade_v8_queries) / sizeof(db_upgrade_v8_queries[0]));
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;
/* FALLTHROUGH */
case 9:
ret = db_generic_upgrade(db_upgrade_v10_queries, sizeof(db_upgrade_v10_queries) / sizeof(db_upgrade_v10_queries[0]));
if (ret < 0)
return -1;
/* FALLTHROUGH */
case 10:
ret = db_generic_upgrade(db_upgrade_v11_queries, sizeof(db_upgrade_v11_queries) / sizeof(db_upgrade_v11_queries[0]));
if (ret < 0)