A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: d25e4f9714e9d2fb42659c7608843bdd1942b7ed (4021 bytes)[doc][blame][raw]
1
/* ############################################################ */2
/* # station # */3
/* ############################################################ */5
CREATE TABLE station (6
id SERIAL PRIMARY KEY,7
uid TEXT UNIQUE,8
name TEXT NOT NULL,9
url TEXT NOT NULL,10
icon TEXT,11
homepage TEXT,12
tags TEXT[],13
country TEXT,14
state TEXT,15
languages TEXT[],16
score INTEGER,17
description TEXT,18
color TEXT,19
group_id INTEGER20
);22
ALTER TABLE station23
ADD CONSTRAINT station_group_id24
FOREIGN KEY (group_id)25
REFERENCES station_group(id);27
/* ############################################################ */28
/* # station_group # */29
/* ############################################################ */31
CREATE TABLE station_group (32
id SERIAL PRIMARY KEY,33
name TEXT NOT NULL,34
description TEXT35
);37
/* ############################################################ */38
/* # station_status # */39
/* ############################################################ */41
CREATE TABLE station_status (42
id SERIAL PRIMARY KEY,43
station_id INTEGER UNIQUE,44
is_restricted BOOLEAN DEFAULT false,45
is_broken BOOLEAN DEFAULT false,46
is_no_track_info BOOLEAN DEFAULT false,47
is_hidden BOOLEAN DEFAULT false,48
is_icon BOOLEAN DEFAULT false49
);51
ALTER TABLE station_status52
ADD CONSTRAINT station_status_station_id53
FOREIGN KEY (station_id)54
REFERENCES station(id);56
/* ############################################################ */57
/* # station_stats # */58
/* ############################################################ */60
CREATE TABLE station_stats (61
id SERIAL PRIMARY KEY,62
account_id INTEGER,63
station_id INTEGER,64
playtime INTEGER DEFAULT 0,65
latest_at TIMESTAMP WITH TIME ZONE DEFAULT now()66
);68
ALTER TABLE station_stats69
ADD CONSTRAINT station_stats_unique70
UNIQUE(account_id, station_id);72
ALTER TABLE station_stats73
ADD CONSTRAINT station_stats_account_id74
FOREIGN KEY (account_id)75
REFERENCES account(id);77
ALTER TABLE station_stats78
ADD CONSTRAINT station_stats_station_id79
FOREIGN KEY (station_id)80
REFERENCES station(id);82
/* ############################################################ */83
/* # account # */84
/* ############################################################ */86
CREATE TABLE account (87
id SERIAL PRIMARY KEY,88
name TEXT,89
language TEXT DEFAULT 'en',90
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()91
);93
/* ############################################################ */94
/* # device # */95
/* ############################################################ */97
CREATE TABLE device (98
id SERIAL PRIMARY KEY,99
uid TEXT UNIQUE NOT NULL,100
name TEXT,101
account_id INTEGER,102
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()103
);105
ALTER TABLE device106
ADD CONSTRAINT device_account_id107
FOREIGN KEY (account_id)108
REFERENCES account(id);110
/* ############################################################ */111
/* # favorite # */112
/* ############################################################ */114
CREATE TABLE favorite (115
id SERIAL PRIMARY KEY,116
account_id INTEGER,117
station_id INTEGER118
);120
ALTER TABLE favorite121
ADD CONSTRAINT favorite_account_id122
FOREIGN KEY (account_id)123
REFERENCES account(id);125
ALTER TABLE favorite126
ADD CONSTRAINT favorite_station_id127
FOREIGN KEY (station_id)128
REFERENCES station(id);130
/* ############################################################ */131
/* # guest account # */132
/* ############################################################ */134
INSERT INTO account (id, name)135
VALUES (0, 'Guest');137
INSERT INTO device (uid, account_id)138
VALUES ('guest-token', 0);