fix migration to prevent problems when starting database from scratch