2 # Copyright (C) The Arvados Authors. All rights reserved.
4 # SPDX-License-Identifier: Apache-2.0
8 RAILSPKG_DATABASE_LOAD_TASK="$1"
9 DB_MIGRATE_STATUS=$($COMMAND_PREFIX bundle exec rake db:migrate:status 2>&1 || true)
10 if echo "$DB_MIGRATE_STATUS" | grep -qF 'Schema migrations table does not exist yet.'; then
11 # The database exists, but the migrations table doesn't.
12 bundle exec rake "$RAILSPKG_DATABASE_LOAD_TASK" db:seed
13 elif echo "$DB_MIGRATE_STATUS" | grep -q '^database: '; then
14 bundle exec rake db:migrate
15 elif echo "$DB_MIGRATE_STATUS" | grep -q 'database .* does not exist'; then
16 bundle exec rake db:setup
18 echo "Warning: Database is not ready to set up." >&2
22 if [[ -f "/create-workbench-api-client.rb" ]]; then
23 # This is the API server
24 cd /var/www/arvados-api/current
25 # The script/rails command in the Arvados 2.1.0 release has an incorrect require path.
26 sed -i 's|rails/commands/server|rails/command|' script/rails
27 bundle exec script/create_superuser_token.rb {{ .Values.superUserSecret }}
29 bundle exec get_anonymous_user_token.rb -t {{ .Values.anonymousUserSecret }} || true
30 bundle exec rails runner /create-workbench-api-client.rb
35 prepare_database "db:structure:load"