Use async DB queries for schema integrity check

Addresses #521