Add migrate DB repository consistency check

To automatically detect issue like #768