A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 346fc63e42ea7610a283147d125948a73c056638 (4038 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 INTEGER,20
utc INTEGER21
);23
ALTER TABLE station24
ADD CONSTRAINT station_group_id25
FOREIGN KEY (group_id)26
REFERENCES station_group(id);28
/* ############################################################ */29
/* # station_group # */30
/* ############################################################ */32
CREATE TABLE station_group (33
id SERIAL PRIMARY KEY,34
name TEXT NOT NULL,35
description TEXT36
);38
/* ############################################################ */39
/* # station_status # */40
/* ############################################################ */42
CREATE TABLE station_status (43
id SERIAL PRIMARY KEY,44
station_id INTEGER UNIQUE,45
is_restricted BOOLEAN DEFAULT false,46
is_broken BOOLEAN DEFAULT false,47
is_no_track_info BOOLEAN DEFAULT false,48
is_hidden BOOLEAN DEFAULT false,49
is_icon BOOLEAN DEFAULT false50
);52
ALTER TABLE station_status53
ADD CONSTRAINT station_status_station_id54
FOREIGN KEY (station_id)55
REFERENCES station(id);57
/* ############################################################ */58
/* # station_stats # */59
/* ############################################################ */61
CREATE TABLE station_stats (62
id SERIAL PRIMARY KEY,63
account_id INTEGER,64
station_id INTEGER,65
playtime INTEGER DEFAULT 0,66
latest_at TIMESTAMP WITH TIME ZONE DEFAULT now()67
);69
ALTER TABLE station_stats70
ADD CONSTRAINT station_stats_unique71
UNIQUE(account_id, station_id);73
ALTER TABLE station_stats74
ADD CONSTRAINT station_stats_account_id75
FOREIGN KEY (account_id)76
REFERENCES account(id);78
ALTER TABLE station_stats79
ADD CONSTRAINT station_stats_station_id80
FOREIGN KEY (station_id)81
REFERENCES station(id);83
/* ############################################################ */84
/* # account # */85
/* ############################################################ */87
CREATE TABLE account (88
id SERIAL PRIMARY KEY,89
name TEXT,90
language TEXT DEFAULT 'en',91
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()92
);94
/* ############################################################ */95
/* # device # */96
/* ############################################################ */98
CREATE TABLE device (99
id SERIAL PRIMARY KEY,100
uid TEXT UNIQUE NOT NULL,101
name TEXT,102
account_id INTEGER,103
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()104
);106
ALTER TABLE device107
ADD CONSTRAINT device_account_id108
FOREIGN KEY (account_id)109
REFERENCES account(id);111
/* ############################################################ */112
/* # favorite # */113
/* ############################################################ */115
CREATE TABLE favorite (116
id SERIAL PRIMARY KEY,117
account_id INTEGER,118
station_id INTEGER119
);121
ALTER TABLE favorite122
ADD CONSTRAINT favorite_account_id123
FOREIGN KEY (account_id)124
REFERENCES account(id);126
ALTER TABLE favorite127
ADD CONSTRAINT favorite_station_id128
FOREIGN KEY (station_id)129
REFERENCES station(id);131
/* ############################################################ */132
/* # guest account # */133
/* ############################################################ */135
INSERT INTO account (id, name)136
VALUES (0, 'Guest');138
INSERT INTO device (uid, account_id)139
VALUES ('guest-token', 0);