roadie/Scripts/MySQL/Upgrade0010.sql

13 lines
290 B
MySQL
Raw Normal View History

2019-11-28 17:38:26 +00:00
UPDATE `track`
set artistId = NULL
where id in (select t.id
from `track` t
where artistId IS NOT NULL
and artistId NOT IN (select id from `artist`));
ALTER TABLE `track`
ADD CONSTRAINT `track_artist_ibfk_1`
FOREIGN KEY (`artistId`)
REFERENCES `artist` (`id`)
ON DELETE SET NULL;