A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
blob: 871e8ea7d9b99062bf2b2005d7ba5fb527c8cc2b (3671 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 NULL34
);36
/* ############################################################ */37
/* # station_status # */38
/* ############################################################ */40
CREATE TABLE station_status (41
id SERIAL PRIMARY KEY,42
station_id INTEGER UNIQUE,43
is_restricted BOOLEAN DEFAULT false,44
is_broken BOOLEAN DEFAULT false,45
is_no_track_info BOOLEAN DEFAULT false,46
is_hidden BOOLEAN DEFAULT false,47
is_icon BOOLEAN DEFAULT false48
);50
ALTER TABLE station_status51
ADD CONSTRAINT station_status_station_id52
FOREIGN KEY (station_id)53
REFERENCES station(id);55
/* ############################################################ */56
/* # station_stats # */57
/* ############################################################ */59
CREATE TABLE station_stats (60
id SERIAL PRIMARY KEY,61
account_id INTEGER,62
station_id INTEGER,63
playtime INTEGER DEFAULT 0,64
latest_at TIMESTAMP WITH TIME ZONE DEFAULT now()65
);67
ALTER TABLE station_stats68
ADD CONSTRAINT station_stats_unique69
UNIQUE(account_id, station_id);71
ALTER TABLE station_stats72
ADD CONSTRAINT station_stats_account_id73
FOREIGN KEY (account_id)74
REFERENCES account(id);76
ALTER TABLE station_stats77
ADD CONSTRAINT station_stats_station_id78
FOREIGN KEY (station_id)79
REFERENCES station(id);81
/* ############################################################ */82
/* # account # */83
/* ############################################################ */85
CREATE TABLE account (86
id SERIAL PRIMARY KEY,87
name TEXT,88
language TEXT DEFAULT 'en',89
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()90
);92
/* ############################################################ */93
/* # device # */94
/* ############################################################ */96
CREATE TABLE device (97
id SERIAL PRIMARY KEY,98
uid TEXT UNIQUE NOT NULL,99
name TEXT,100
account_id INTEGER,101
created_at TIMESTAMP WITH TIME ZONE DEFAULT now()102
);104
ALTER TABLE device105
ADD CONSTRAINT device_account_id106
FOREIGN KEY (account_id)107
REFERENCES account(id);109
/* ############################################################ */110
/* # favorite # */111
/* ############################################################ */113
CREATE TABLE favorite (114
id SERIAL PRIMARY KEY,115
account_id INTEGER,116
station_id INTEGER117
);119
ALTER TABLE favorite120
ADD CONSTRAINT favorite_account_id121
FOREIGN KEY (account_id)122
REFERENCES account(id);124
ALTER TABLE favorite125
ADD CONSTRAINT favorite_station_id126
FOREIGN KEY (station_id)127
REFERENCES station(id);