Multiple accounts support, load tags online

This commit is contained in:
Cadence Ember 2025-04-02 17:03:03 +13:00
parent cd2827791f
commit 26ea869285
14 changed files with 295 additions and 124 deletions

View file

@ -1,6 +1,14 @@
BEGIN TRANSACTION;
CREATE TABLE account (
account TEXT NOT NULL,
fan_id INTEGER NOT NULL,
currency TEXT,
PRIMARY KEY (account)
) WITHOUT ROWID;
CREATE TABLE item (
account TEXT NOT NULL,
item_id INTEGER NOT NULL,
item_type TEXT NOT NULL,
band_id INTEGER NOT NULL,
@ -24,10 +32,11 @@ CREATE TABLE item (
currency STRING NOT NULL,
label TEXT,
label_id INTEGER,
PRIMARY KEY (item_id)
PRIMARY KEY (account, item_id)
) WITHOUT ROWID;
CREATE TABLE track (
account TEXT NOT NULL,
item_id INTEGER NOT NULL,
track_id INTEGER NOT NULL,
title TEXT NOT NULL,
@ -35,15 +44,16 @@ CREATE TABLE track (
track_number INTEGER,
duration NUMERIC NOT NULL,
mp3 TEXT,
PRIMARY KEY (item_id, track_id),
FOREIGN KEY (item_id) REFERENCES item (item_id) ON DELETE CASCADE
PRIMARY KEY (account, item_id, track_id),
FOREIGN KEY (account, item_id) REFERENCES item (account, item_id) ON DELETE CASCADE
) WITHOUT ROWID;
CREATE TABLE item_tag (
account TEXT NOT NULL,
item_id INTEGER NOT NULL,
tag TEXT NOT NULL,
PRIMARY KEY (item_id, tag),
FOREIGN KEY (item_id) REFERENCES item (item_id) ON DELETE CASCADE
PRIMARY KEY (account, item_id, tag),
FOREIGN KEY (account, item_id) REFERENCES item (account, item_id) ON DELETE CASCADE
) WITHOUT ROWID;
COMMIT;