2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: Apache-2.0
9 RAILSPKG_DATABASE_LOAD_TASK="$1"
10 DB_MIGRATE_STATUS=$($COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1 || true)
11 if echo "$DB_MIGRATE_STATUS" | grep -qF 'Schema migrations table does not exist yet.'; then
12 # The database exists, but the migrations table doesn't.
13 bundle exec rake "$RAILSPKG_DATABASE_LOAD_TASK" db:seed
14 elif echo "$DB_MIGRATE_STATUS" | grep -q '^database: '; then
15 bundle exec rake db:migrate
16 elif echo "$DB_MIGRATE_STATUS" | grep -q 'database .* does not exist'; then
17 bundle exec rake db:setup
19 echo "Warning: Database is not ready to set up." >&2
24 prepare_database "db:schema:load"