A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal
1
/* ########## account ########## */1
/* ### station ### */3
CREATE TABLE station (4
id SERIAL PRIMARY KEY,5
uid TEXT UNIQUE,6
name TEXT NOT NULL,7
url TEXT NOT NULL,8
icon TEXT,9
homepage TEXT,10
tags TEXT[],11
country TEXT,12
state TEXT,13
languages TEXT[],14
score INTEGER15
);17
/* ### account ### */19
CREATE TABLE account (3
id serial PRIMARY KEY,4
created_at timestamp without time zone NOT NULL DEFAULT current_timestamp,5
updated_at timestamp without time zone NOT NULL DEFAULT current_timestamp,6
username text,7
language character(2) DEFAULT 'en',8
is_playback_history boolean DEFAULT true20
id SERIAL PRIMARY KEY,21
name TEXT,22
language TEXT DEFAULT 'en'23
);11
/* ########## device ########## */25
/* ### device ### */27
CREATE TABLE device (13
id serial PRIMARY KEY,14
created_at timestamp without time zone NOT NULL DEFAULT current_timestamp,15
updated_at timestamp without time zone NOT NULL DEFAULT current_timestamp,16
token text UNIQUE NOT NULL,17
account_id integer28
id SERIAL PRIMARY KEY,29
uid TEXT UNIQUE NOT NULL,30
account_id INTEGER31
);33
ALTER TABLE device
35
FOREIGN KEY (account_id)36
REFERENCES account(id);25
/* ########## station ########## */26
CREATE TABLE station (27
id serial PRIMARY KEY,28
uuid TEXT UNIQUE,29
created_at timestamp without time zone NOT NULL DEFAULT current_timestamp,30
updated_at timestamp without time zone NOT NULL DEFAULT current_timestamp,31
"name" text NOT NULL,32
stream_url text NOT NULL,33
votes integer DEFAULT 0,34
favicon text,35
homepage text,36
tags text[],37
country text,38
languages text[],39
"state" text40
);38
/* ### favorite ### */42
/* ########## like ########## */43
CREATE TABLE "like" (44
id serial PRIMARY KEY,45
created_at timestamp without time zone NOT NULL DEFAULT current_timestamp,46
updated_at timestamp without time zone NOT NULL DEFAULT current_timestamp,47
station_id text NOT NULL,48
account_id integer NOT NULL40
CREATE TABLE favorite (41
id SERIAL PRIMARY KEY,42
account_id INTEGER,43
station_id INTEGER44
);51
ALTER TABLE "like"52
ADD CONSTRAINT like_account_id46
ALTER TABLE favorite47
ADD CONSTRAINT favorite_account_id48
FOREIGN KEY (account_id)49
REFERENCES account(id);56
/* ########## code ########## */57
CREATE TABLE code (58
id serial PRIMARY KEY,59
code text UNIQUE NOT NULL,60
"timestamp" timestamp without time zone NOT NULL,61
used boolean DEFAULT false NOT NULL,62
account_id integer UNIQUE NOT NULL63
);65
ALTER TABLE code66
ADD CONSTRAINT code_account_id67
FOREIGN KEY (account_id)68
REFERENCES account(id);51
ALTER TABLE favorite52
ADD CONSTRAINT favorite_station_id53
FOREIGN KEY (station_id)54
REFERENCES station(id);
1
/* Create a test user */1
/* ### create a test user ### */3
INSERT INTO account (id, username) VALUES (1, 'Test User');3
INSERT INTO device (token, account_id) VALUES ('test-token', 1);4
INSERT INTO device (uid, account_id) VALUES ('test-token', 1);