-- 0100_backup_music.up.sql — the music files in Minstrel's own backup. -- -- Until now a backup held the database only. With include_music on, each -- library file is also sent once to music/ in the same destination, -- and sent again only when it changes. -- -- backup_settings.include_music off until an admin switches it on. -- backup_music_files one row per track sent (or refused): the -- file's size and mtime when it was sent, so -- a later night sends only what is new or -- changed. A track the scan has touched since -- checked_at is looked at again; it goes up -- again only if the file itself changed, so a -- full rescan doesn't resend the library. A -- refusal is kept with its reason and tried -- again once the file changes. -- backup_runs.music_* how much a run sent, and why it stopped. ALTER TABLE backup_settings ADD COLUMN include_music boolean NOT NULL DEFAULT false; ALTER TABLE backup_runs ADD COLUMN music_files integer NOT NULL DEFAULT 0, ADD COLUMN music_bytes bigint NOT NULL DEFAULT 0, ADD COLUMN music_note text NOT NULL DEFAULT ''; CREATE TABLE backup_music_files ( track_id uuid PRIMARY KEY REFERENCES tracks (id) ON DELETE CASCADE, -- The file as it was sent. size bigint NOT NULL, mtime timestamptz NOT NULL, -- Where it went: the object key, or the file's path in the folder. location text NOT NULL, -- When the file was last sent or found unchanged. checked_at timestamptz NOT NULL DEFAULT now(), -- Empty when it was sent; otherwise why the destination refused it. error text NOT NULL DEFAULT '' );