Wait for the database to become ready.