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
23 if [[ -f "/create-workbench-api-client.rb" ]]; then
24 # This is the API server
25 cd /var/www/arvados-api/current
26 bundle exec script/create_superuser_token.rb thisisnotaverygoodsuperusersecretstring00000000000
28 bundle exec get_anonymous_user_token.rb -t thisisnotaverygoodanonymoussecretstring00000000000 || true
29 bundle exec rails runner /create-workbench-api-client.rb
33 prepare_database "db:schema:load"