summaryrefslogtreecommitdiffstats
path: root/schema.sql
blob: b65ae6bdea880520b702a19ed06635f15a628903 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
CREATE TABLE IF NOT EXISTS users (
	user_id SERIAL PRIMARY KEY,
	type text,
	op_id text,
	name text,
	email text,
	lfm_name text UNIQUE,
	lfm_password text,
	created timestamptz DEFAULT current_timestamp
);

CREATE TABLE IF NOT EXISTS scrobbling_sessions (
    session_key text PRIMARY KEY,
	user_id int REFERENCES users,
    client text,
	client_version text,
    protocol text,
	created timestamptz DEFAULT current_timestamp
);

CREATE TABLE IF NOT EXISTS songs (
	song_id SERIAL PRIMARY KEY,
	artist text,
	album text,
	name text,
	track_number text,
	duration text,
	mbid text,
	image text
);

CREATE TABLE IF NOT EXISTS scrobbles (
	artist text,
	album_artist text,
	track_name text,
	album text,
	track_number int,
	duration int,
	time timestamptz,
	chosen bool,
	mbid text,
	song_id int REFERENCES songs,
	session_key text REFERENCES scrobbling_sessions,
	user_id int REFERENCES users
);

CREATE TABLE IF NOT EXISTS user_sessions (
	id text PRIMARY KEY,
	user_id integer REFERENCES users,
	created timestamptz DEFAULT current_timestamp
);