mirror of
https://github.com/navidrome/navidrome.git
synced 2026-11-13 05:38:47 +01:00
feat: persist and expose plugin playlist ValidUntil in Subsonic API
Add a ValidUntil field to the Playlist model and persist it from the plugin's GetPlaylistResponse during sync. This allows clients to know when a plugin playlist's data will be refreshed. The value is exposed in the OpenSubsonic playlist response alongside the existing smart playlist ValidUntil calculation. The migration is consolidated into a single multi-statement ExecContext call.
This commit is contained in:
parent
a5fd18dc67
commit
9ddbcbf6b4
6 changed files with 33 additions and 22 deletions
|
|
@ -12,27 +12,21 @@ func init() {
|
|||
}
|
||||
|
||||
func upAddPluginPlaylistFields(ctx context.Context, tx *sql.Tx) error {
|
||||
_, err := tx.ExecContext(ctx, `ALTER TABLE playlist ADD COLUMN plugin_id VARCHAR(255) NOT NULL DEFAULT '';`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `ALTER TABLE playlist ADD COLUMN plugin_playlist_id VARCHAR(255) NOT NULL DEFAULT '';`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `CREATE UNIQUE INDEX IF NOT EXISTS idx_playlist_plugin ON playlist(plugin_id, plugin_playlist_id, owner_id) WHERE plugin_id != '';`)
|
||||
_, err := tx.ExecContext(ctx, `
|
||||
ALTER TABLE playlist ADD COLUMN plugin_id VARCHAR(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE playlist ADD COLUMN plugin_playlist_id VARCHAR(255) NOT NULL DEFAULT '';
|
||||
ALTER TABLE playlist ADD COLUMN valid_until DATETIME DEFAULT NULL;
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS idx_playlist_plugin ON playlist(plugin_id, plugin_playlist_id, owner_id) WHERE plugin_id != '';
|
||||
`)
|
||||
return err
|
||||
}
|
||||
|
||||
func downAddPluginPlaylistFields(ctx context.Context, tx *sql.Tx) error {
|
||||
_, err := tx.ExecContext(ctx, `DROP INDEX IF EXISTS idx_playlist_plugin;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `ALTER TABLE playlist DROP COLUMN plugin_playlist_id;`)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, err = tx.ExecContext(ctx, `ALTER TABLE playlist DROP COLUMN plugin_id;`)
|
||||
_, err := tx.ExecContext(ctx, `
|
||||
DROP INDEX IF EXISTS idx_playlist_plugin;
|
||||
ALTER TABLE playlist DROP COLUMN valid_until;
|
||||
ALTER TABLE playlist DROP COLUMN plugin_playlist_id;
|
||||
ALTER TABLE playlist DROP COLUMN plugin_id;
|
||||
`)
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue