so://phie

verbal

A mobile app for listening to radio stations from around the globe
git clone git://soophie.de/verbal

blob: 70b819955f24e2b76fe9e321e06bc1b914a9189f (1909 bytes)[doc][blame][raw]

1/* ########## account ########## */

2CREATE TABLE account (

3 id serial PRIMARY KEY,

4 created_at timestamp without time zone NOT NULL,

5 updated_at timestamp without time zone NOT NULL,

6 username text,

7 language character(2) DEFAULT 'en',

8 is_playback_history boolean DEFAULT true

9);

10

11/* ########## device ########## */

12CREATE TABLE device (

13 id serial PRIMARY KEY,

14 created_at timestamp without time zone NOT NULL,

15 updated_at timestamp without time zone NOT NULL,

16 token text UNIQUE NOT NULL,

17 account_id integer

18);

19

20ALTER TABLE device

21 ADD CONSTRAINT device_account_id

22 FOREIGN KEY (account_id)

23 REFERENCES account(id);

24

25/* ########## station ########## */

26CREATE TABLE station (

27 id serial PRIMARY KEY,

28 created_at timestamp without time zone NOT NULL,

29 updated_at timestamp without time zone NOT NULL,

30 "name" text NOT NULL,

31 stream_url text NOT NULL,

32 votes integer DEFAULT 0,

33 favicon text,

34 homepage text,

35 tags text[],

36 country text,

37 languages text[],

38 "state" text

39);

40

41/* ########## favorite ########## */

42CREATE TABLE favorite (

43 id serial PRIMARY KEY,

44 created_at timestamp without time zone NOT NULL,

45 updated_at timestamp without time zone NOT NULL,

46 station_id text NOT NULL,

47 account_id integer NOT NULL

48);

49

50ALTER TABLE favorite

51 ADD CONSTRAINT favorite_account_id

52 FOREIGN KEY (account_id)

53 REFERENCES account(id);

54

55ALTER TABLE favorite

56 ADD CONSTRAINT favorite_station_id

57 FOREIGN KEY (station_id)

58 REFERENCES station(id);

59

60/* ########## code ########## */

61CREATE TABLE code (

62 id serial PRIMARY KEY,

63 code text UNIQUE NOT NULL,

64 "timestamp" timestamp without time zone NOT NULL,

65 used boolean DEFAULT false NOT NULL,

66 account_id integer UNIQUE NOT NULL

67);

68

69ALTER TABLE code

70 ADD CONSTRAINT code_account_id

71 FOREIGN KEY (account_id)

72 REFERENCES account(id);