36 lines
812 B
Bash
Executable File
36 lines
812 B
Bash
Executable File
#! /bin/bash
|
|
|
|
set -e
|
|
|
|
source ./scripts/env.sh ./.env.schema
|
|
|
|
docker compose down
|
|
|
|
base_or_head="$1"
|
|
rev="$2"
|
|
|
|
git worktree remove "./$base_or_head" || true
|
|
git worktree add "./$base_or_head" --detach "$rev"
|
|
|
|
mkdir -p "./$base_or_head/data/$base_or_head"
|
|
ln -sr "../data/$base_or_head" "./$base_or_head/data/$base_or_head"
|
|
cp docker-compose.yml "./$base_or_head/docker-compose.yml"
|
|
|
|
cd "./$base_or_head"
|
|
docker compose up -d "$base_or_head"
|
|
cd "../$base_or_head"
|
|
|
|
if [[ "$base_or_head" = "head" ]]; then
|
|
port=5433
|
|
else
|
|
port=5432
|
|
fi
|
|
|
|
url=postgresql://$POSTGRES_USER:$POSTGRES_PASSWORD@localhost:$port
|
|
|
|
dropdb=$(mktemp)
|
|
echo "drop database dnim with (force); create database dnim;" > "$dropdb"
|
|
psql --quiet "$url/postgres" --file="$dropdb"
|
|
|
|
ls ./schema/ | xargs -I{} psql --quiet "$url/dnim" --file=./schema/{}
|