Allow deletion of media that are associated with galleries.

Right now the way the mapping is set up there is no cascade of deletes from the Media to the GalleryHasMedia. This means that if you attempt to delete Media and there are still GalleryHasMedia entities pointing at it you get a foreign key error.

Closes #576

Cascade removal from Media to GalleryHasMedia.
@dbu This cascades a deletion from the Media to the GalleryHasMedia (the joining entity). That way you can delete  a Media and it is removed from all galleries (the only logical course of action). As the code stands now you can only delete Media if they are not in any galleries.