Rearrange order of Album.delete ops to not void FK contraint.

This commit is contained in:
voussoir 2018-06-30 12:51:09 -07:00
parent c736c33165
commit c930228d3f

View file

@ -399,9 +399,9 @@ class Album(ObjectBase, GroupableMixin):
def delete(self, *, delete_children=False, commit=True): def delete(self, *, delete_children=False, commit=True):
self.photodb.log.debug('Deleting %s', self) self.photodb.log.debug('Deleting %s', self)
GroupableMixin.delete(self, delete_children=delete_children, commit=False) GroupableMixin.delete(self, delete_children=delete_children, commit=False)
self.photodb.sql_delete(table='albums', pairs={'id': self.id})
self.photodb.sql_delete(table='album_photo_rel', pairs={'albumid': self.id})
self.photodb.sql_delete(table='album_associated_directories', pairs={'albumid': self.id}) self.photodb.sql_delete(table='album_associated_directories', pairs={'albumid': self.id})
self.photodb.sql_delete(table='album_photo_rel', pairs={'albumid': self.id})
self.photodb.sql_delete(table='albums', pairs={'id': self.id})
self._uncache() self._uncache()
if commit: if commit:
self.photodb.log.debug('Committing - delete album') self.photodb.log.debug('Committing - delete album')