nomadcode/bin/migrate-up

17 lines
525 B
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
ROOT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
cd "$ROOT_DIR"
GOOSE_DRIVER="${GOOSE_DRIVER:-postgres}"
DATABASE_URL="${DATABASE_URL:-postgres://nomadcode:nomadcode@localhost:5432/nomadcode?sslmode=disable}"
GOOSE_DBSTRING="${GOOSE_DBSTRING:-$DATABASE_URL}"
if [[ -n "${GOOSE_BIN:-}" ]]; then
goose_cmd=("$GOOSE_BIN")
else
goose_cmd=(go run github.com/pressly/goose/v3/cmd/goose@v3.27.1)
fi
exec "${goose_cmd[@]}" -dir migrations "$GOOSE_DRIVER" "$GOOSE_DBSTRING" up