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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
|
SET statement_timeout = 0;
SET lock_timeout = 0;
SET idle_in_transaction_session_timeout = 0;
SET client_encoding = 'UTF8';
SET standard_conforming_strings = on;
SET check_function_bodies = false;
SET client_min_messages = warning;
SET row_security = off;
SET search_path = public, pg_catalog;
SET default_tablespace = '';
SET default_with_oids = false;
CREATE TABLE goose_db_version (
id integer NOT NULL,
version_id bigint NOT NULL,
is_applied boolean NOT NULL,
tstamp timestamp without time zone DEFAULT now()
);
CREATE SEQUENCE goose_db_version_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE goose_db_version_id_seq OWNED BY goose_db_version.id;
CREATE TABLE now_playing (
artist text,
album_artist text,
track_name text,
album text,
track_number integer,
duration integer,
received timestamp with time zone DEFAULT now(),
mbid text,
song_id integer,
session_key text,
user_id integer
);
CREATE TABLE scrobble_import (
lfm_name text NOT NULL,
"from" timestamp with time zone NOT NULL,
"to" timestamp with time zone NOT NULL,
last_fetch timestamp with time zone,
done boolean
);
CREATE TABLE scrobbles (
artist text,
album_artist text,
track_name text,
album text,
track_number integer,
duration integer,
"time" timestamp with time zone,
chosen boolean,
mbid text,
song_id integer,
session_key text,
user_id integer
);
CREATE TABLE scrobbling_sessions (
session_key text NOT NULL,
user_id integer,
client text,
client_version text,
protocol text,
created timestamp with time zone DEFAULT now()
);
CREATE TABLE songs (
song_id integer NOT NULL,
artist text,
album text,
name text,
track_number text,
duration text,
mbid text,
image text
);
CREATE SEQUENCE songs_song_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE songs_song_id_seq OWNED BY songs.song_id;
CREATE TABLE user_sessions (
id text NOT NULL,
user_id integer,
created timestamp with time zone DEFAULT now()
);
CREATE TABLE users (
user_id integer NOT NULL,
type text,
op_id text,
name text,
email text,
lfm_name text,
lfm_password text,
created timestamp with time zone DEFAULT now()
);
CREATE SEQUENCE users_user_id_seq
START WITH 1
INCREMENT BY 1
NO MINVALUE
NO MAXVALUE
CACHE 1;
ALTER SEQUENCE users_user_id_seq OWNED BY users.user_id;
ALTER TABLE ONLY goose_db_version ALTER COLUMN id SET DEFAULT nextval('goose_db_version_id_seq'::regclass);
ALTER TABLE ONLY songs ALTER COLUMN song_id SET DEFAULT nextval('songs_song_id_seq'::regclass);
ALTER TABLE ONLY users ALTER COLUMN user_id SET DEFAULT nextval('users_user_id_seq'::regclass);
ALTER TABLE ONLY goose_db_version
ADD CONSTRAINT goose_db_version_pkey PRIMARY KEY (id);
ALTER TABLE ONLY now_playing
ADD CONSTRAINT now_playing_user_id_key UNIQUE (user_id);
ALTER TABLE ONLY users
ADD CONSTRAINT op UNIQUE (type, op_id);
ALTER TABLE ONLY scrobble_import
ADD CONSTRAINT scrobble_import_pkey PRIMARY KEY (lfm_name, "from", "to");
ALTER TABLE ONLY scrobbling_sessions
ADD CONSTRAINT scrobbling_sessions_pkey PRIMARY KEY (session_key);
ALTER TABLE ONLY songs
ADD CONSTRAINT songs_pkey PRIMARY KEY (song_id);
ALTER TABLE ONLY user_sessions
ADD CONSTRAINT user_sessions_pkey PRIMARY KEY (id);
ALTER TABLE ONLY users
ADD CONSTRAINT users_lfm_name_key UNIQUE (lfm_name);
ALTER TABLE ONLY users
ADD CONSTRAINT users_pkey PRIMARY KEY (user_id);
CREATE INDEX scrobbles_time ON scrobbles USING btree ("time" DESC);
ALTER TABLE ONLY now_playing
ADD CONSTRAINT now_playing_session_key_fkey FOREIGN KEY (session_key) REFERENCES scrobbling_sessions(session_key);
ALTER TABLE ONLY now_playing
ADD CONSTRAINT now_playing_song_id_fkey FOREIGN KEY (song_id) REFERENCES songs(song_id);
ALTER TABLE ONLY now_playing
ADD CONSTRAINT now_playing_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id);
ALTER TABLE ONLY scrobbles
ADD CONSTRAINT scrobbles_session_key_fkey FOREIGN KEY (session_key) REFERENCES scrobbling_sessions(session_key);
ALTER TABLE ONLY scrobbles
ADD CONSTRAINT scrobbles_song_id_fkey FOREIGN KEY (song_id) REFERENCES songs(song_id);
ALTER TABLE ONLY scrobbles
ADD CONSTRAINT scrobbles_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id);
ALTER TABLE ONLY scrobbling_sessions
ADD CONSTRAINT scrobbling_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id);
ALTER TABLE ONLY user_sessions
ADD CONSTRAINT user_sessions_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id);
|