run: install-dependencies start-database migrate-database seed-database mix phx.server install-dependencies: mix deps.get migrate-database: mix ash.setup reset-database: mix ash.reset seed-database: mix run priv/repo/seeds.exs start-database: docker compose up -d ci-dev: lint audit test lint: mix format --check-formatted mix compile --warnings-as-errors mix credo audit: mix sobelow --config mix deps.audit mix hex.audit test: mix test format: mix format # Usage: # just regen-migrations migration_name [commit_hash] # If commit_hash is given, rollback & delete the migrations from that commit. # Otherwise, rollback & delete all untracked migrations. regen-migrations migration_name commit_hash='': #!/usr/bin/env bash set -euo pipefail # Pick migrations either from the given commit or untracked files if [ -n "{{commit_hash}}" ]; then echo "→ Rolling back migrations from commit {{commit_hash}}" MIG_FILES=$(git show --name-only --pretty=format: "{{commit_hash}}" \ | grep -E "^priv/repo/migrations/|^priv/resource_snapshots") else echo "→ Rolling back all untracked migrations" MIG_FILES=$(git ls-files --others priv/repo/migrations) fi # Roll back in Ash COUNT=$(echo "$MIG_FILES" | wc -l) mix ash_postgres.rollback -n "$COUNT" # Remove the migration files echo removing $MIG_FILES echo "$MIG_FILES" | xargs rm -f # Also clean up any untracked resource snapshots git ls-files --others priv/resource_snapshots | xargs rm -f # Generate a fresh migration mix ash.codegen --name "{{migration_name}}"