this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add file table

+44 -36
+44 -36
src/db/migrations/01-init.sql
··· 1 - CREATE TABLE migrations ( 2 - id INTEGER PRIMARY KEY, 3 - name TEXT NOT NULL UNIQUE, 4 - applied_at DATE 1 + create table migrations ( 2 + id integer primary key, 3 + name text not null unique, 4 + applied_at date 5 5 ); 6 6 7 - CREATE TABLE album ( 8 - id TEXT PRIMARY KEY, 9 - title TEXT NOT NULL UNIQUE, 10 - mb_id TEXT UNIQUE, 11 - mb_rg_id TEXT UNIQUE 7 + create table album ( 8 + id text primary key, 9 + title text not null unique, 10 + mb_id text unique, 11 + mb_rg_id text unique 12 12 ); 13 13 14 - CREATE TABLE artist ( 15 - id TEXT PRIMARY KEY, 16 - name TEXT NOT NULL UNIQUE, 17 - mb_id TEXT UNIQUE, 18 - acoust_id TEXT UNIQUE 14 + create table artist ( 15 + id text primary key, 16 + name text not null unique, 17 + mb_id text unique, 18 + acoust_id text unique 19 19 ); 20 20 21 - CREATE TABLE track ( 22 - id TEXT PRIMARY KEY, 23 - title TEXT NOT NULL, 24 - track_number INTEGER NOT NULL DEFAULT 0, 25 - mb_id TEXT, 26 - album_id TEXT NOT NULL, 21 + create table track ( 22 + id text primary key, 23 + title text not null, 24 + track_number integer not null default 0, 25 + mb_id text, 26 + album_id text not null, 27 27 28 - UNIQUE(title, track_number, album_id) 29 - FOREIGN KEY(album_id) REFERENCES album(id) ON DELETE CASCADE 28 + unique(title, track_number, album_id) 29 + foreign key(album_id) references album(id) on delete cascade 30 30 ); 31 31 32 - CREATE INDEX track_album_idx ON track(album_id); 32 + create table file ( 33 + id text primary key, 34 + path text not null unique, 35 + track_id text not null unique, 33 36 34 - CREATE TABLE artist_track ( 35 - artist_id TEXT NOT NULL, 36 - track_id TEXT NOT NULL, 37 + foreign key (track_id) references track(id) 38 + ); 37 39 38 - PRIMARY KEY(artist_id, track_id), 39 - FOREIGN KEY(artist_id) REFERENCES artist(id), 40 - FOREIGN KEY(track_id) REFERENCES track(id) 40 + create index track_album_idx on track(album_id); 41 + 42 + create table artist_track ( 43 + artist_id text not null, 44 + track_id text not null, 45 + 46 + primary key(artist_id, track_id), 47 + foreign key(artist_id) references artist(id), 48 + foreign key(track_id) references track(id) 41 49 ); 42 50 43 - CREATE TABLE artist_album ( 44 - artist_id TEXT NOT NULL, 45 - album_id TEXT NOT NULL, 51 + create table artist_album ( 52 + artist_id text not null, 53 + album_id text not null, 46 54 47 - PRIMARY KEY(artist_id, album_id), 48 - FOREIGN KEY(artist_id) REFERENCES artist(id), 49 - FOREIGN KEY(album_id) REFERENCES album(id) 55 + primary key(artist_id, album_id), 56 + foreign key(artist_id) references artist(id), 57 + foreign key(album_id) references album(id) 50 58 ); 51 59 52 - INSERT INTO migrations (name, applied_at) VALUES ("01-init", CURRENT_TIMESTAMP); 60 + insert into migrations (name, applied_at) values ("01-init", current_timestamp);