allow on artist to have multiple urls

This commit is contained in:
2025-01-29 18:51:45 +01:00
parent 9e83c1ecc1
commit cbf78bd64e
2 changed files with 3 additions and 8 deletions

View File

@ -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)
);

View File

@ -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