[db] Upgrade db to v20.00
- New table 'queue' for persisting the queue/current playlist - New entry 'plversion' in admin table for queue version
This commit is contained in:
parent
faaeb92ce5
commit
0beb68e1f1
|
@ -158,6 +158,32 @@
|
|||
" parent_id INTEGER DEFAULT 0" \
|
||||
");"
|
||||
|
||||
#define T_QUEUE \
|
||||
"CREATE TABLE IF NOT EXISTS queue (" \
|
||||
" id INTEGER PRIMARY KEY NOT NULL," \
|
||||
" file_id INTEGER NOT NULL," \
|
||||
" pos INTEGER NOT NULL," \
|
||||
" shuffle_pos INTEGER NOT NULL," \
|
||||
" data_kind INTEGER NOT NULL," \
|
||||
" media_kind INTEGER NOT NULL," \
|
||||
" song_length INTEGER NOT NULL," \
|
||||
" path VARCHAR(4096) NOT NULL," \
|
||||
" virtual_path VARCHAR(4096) NOT NULL," \
|
||||
" title VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" artist VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_artist VARCHAR(1024) NOT NULL COLLATE DAAP," \
|
||||
" album VARCHAR(1024) NOT NULL COLLATE DAAP," \
|
||||
" genre VARCHAR(255) DEFAULT NULL COLLATE DAAP," \
|
||||
" songalbumid INTEGER NOT NULL," \
|
||||
" time_modified INTEGER DEFAULT 0," \
|
||||
" artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" year INTEGER DEFAULT 0," \
|
||||
" track INTEGER DEFAULT 0," \
|
||||
" disc INTEGER DEFAULT 0" \
|
||||
");"
|
||||
|
||||
#define TRG_GROUPS_INSERT_FILES \
|
||||
"CREATE TRIGGER update_groups_new_file AFTER INSERT ON files FOR EACH ROW" \
|
||||
" BEGIN" \
|
||||
|
@ -237,6 +263,7 @@ static const struct db_init_query db_init_table_queries[] =
|
|||
{ T_SPEAKERS, "create table speakers" },
|
||||
{ T_INOTIFY, "create table inotify" },
|
||||
{ T_DIRECTORIES, "create table directories" },
|
||||
{ T_QUEUE, "create table queue" },
|
||||
|
||||
{ TRG_GROUPS_INSERT_FILES, "create trigger update_groups_new_file" },
|
||||
{ TRG_GROUPS_UPDATE_FILES, "create trigger update_groups_update_file" },
|
||||
|
@ -327,6 +354,12 @@ static const struct db_init_query db_init_table_queries[] =
|
|||
#define I_DIR_PARENT \
|
||||
"CREATE INDEX IF NOT EXISTS idx_dir_parentid ON directories(parent_id);"
|
||||
|
||||
#define I_QUEUE_POS \
|
||||
"CREATE INDEX IF NOT EXISTS idx_queue_pos ON queue(pos);"
|
||||
|
||||
#define I_QUEUE_SHUFFLEPOS \
|
||||
"CREATE INDEX IF NOT EXISTS idx_queue_shufflepos ON queue(shuffle_pos);"
|
||||
|
||||
static const struct db_init_query db_init_index_queries[] =
|
||||
{
|
||||
{ I_RESCAN, "create rescan index" },
|
||||
|
@ -357,6 +390,9 @@ static const struct db_init_query db_init_index_queries[] =
|
|||
|
||||
{ I_DIR_VPATH, "create directories disabled_virtualpath index" },
|
||||
{ I_DIR_PARENT, "create directories parentid index" },
|
||||
|
||||
{ I_QUEUE_POS, "create queue pos index" },
|
||||
{ I_QUEUE_SHUFFLEPOS, "create queue shuffle pos index" },
|
||||
};
|
||||
|
||||
int
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* 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 19
|
||||
#define SCHEMA_VERSION_MAJOR 20
|
||||
#define SCHEMA_VERSION_MINOR 00
|
||||
|
||||
int
|
||||
|
|
|
@ -1441,6 +1441,54 @@ db_upgrade_v19(sqlite3 *hdl)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* Upgrade from schema v19.00 to v20.00 */
|
||||
/* Create new table queue for persistent playqueue
|
||||
*/
|
||||
|
||||
#define U_V2000_CREATE_TABLE_QUEUE \
|
||||
"CREATE TABLE IF NOT EXISTS queue (" \
|
||||
" id INTEGER PRIMARY KEY NOT NULL," \
|
||||
" file_id INTEGER NOT NULL," \
|
||||
" pos INTEGER NOT NULL," \
|
||||
" shuffle_pos INTEGER NOT NULL," \
|
||||
" data_kind INTEGER NOT NULL," \
|
||||
" media_kind INTEGER NOT NULL," \
|
||||
" song_length INTEGER NOT NULL," \
|
||||
" path VARCHAR(4096) NOT NULL," \
|
||||
" virtual_path VARCHAR(4096) NOT NULL," \
|
||||
" title VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" artist VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_artist VARCHAR(1024) NOT NULL COLLATE DAAP," \
|
||||
" album VARCHAR(1024) NOT NULL COLLATE DAAP," \
|
||||
" genre VARCHAR(255) DEFAULT NULL COLLATE DAAP," \
|
||||
" songalbumid INTEGER NOT NULL," \
|
||||
" time_modified INTEGER DEFAULT 0," \
|
||||
" artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" album_artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \
|
||||
" year INTEGER DEFAULT 0," \
|
||||
" track INTEGER DEFAULT 0," \
|
||||
" disc INTEGER DEFAULT 0" \
|
||||
");"
|
||||
|
||||
#define U_V2000_PLVERSION \
|
||||
"INSERT INTO admin (key, value) VALUES ('plversion', '0');"
|
||||
|
||||
#define U_V2000_SCVER_MAJOR \
|
||||
"UPDATE admin SET value = '20' WHERE key = 'schema_version_major';"
|
||||
#define U_V2000_SCVER_MINOR \
|
||||
"UPDATE admin SET value = '00' WHERE key = 'schema_version_minor';"
|
||||
|
||||
static const struct db_upgrade_query db_upgrade_v2000_queries[] =
|
||||
{
|
||||
{ U_V2000_CREATE_TABLE_QUEUE, "create table directories" },
|
||||
{ U_V2000_PLVERSION, "insert plversion" },
|
||||
|
||||
{ U_V2000_SCVER_MAJOR, "set schema_version_major to 20" },
|
||||
{ U_V2000_SCVER_MINOR, "set schema_version_minor to 00" },
|
||||
};
|
||||
|
||||
|
||||
int
|
||||
db_upgrade(sqlite3 *hdl, int db_ver)
|
||||
{
|
||||
|
@ -1551,6 +1599,13 @@ db_upgrade(sqlite3 *hdl, int db_ver)
|
|||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
/* FALLTHROUGH */
|
||||
|
||||
case 1900:
|
||||
ret = db_generic_upgrade(hdl, db_upgrade_v2000_queries, sizeof(db_upgrade_v2000_queries) / sizeof(db_upgrade_v2000_queries[0]));
|
||||
if (ret < 0)
|
||||
return -1;
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
Loading…
Reference in New Issue