mirror of
https://github.com/navidrome/navidrome.git
synced 2026-08-01 07:21:17 +00:00
Merge f22cca069d2ebe5aadd3f551cf13e6b7d2b6bc41 into add0a6dc9b8360db480f76793fa928499bf51741
This commit is contained in:
commit
253a5a2bc1
@ -0,0 +1,48 @@
|
||||
-- +goose Up
|
||||
|
||||
-- Add useful information to playlist tracks.
|
||||
--
|
||||
-- The fields:
|
||||
-- add_time - The UTC time when the item was added to the playlist.
|
||||
-- weight - A random integer generated by SQLite.
|
||||
--
|
||||
-- They allow:
|
||||
-- - Let users recall when they added the track to playlist. Navidrome
|
||||
-- currently doesn't store this information which might be important
|
||||
-- to music curators.
|
||||
-- - A fixed randomness to the playlist (shuffle) defined by the database.
|
||||
-- - Let user sort playlist by time added (last week, last month, last year),
|
||||
-- by a fixed random order (given by weight field), and also shuffle the
|
||||
-- playlist via the player as it is currently supported by players. UI for
|
||||
-- all these sorting modes currently doesn't exists, so lets build the
|
||||
-- information infrastructure first so the UI can be built on top of that.
|
||||
CREATE TABLE IF NOT EXISTS "playlist_tracks_new"
|
||||
(
|
||||
id integer default 0 not null,
|
||||
playlist_id varchar(255) not null
|
||||
constraint playlist_tracks_playlist_id_fk
|
||||
references playlist
|
||||
on update cascade on delete cascade,
|
||||
media_file_id varchar(255) not null,
|
||||
constraint playlist_tracks_media_file_id_fk
|
||||
references media_file
|
||||
on update cascade on delete cascade,
|
||||
missing boolean default 0 not null,
|
||||
|
||||
added_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
|
||||
|
||||
PRIMARY KEY (playlist_id, id)
|
||||
);
|
||||
|
||||
-- Copy old table data into patched table; the new fields will be
|
||||
-- filled with defaults.
|
||||
INSERT INTO playlist_tracks_new (id,playlist_id,media_file_id,missing)
|
||||
SELECT id,playlist_id,media_file_id,missing FROM playlist_tracks;
|
||||
|
||||
-- Drop old table
|
||||
DROP TABLE playlist_tracks;
|
||||
|
||||
-- Put new table to work
|
||||
ALTER TABLE playlist_tracks_new RENAME TO playlist_tracks;
|
||||
|
||||
SELECT 1;
|
||||
Loading…
x
Reference in New Issue
Block a user