A Wrapped / Replay like for teal.fm and rocksky.app (currently on hiatus)
1begin;
2
3-- TODO MAYBE: l_*_* link tables?
4-- TODO MAYBE: label, label_alias, label_gid_redirect, release_label ??
5
6create table if not exists artist
7(
8 id bigint primary key,
9 gid text not null,
10 name text not null,
11 sort_name text not null,
12 begin_date_year int,
13 begin_date_month int,
14 begin_date_day int,
15 end_date_year int,
16 end_date_month int,
17 end_date_day int,
18 type int,
19 area int,
20 gender int,
21 comment text,
22 edits_pending int,
23 last_update datetime,
24 ended text not null,
25 begin_area int,
26 end_area int
27);
28
29create table if not exists artist_alias
30(
31 id bigint primary key,
32 artist bigint not null references artist (id),
33 name text not null,
34 locale text,
35 edits_pending int,
36 last_update datetime,
37 type int,
38 sort_name text not null,
39 begin_date_year int,
40 begin_date_month int,
41 begin_date_day int,
42 end_date_year int,
43 end_date_month int,
44 end_date_day int,
45 primary_for_locale text not null,
46 ended text not null
47);
48
49create table if not exists artist_credit
50(
51 id bigint primary key,
52 name text not null,
53 artist_count int not null,
54 ref_count int not null,
55 created datetime not null,
56 edits_pending int,
57 gid text not null
58);
59
60create table if not exists artist_credit_name
61(
62 artist_credit bigint not null references artist_credit (id),
63 position int not null,
64 artist bigint not null references artist (id),
65 name text not null,
66 join_phrase text,
67
68 primary key (artist_credit, position)
69);
70
71create table if not exists artist_gid_redirect
72(
73 gid text primary key,
74 new_id bigint not null references artist (id),
75 created datetime not null
76);
77
78create table if not exists artist_tag
79(
80 artist bigint not null references artist (id),
81 tag bigint not null references tag (id),
82 count int,
83 last_update datetime,
84
85 primary key (artist, tag)
86);
87
88
89create table if not exists genre
90(
91 id bigint primary key,
92 gid text not null,
93 name text not null,
94 comment text,
95 edits_pending int,
96 last_update datetime
97);
98
99create table if not exists genre_alias
100(
101 id bigint primary key,
102 genre bigint not null references genre (id),
103 name text not null,
104 locale text,
105 edits_pending int,
106 last_update datetime,
107 type int,
108 sort_name text not null,
109 begin_date_year int,
110 begin_date_month int,
111 begin_date_day int,
112 end_date_year int,
113 end_date_month int,
114 end_date_day int,
115 primary_for_locale text not null,
116 ended text not null
117);
118
119create table if not exists isrc
120(
121 id bigint primary key,
122 recording bigint not null references recording (id),
123 isrc text not null,
124 source int,
125 edits_pending int,
126 created datetime
127);
128
129create table if not exists medium
130(
131 id bigint primary key,
132 "release" bigint not null references "release" (id),
133 position int not null,
134 format int,
135 name text,
136 edits_pending int,
137 last_update datetime,
138 track_count int,
139 gid text not null
140);
141
142create table if not exists recording
143(
144 id bigint primary key,
145 gid text not null,
146 name text not null,
147 artist_credit bigint not null references artist_credit (id),
148 length int,
149 comment text,
150 edits_pending int,
151 last_update datetime,
152 video text not null
153);
154
155create table if not exists recording_alias
156(
157 id bigint primary key,
158 recording bigint not null references recording (id),
159 name text not null,
160 locale text,
161 edits_pending int,
162 last_update datetime,
163 type int,
164 sort_name text not null,
165 begin_date_year int,
166 begin_date_month int,
167 begin_date_day int,
168 end_date_year int,
169 end_date_month int,
170 end_date_day int,
171 primary_for_locale text not null,
172 ended text not null
173);
174
175create table if not exists recording_gid_redirect
176(
177 gid text primary key,
178 new_id bigint not null references recording (id),
179 created datetime not null
180);
181
182create table if not exists recording_tag
183(
184 recording bigint not null references recording (id),
185 tag bigint not null references tag (id),
186 count int,
187 last_updated datetime,
188
189 primary key (recording, tag)
190);
191
192create table if not exists "release"
193(
194 id bigint primary key,
195 gid text not null,
196 name text not null,
197 artist_credit bigint not null references artist_credit (id),
198 release_group bigint not null references release_group (id),
199 status int,
200 packaging int,
201 language int,
202 script int,
203 barcode text,
204 comment text,
205 edits_pending int,
206 quality int,
207 last_update datetime
208);
209
210create table if not exists release_alias
211(
212 id bigint primary key,
213 "release" bigint not null references "release" (id),
214 name text not null,
215 locale text,
216 edits_pending int,
217 last_update datetime,
218 type int,
219 sort_name text not null,
220 begin_date_year int,
221 begin_date_month int,
222 begin_date_day int,
223 end_date_year int,
224 end_date_month int,
225 end_date_day int,
226 primary_for_locale text not null,
227 ended text not null
228);
229
230create table if not exists release_gid_redirect
231(
232 gid text primary key,
233 new_id bigint not null,
234 created datetime not null
235);
236
237create table if not exists release_group
238(
239 id bigint primary key,
240 gid text not null,
241 name text not null,
242 artist_credit bigint not null references artist_credit (id),
243 type int,
244 comment text,
245 edits_pending int,
246 last_update datetime
247);
248
249create table if not exists release_group_alias
250(
251 id bigint primary key,
252 release_group bigint not null references release_group (id),
253 name text not null,
254 locale text,
255 edits_pending int,
256 last_update datetime,
257 type int,
258 sort_name text not null,
259 begin_date_year int,
260 begin_date_month int,
261 begin_date_day int,
262 end_date_year int,
263 end_date_month int,
264 end_date_day int,
265 primary_for_locale text not null,
266 ended text not null
267);
268
269create table if not exists release_group_gid_redirect
270(
271 gid text primary key,
272 new_id bigint not null,
273 created datetime not null
274);
275
276create table if not exists release_group_tag
277(
278 release_group bigint not null references release_group (id),
279 tag bigint not null references tag (id),
280 count int,
281 last_update datetime,
282
283 primary key (release_group, tag)
284);
285
286create table if not exists release_tag
287(
288 "release" bigint not null references "release" (id),
289 tag bigint not null references tag (id),
290 count int,
291 last_update datetime,
292
293 primary key ("release", tag)
294);
295
296create table if not exists tag
297(
298 id bigint primary key,
299 name text not null,
300 ref_count bigint
301);
302
303create table if not exists track
304(
305 id bigint primary key,
306 gid text not null,
307 recording bigint not null references recording (id),
308 medium bigint not null references medium (id),
309 position int,
310 number text,
311 name text not null,
312 artist_credit bigint not null references artist_credit (id),
313 length int,
314 edits_pending int,
315 last_updated datetime,
316 is_data_track text not null
317);
318
319create table if not exists track_gid_redirect
320(
321 gid text primary key,
322 new_id bigint not null,
323 created datetime not null
324);
325commit;