#!/bin/bash -e

echo "entrypoint"
echo "${*}"

# If running the rails server then create or migrate existing database
# bundle exec puma -C config/puma.rb
# if [ "${*}" == "./bin/rails server" ]; then
#   ./bin/rails db:prepare
# fi

# Run database migrations when deploying to Render. It is not great, maybe there's a better way?
# https://community.render.com/t/release-command-for-db-migrations/247/6
if [ -z "$RENDER" ]; then echo "var is unset"; else bin/rails db:migrate; fi

exec "${@}"
