* Remove fk in scheduled_query_stats table and clean up orphan rows for it * Improve test and fix bug with the cleanup