allow on artist to have multiple urls
This commit is contained in:
@ -24,7 +24,6 @@ AS $$
|
|||||||
website_id integer,
|
website_id integer,
|
||||||
artist_id integer,
|
artist_id integer,
|
||||||
CONSTRAINT aw_url UNIQUE(url),
|
CONSTRAINT aw_url UNIQUE(url),
|
||||||
CONSTRAINT aw_folder_path UNIQUE(folder_path),
|
|
||||||
CONSTRAINT aw_artist FOREIGN KEY (artist_id) REFERENCES artist (ID),
|
CONSTRAINT aw_artist FOREIGN KEY (artist_id) REFERENCES artist (ID),
|
||||||
CONSTRAINT aw_website FOREIGN KEY (website_id) REFERENCES website (ID)
|
CONSTRAINT aw_website FOREIGN KEY (website_id) REFERENCES website (ID)
|
||||||
);
|
);
|
||||||
|
@ -16,18 +16,14 @@ BEGIN
|
|||||||
PERFORM * FROM artist a
|
PERFORM * FROM artist a
|
||||||
WHERE a.name = in_artist_name;
|
WHERE a.name = in_artist_name;
|
||||||
|
|
||||||
IF FOUND THEN
|
IF NOT FOUND THEN
|
||||||
RAISE EXCEPTION 'artist already exists';
|
INSERT INTO artist (name) VALUES (in_artist_name);
|
||||||
END IF;
|
END IF;
|
||||||
|
|
||||||
INSERT INTO artist_website (url) VALUES (in_url);
|
|
||||||
INSERT INTO artist (name) VALUES (in_artist_name);
|
|
||||||
|
|
||||||
SELECT artist.id INTO temp_artist_id FROM artist
|
SELECT artist.id INTO temp_artist_id FROM artist
|
||||||
WHERE artist.name = in_artist_name;
|
WHERE artist.name = in_artist_name;
|
||||||
|
|
||||||
UPDATE artist_website SET artist_id = temp_artist_id
|
INSERT INTO artist_website (url, artist_id) VALUES (in_url, temp_artist_id);
|
||||||
WHERE url = in_url;
|
|
||||||
|
|
||||||
SELECT * INTO ret_value FROM set_website_name(in_url);
|
SELECT * INTO ret_value FROM set_website_name(in_url);
|
||||||
IF ret_value <> 0 THEN
|
IF ret_value <> 0 THEN
|
||||||
|
Reference in New Issue
Block a user