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