forked from philipmat/discogs-xml2db
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfix_db.sql
33 lines (27 loc) · 1.16 KB
/
fix_db.sql
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
-- Add in missing Various artist
INSERT INTO artist(id, name)VALUES (194, 'Various');
CREATE TABLE TEMP AS
SELECT DISTINCT ON (t1.artist_id, t1.type) * FROM artists_images t1
ORDER BY t1.artist_id, t1.type, t1.width desc, t1.height desc;
DROP TABLE artists_images;
ALTER TABLE temp RENAME TO artists_images;
CREATE TABLE TEMP AS
SELECT DISTINCT ON (t1.label_id, t1.type) * FROM labels_images t1
ORDER BY t1.label_id, t1.type, t1.width desc, t1.height desc;
DROP TABLE labels_images;
ALTER TABLE temp RENAME TO labels_images;
CREATE TABLE TEMP AS
SELECT DISTINCT ON (t1.master_id, t1.type) * FROM masters_images t1
ORDER BY t1.master_id, t1.type, t1.width desc, t1.height desc;
DROP TABLE masters_images;
ALTER TABLE temp RENAME TO masters_images;
CREATE TABLE TEMP AS
SELECT DISTINCT ON (t1.release_id, t1.type) * FROM releases_images t1
ORDER BY t1.release_id, t1.type, t1.width desc, t1.height desc;
DROP TABLE releases_images;
ALTER TABLE temp RENAME TO releases_images;
-- Remove duplicate release labels tuples
CREATE TABLE tmp_release_labels AS
SELECT DISTINCT * FROM releases_labels;
DROP TABLE releases_labels;
ALTER TABLE tmp_release_labels RENAME TO releases_labels;