bb4619aefe
Adds a new cron blueprint with UUID-keyed jobs that Cronicle triggers via HTTP POST with a shared secret header. Also adds scripts/migrate-new.sh so migrations can be generated locally against a Docker postgres when no prod container is running. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
44 lines
1.4 KiB
Bash
Executable File
44 lines
1.4 KiB
Bash
Executable File
#!/bin/bash
|
|
# Generate a new aerich migration.
|
|
# If a raggr container is running, exec into it.
|
|
# Otherwise, spin up the local postgres service and run aerich from the venv.
|
|
set -euo pipefail
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
# Load .env so POSTGRES_* vars are available locally
|
|
if [ -f .env ]; then
|
|
set -a
|
|
# shellcheck disable=SC1091
|
|
source .env
|
|
set +a
|
|
fi
|
|
|
|
POSTGRES_USER="${POSTGRES_USER:-raggr}"
|
|
POSTGRES_PASSWORD="${POSTGRES_PASSWORD:-changeme}"
|
|
POSTGRES_DB="${POSTGRES_DB:-raggr}"
|
|
LOCAL_DB_URL="postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@localhost:5432/${POSTGRES_DB}"
|
|
|
|
read -rp "Migration name: " name
|
|
|
|
RUNNING=$(docker compose ps --status running --services 2>/dev/null | grep -oE 'raggr-(blue|green)' | head -1 || true)
|
|
|
|
if [ -n "$RUNNING" ]; then
|
|
echo "==> Using running container: $RUNNING"
|
|
docker compose --profile blue --profile green exec "$RUNNING" aerich migrate --name "$name"
|
|
else
|
|
echo "==> No raggr container running — using local postgres"
|
|
docker compose up -d postgres
|
|
|
|
echo "==> Waiting for postgres to be ready..."
|
|
until docker compose exec -T postgres pg_isready -U "$POSTGRES_USER" > /dev/null 2>&1; do
|
|
sleep 1
|
|
done
|
|
|
|
echo "==> Applying existing migrations..."
|
|
DATABASE_URL="$LOCAL_DB_URL" .venv/bin/aerich upgrade
|
|
|
|
echo "==> Generating migration: $name"
|
|
DATABASE_URL="$LOCAL_DB_URL" .venv/bin/aerich migrate --name "$name"
|
|
fi
|