#!/usr/bin/env bash
# shellcheck disable=SC2188

<<COMMENT
This is the script we use to run any required commands that have to live before a rollout

Right now, that just means reseeding the production db and setting up the new prisma schema

Called By: A job definition in our Helm k8s app templates
COMMENT

set -eo pipefail

cd $(dirname "$0")/..

if ! [[ -z $1 ]]; then
    export PALOLO_ENV=$1
fi

set -u

pnpm --dir=packages/server run secrets "${PALOLO_ENV?}" --deploy
pnpm --dir=packages/server run prisma migrate deploy
pnpm --dir=packages/server run seed-production
