2022-12-31 14:25:43 +01:00
|
|
|
-- +migrate up
|
|
|
|
CREATE TABLE songs (
|
2023-01-02 07:51:41 +01:00
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
url TEXT NOT NULL,
|
|
|
|
disabled INTEGER NOT NULL DEFAULT 0,
|
|
|
|
uploaded_by INTEGER references accounts(id)
|
2022-12-31 14:25:43 +01:00
|
|
|
);
|
|
|
|
|
2023-01-02 07:51:41 +01:00
|
|
|
-- song data is fetched on-demand rather than whenever songs are created,
|
|
|
|
-- so this is a seperate table that's filled in for any given song once
|
|
|
|
-- it's needed
|
|
|
|
CREATE TABLE song_data (
|
2023-01-02 10:31:55 +01:00
|
|
|
id SERIAL PRIMARY KEY references songs(id),
|
2023-01-02 07:51:41 +01:00
|
|
|
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
author_id INTEGER NOT NULL references song_authors(id),
|
|
|
|
|
|
|
|
source TEXT NOT NULL DEFAULT "unknown",
|
|
|
|
size INTEGER, -- in bytes
|
|
|
|
duration INTEGER,
|
|
|
|
|
|
|
|
-- this may contain an absolute url OR a relative one (starts with ./)
|
|
|
|
-- depending on if its local or remote
|
|
|
|
-- null indicates it should be re-fetched every time its queried
|
|
|
|
proxy_url TEXT,
|
|
|
|
|
|
|
|
last_updated TEXT NOT NULL DEFAULT (STRFTIME('%Y-%m-%d %H:%M:%f', 'now'))
|
|
|
|
);
|
|
|
|
|
|
|
|
CREATE TABLE song_authors (
|
|
|
|
id SERIAL PRIMARY KEY,
|
|
|
|
source TEXT NOT NULL DEFAULT "unknown",
|
|
|
|
name TEXT NOT NULL,
|
|
|
|
url TEXT NOT NULL
|
|
|
|
);
|
|
|
|
|
|
|
|
INSERT INTO song_authors (id, name, source, url) VALUES (1, "", "unknown", "");
|
|
|
|
|
2022-12-31 14:25:43 +01:00
|
|
|
-- +migrate down
|
2023-01-02 07:51:41 +01:00
|
|
|
DROP TABLE songs;
|
|
|
|
DROP TABLE song_data;
|
|
|
|
DROP TABLE song_authors;
|