mirror of
https://github.com/owntone/owntone-server.git
synced 2025-11-25 20:16:14 -05:00
[db] Recreate v20 files table, so that new constraints take effect if upgrading
The constraints on songalbumid and songartistid where changed with v20, so we need to make sure they take effect when upgrading. This commit tries to do the table recreation like sqlite recommends and without manually crafted copy queries that are probably prone to errors. Since we are recreating anyway, this commit also reorders the columns slightly. It also includes auto-drop/recreation of triggers (should really have been its own commit) during upgrade, like is already done with indices.
This commit is contained in:
81
src/db.h
81
src/db.h
@@ -140,12 +140,16 @@ db_data_kind_label(enum data_kind data_kind);
|
||||
|
||||
/* Note that fields marked as integers in the metadata map in filescanner_ffmpeg must be uint32_t here */
|
||||
struct media_file_info {
|
||||
uint32_t id;
|
||||
|
||||
char *path;
|
||||
uint32_t index;
|
||||
char *virtual_path;
|
||||
char *fname;
|
||||
uint32_t directory_id; /* Id of directory */
|
||||
char *title;
|
||||
char *artist;
|
||||
char *album;
|
||||
char *album_artist;
|
||||
char *genre;
|
||||
char *comment;
|
||||
char *type; /* daap.songformat */
|
||||
@@ -160,6 +164,7 @@ struct media_file_info {
|
||||
uint32_t song_length;
|
||||
int64_t file_size;
|
||||
uint32_t year; /* TDRC */
|
||||
uint32_t date_released;
|
||||
|
||||
uint32_t track; /* TRCK */
|
||||
uint32_t total_tracks;
|
||||
@@ -167,44 +172,44 @@ struct media_file_info {
|
||||
uint32_t disc; /* TPOS */
|
||||
uint32_t total_discs;
|
||||
|
||||
uint32_t bpm; /* TBPM */
|
||||
uint32_t compilation;
|
||||
char artwork;
|
||||
uint32_t rating;
|
||||
|
||||
uint32_t play_count;
|
||||
uint32_t skip_count;
|
||||
uint32_t seek;
|
||||
|
||||
uint32_t data_kind; /* dmap.datakind (asdk) */
|
||||
uint32_t media_kind;
|
||||
uint32_t item_kind; /* song or movie */
|
||||
|
||||
char *description; /* daap.songdescription */
|
||||
|
||||
uint32_t db_timestamp;
|
||||
uint32_t time_added; /* FIXME: time_t */
|
||||
uint32_t time_modified;
|
||||
uint32_t time_played;
|
||||
|
||||
uint32_t play_count;
|
||||
uint32_t seek;
|
||||
uint32_t rating;
|
||||
uint32_t db_timestamp;
|
||||
uint32_t time_skipped;
|
||||
|
||||
uint32_t disabled;
|
||||
uint32_t bpm; /* TBPM */
|
||||
|
||||
uint32_t id;
|
||||
|
||||
char *description; /* daap.songdescription */
|
||||
uint64_t sample_count; //TODO [unused] sample count is never set and therefor always 0
|
||||
char *codectype; /* song.codectype, 4 chars max (32 bits) */
|
||||
|
||||
uint32_t item_kind; /* song or movie */
|
||||
uint32_t data_kind; /* dmap.datakind (asdk) */
|
||||
uint64_t sample_count; //TODO [unused] sample count is never set and therefor always 0
|
||||
uint32_t compilation;
|
||||
char artwork;
|
||||
uint32_t idx;
|
||||
|
||||
/* iTunes 5+ */
|
||||
uint32_t contentrating;
|
||||
uint32_t has_video; /* iTunes 6.0.2 */
|
||||
uint32_t contentrating;/* iTunes 5+ */
|
||||
|
||||
/* iTunes 6.0.2 */
|
||||
uint32_t has_video;
|
||||
uint32_t bits_per_sample;
|
||||
|
||||
uint32_t media_kind;
|
||||
uint32_t tv_episode_sort;
|
||||
uint32_t tv_season_num;
|
||||
char *tv_series_name;
|
||||
char *tv_episode_num_str; /* com.apple.itunes.episode-num-str, used as a unique episode identifier */
|
||||
char *tv_network_name;
|
||||
|
||||
char *album_artist;
|
||||
uint32_t tv_episode_sort;
|
||||
uint32_t tv_season_num;
|
||||
|
||||
int64_t songartistid;
|
||||
int64_t songalbumid;
|
||||
@@ -212,16 +217,8 @@ struct media_file_info {
|
||||
char *title_sort;
|
||||
char *artist_sort;
|
||||
char *album_sort;
|
||||
char *composer_sort;
|
||||
char *album_artist_sort;
|
||||
|
||||
char *virtual_path;
|
||||
|
||||
uint32_t directory_id; /* Id of directory */
|
||||
uint32_t date_released;
|
||||
|
||||
uint32_t skip_count;
|
||||
uint32_t time_skipped;
|
||||
char *composer_sort;
|
||||
};
|
||||
|
||||
#define mfi_offsetof(field) offsetof(struct media_file_info, field)
|
||||
@@ -308,10 +305,13 @@ struct db_group_info {
|
||||
struct db_media_file_info {
|
||||
char *id;
|
||||
char *path;
|
||||
char *virtual_path;
|
||||
char *fname;
|
||||
char *directory_id;
|
||||
char *title;
|
||||
char *artist;
|
||||
char *album;
|
||||
char *album_artist;
|
||||
char *genre;
|
||||
char *comment;
|
||||
char *type;
|
||||
@@ -325,6 +325,7 @@ struct db_media_file_info {
|
||||
char *song_length;
|
||||
char *file_size;
|
||||
char *year;
|
||||
char *date_released;
|
||||
char *track;
|
||||
char *total_tracks;
|
||||
char *disc;
|
||||
@@ -334,14 +335,17 @@ struct db_media_file_info {
|
||||
char *artwork;
|
||||
char *rating;
|
||||
char *play_count;
|
||||
char *skip_count;
|
||||
char *seek;
|
||||
char *data_kind;
|
||||
char *media_kind;
|
||||
char *item_kind;
|
||||
char *description;
|
||||
char *db_timestamp;
|
||||
char *time_added;
|
||||
char *time_modified;
|
||||
char *time_played;
|
||||
char *db_timestamp;
|
||||
char *time_skipped;
|
||||
char *disabled;
|
||||
char *sample_count;
|
||||
char *codectype;
|
||||
@@ -349,8 +353,6 @@ struct db_media_file_info {
|
||||
char *has_video;
|
||||
char *contentrating;
|
||||
char *bits_per_sample;
|
||||
char *album_artist;
|
||||
char *media_kind;
|
||||
char *tv_episode_sort;
|
||||
char *tv_season_num;
|
||||
char *tv_series_name;
|
||||
@@ -361,13 +363,8 @@ struct db_media_file_info {
|
||||
char *title_sort;
|
||||
char *artist_sort;
|
||||
char *album_sort;
|
||||
char *composer_sort;
|
||||
char *album_artist_sort;
|
||||
char *virtual_path;
|
||||
char *directory_id;
|
||||
char *date_released;
|
||||
char *skip_count;
|
||||
char *time_skipped;
|
||||
char *composer_sort;
|
||||
};
|
||||
|
||||
#define dbmfi_offsetof(field) offsetof(struct db_media_file_info, field)
|
||||
|
||||
Reference in New Issue
Block a user