Browse files

daemon: Fix artist clean up

  • Loading branch information...
1 parent 904d771 commit c8b7d6f7517810d2007f6172f6337d3963b27a41 @alexkay committed May 4, 2012
Showing with 14 additions and 4 deletions.
  1. +14 −4 daemon/releases.py
View
18 daemon/releases.py
@@ -73,10 +73,20 @@ def check():
SET "artist_id" = %s
WHERE "artist_id" = %s
""", [new_artist.id, artist.id])
- # Mark release groups as deleted.
- n = artist.releasegroup_set.update(is_deleted=True)
- logging.info('Deleted %s release groups' % n)
- artist.delete()
+ # Delete the artist and its release groups.
+ # Use SQL, delete() is buggy, see Django bug #16426.
+ # TODO: possible FK constraint fail in app_star.
+ cursor.execute(
+ """
+ DELETE FROM "app_releasegroup"
+ WHERE "artist_id" = %s
+ """, [artist.id])
+ logging.info('Deleted release groups')
+ cursor.execute(
+ """
+ DELETE FROM "app_artist"
+ WHERE "id" = %s
+ """, [artist.id])
logging.info('Deleted the artist')
continue
else:

0 comments on commit c8b7d6f

Please sign in to comment.