Fix startup timing problems when connection is not yet defined in automigrate