#!/usr/bin/env bash # # Usage: bin/heroku_deploy . ./shell_colors set -euo pipefail schema_version=$(bin/rails db:version | { grep "^Current version: [0-9]\\+$" || true; } | tr -s ' ' | cut -d ' ' -f3) if [ -z "$schema_version" ]; then printf "šŸ’€${RED} [Release Phase]: Database schema version could not be determined. Does the database exist?${NO_COLOR}\n" exit 1 fi if [ "$schema_version" -eq "0" ]; then printf "\nā³${YELLOW} [Release Phase]: Loading the database schema.${NO_COLOR}\n" bin/rails db:schema:load else printf "\nā³${YELLOW} [Release Phase]: Running database migrations.${NO_COLOR}\n" bin/rails db:migrate fi printf "\nšŸŽ‰${GREEN} [Release Phase]: Database is up to date.${NO_COLOR}\n"