mirror of
https://github.com/standardebooks/web.git
synced 2025-07-16 03:16:36 -04:00
Delete unreferenced artists after updating artwork
Also clean up ArtistAlternateSpellings at the same time we delete an artist
This commit is contained in:
parent
8b62a9130c
commit
60c6142688
2 changed files with 22 additions and 0 deletions
|
@ -141,5 +141,25 @@ class Artist extends PropertiesBase{
|
||||||
from Artists
|
from Artists
|
||||||
where ArtistId = ?
|
where ArtistId = ?
|
||||||
', [$this->ArtistId]);
|
', [$this->ArtistId]);
|
||||||
|
Db::Query('
|
||||||
|
DELETE
|
||||||
|
from ArtistAlternateSpellings
|
||||||
|
where ArtistId = ?
|
||||||
|
', [$this->ArtistId]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static function DeleteUnreferencedArtists(): void{
|
||||||
|
Db::Query('
|
||||||
|
DELETE
|
||||||
|
from Artists
|
||||||
|
where ArtistId NOT IN
|
||||||
|
(SELECT DISTINCT ArtistId FROM Artworks)
|
||||||
|
');
|
||||||
|
Db::Query('
|
||||||
|
DELETE
|
||||||
|
from ArtistAlternateSpellings
|
||||||
|
where ArtistId NOT IN
|
||||||
|
(SELECT DISTINCT ArtistId FROM Artworks)
|
||||||
|
');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -731,6 +731,8 @@ class Artwork extends PropertiesBase{
|
||||||
$this->ArtworkId]
|
$this->ArtworkId]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Artist::DeleteUnreferencedArtists();
|
||||||
|
|
||||||
Db::Query('
|
Db::Query('
|
||||||
DELETE FROM ArtworkTags
|
DELETE FROM ArtworkTags
|
||||||
WHERE
|
WHERE
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue