Change Foreign Key relationship for ResourceBase and Thumbnail

Prevents duplicated thumbnail db objects and files

Cleans up thumbnails after a Resource is deleted
Changed the Thumbnail delete logic and fix tests
Merge branch 'thumbnail_fix_pr_2' into thumbnail_fix_pr