mirror of
https://github.com/sphildreth/roadie
synced 2024-11-12 23:47:07 +00:00
13 lines
290 B
MySQL
13 lines
290 B
MySQL
|
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;
|
||
|
|