Change Foreign Key relationship for ResourceBase and Thumbnail

Prevents duplicate thumbnails when updatelayers is run

Restores lost logic in updatelayers gs_slurp from old bulk merge
Merge branch 'thumbnail_fix_pr' (new) into link_fix