Moved foreign key checks from 'connection' event