db/scripts/diff.sh

24 lines
530 B
Bash
Raw Normal View History

#! /bin/bash
2023-06-09 01:29:13 +00:00
set -e
source ./scripts/env.sh ./.env.schema
2023-06-09 01:29:13 +00:00
rev=${1:-}
head_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5432/$POSTGRES_DB
base_url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:5433/$POSTGRES_DB
if [[ -z "$rev" ]]; then
echo "revision to diff is required";
exit 1;
fi
docker compose up -d
./scripts/build.sh $rev
./scripts/build.sh HEAD
echo "migrate from $rev => HEAD" 1>&2
migra --unsafe $base_url $head_url || echo "migra exited with code $?. this is /probably/ fine" 1>&2