From 8600c21424c3449d2a144a79f1d560933db43e64 Mon Sep 17 00:00:00 2001 From: chme Date: Fri, 29 Jan 2016 19:46:56 +0100 Subject: [PATCH] [db-upgrade] add column date_released to files table, add column name to speakers table --- src/db.c | 8 ++++++-- src/db.h | 2 ++ src/db_upgrade.c | 6 ++++++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/db.c b/src/db.c index af70b69d..cf8a321c 100644 --- a/src/db.c +++ b/src/db.c @@ -138,6 +138,7 @@ static const struct col_type_map mfi_cols_map[] = { mfi_offsetof(album_artist_sort), DB_TYPE_STRING }, { mfi_offsetof(virtual_path), DB_TYPE_STRING }, { mfi_offsetof(directory_id), DB_TYPE_INT }, + { mfi_offsetof(date_released), DB_TYPE_INT }, }; /* This list must be kept in sync with @@ -227,6 +228,7 @@ static const ssize_t dbmfi_cols_map[] = dbmfi_offsetof(album_artist_sort), dbmfi_offsetof(virtual_path), dbmfi_offsetof(directory_id), + dbmfi_offsetof(date_released), }; /* This list must be kept in sync with @@ -4850,7 +4852,8 @@ db_perthread_deinit(void) " composer_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " album_artist_sort VARCHAR(1024) DEFAULT NULL COLLATE DAAP," \ " virtual_path VARCHAR(4096) DEFAULT NULL," \ - " directory_id INTEGER DEFAULT 0" \ + " directory_id INTEGER DEFAULT 0," \ + " date_released INTEGER DEFAULT 0" \ ");" #define T_PL \ @@ -4896,7 +4899,8 @@ db_perthread_deinit(void) "CREATE TABLE IF NOT EXISTS speakers(" \ " id INTEGER PRIMARY KEY NOT NULL," \ " selected INTEGER NOT NULL," \ - " volume INTEGER NOT NULL" \ + " volume INTEGER NOT NULL," \ + " name VARCHAR(255) DEFAULT NULL" \ ");" #define T_INOTIFY \ diff --git a/src/db.h b/src/db.h index 166d9840..1429c781 100644 --- a/src/db.h +++ b/src/db.h @@ -184,6 +184,7 @@ struct media_file_info { char *virtual_path; uint32_t directory_id; /* Id of directory */ + uint32_t date_released; }; #define mfi_offsetof(field) offsetof(struct media_file_info, field) @@ -321,6 +322,7 @@ struct db_media_file_info { char *album_artist_sort; char *virtual_path; char *directory_id; + char *date_released; }; #define dbmfi_offsetof(field) offsetof(struct db_media_file_info, field) diff --git a/src/db_upgrade.c b/src/db_upgrade.c index db5c66d8..b0d5c8f7 100644 --- a/src/db_upgrade.c +++ b/src/db_upgrade.c @@ -1186,6 +1186,10 @@ static const struct db_upgrade_query db_upgrade_v1801_queries[] = "ALTER TABLE playlists ADD COLUMN directory_id INTEGER DEFAULT 0;" #define U_V1900_ALTER_FILES_ADD_DIRECTORYID \ "ALTER TABLE files ADD COLUMN directory_id INTEGER DEFAULT 0;" +#define U_V1900_ALTER_FILES_ADD_DATERELEASED \ + "ALTER TABLE files ADD COLUMN date_released INTEGER DEFAULT 0;" +#define U_V1900_ALTER_SPEAKERS_ADD_NAME \ + "ALTER TABLE speakers ADD COLUMN name VARCHAR(255) DEFAULT NULL;" #define U_V1900_INSERT_DIR1 \ "INSERT INTO directories (id, virtual_path, db_timestamp, disabled, parent_id)" \ @@ -1210,6 +1214,8 @@ static const struct db_upgrade_query db_upgrade_v1900_queries[] = { U_V1900_CREATE_TABLE_DIRECTORIES, "create table directories" }, { U_V1900_ALTER_PL_ADD_DIRECTORYID, "alter table pl add column directory_id" }, { U_V1900_ALTER_FILES_ADD_DIRECTORYID, "alter table files add column directory_id" }, + { U_V1900_ALTER_FILES_ADD_DATERELEASED,"alter table files add column date_released" }, + { U_V1900_ALTER_SPEAKERS_ADD_NAME, "alter table speakers add column name" }, { U_V1900_INSERT_DIR1, "insert root directory" }, { U_V1900_INSERT_DIR2, "insert /file: directory" }, { U_V1900_INSERT_DIR3, "insert /htttp: directory" },