#!/usr/bin/env bash

set -euo pipefail

cd "$(dirname "$0")/../../" # Navigate to the root of the project

direction="${1:-upgrade}"
revision="${2:-head}"

# downgradeだけ入力された場合
if [ "$direction" == "downgrade" ] && [ "$revision" == "head" ]; then
    revision="base"
fi

cd database/migration
alembic "$direction" "$revision"
