From 6a55c6088d945c9da8c9fa3f7b12d286d04bc2ec Mon Sep 17 00:00:00 2001 From: Anna Schumaker Date: Wed, 10 May 2023 17:36:34 -0400 Subject: [PATCH] Add 'saved_track_data' --- saved_track_data.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 saved_track_data.md diff --git a/saved_track_data.md b/saved_track_data.md new file mode 100644 index 0000000..3e0479a --- /dev/null +++ b/saved_track_data.md @@ -0,0 +1,17 @@ +The `saved_track_data` table is used to preserve [track](tracks) data when tracks are deleted and restore the values if a track with the same mbid is later added. This lets us handle renaming files without losing the user's playback statistics. Note that this only works for tracks that have an MBID. + +### Columns + +| Name | Type | Default | Description | +| ----------- | --------- | ------- | ------------------------------------------------------------------------------------- | +| mbid | TEXT | | The [MusicBrainz ID](https://musicbrainz.org/doc/MusicBrainz_Identifier) of the track | +| favorite | BOOLEAN | FALSE | The favorite status of the track | +| playcount | INTEGER | 0 | The playcount of the track | +| lastplayed | TIMESTAMP | NULL | The last played timestamp of the track | +| laststarted | TIMESTAMP | NULL | The last started timestamp of the track | + +### Triggers +| Name | When | Description | +| --------------------- | ------------- | ------------------------------------------------------------------ | +| tracks_delete_save | Before delete | Insert the appropriate fields into the saved_tracks_data table | +| tracks_insert_restore | After insert | Update the [[tracks]] table with fields from the saved_tracks_data | \ No newline at end of file