Agent skill
migrate-baselhussain-ai-keto-meal-plan-ge
Database migration management (create, apply, rollback using Alembic)
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/migrate-baselhussain-ai-keto-meal-plan-ge
SKILL.md
User Input
$ARGUMENTS
Commands: up (apply), down (rollback), create <message>, status, history
Task
Manage database migrations using Alembic for the keto meal plan project.
Steps
-
Parse Arguments:
upor empty: Apply all pending migrationsdownordown <N>: Rollback N migrations (default: 1)create <message>: Create new migration from model changesstatus: Show current migration statushistory: Show migration history
-
Navigate to Backend Directory:
bashcd backend -
Execute Command:
For
up(Apply Migrations):bash# Show pending migrations first alembic current alembic heads # Apply migrations alembic upgrade head # Verify success alembic currentFor
down(Rollback):bash# Show current version alembic current # Rollback (default: 1 step) alembic downgrade -1 # Or rollback N steps if specified # alembic downgrade -N # Verify rollback alembic currentFor
create <message>(Create Migration):bash# Generate migration from SQLAlchemy model changes alembic revision --autogenerate -m "<message>" # Show generated migration file path # Example: database/migrations/versions/abc123_add_column.pyFor
status(Show Status):bash# Current version alembic current # Latest available version alembic heads # Check for pending migrations alembic upgrade head --sql | head -20For
history(Show History):bash# Show all migrations alembic history --verbose -
Validate Database Connection:
bash# Test database connection python -c "from src.lib.database import engine; print('✅ Database connection successful')" -
Output Summary:
✅ Migration Summary ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ Command: [up/down/create/status/history] Current Version: abc123_migration_name [Status information based on command] Database: [connection string without password] -
Recommendations:
- After
create: "Review migration file atdatabase/migrations/versions/XXX.pybefore applying" - After
up: "Migration applied successfully. Verify database schema." - After
down: "⚠️ Migration rolled back. Data may be lost. Verify database state."
- After
Example Usage
/migrate # Apply all pending migrations
/migrate up # Apply all pending migrations
/migrate down # Rollback last migration
/migrate down 2 # Rollback 2 migrations
/migrate create "Add user preferences" # Create new migration
/migrate status # Show migration status
/migrate history # Show migration history
Exit Criteria
- Migration command executes successfully
- Database connection verified
- Current migration version displayed
- Migration files reviewed (for create command)
Safety Notes
- Always backup production database before running migrations
- Review autogenerated migrations - Alembic may not detect all changes
- Test migrations on development database first
- Rollback carefully - downgrade may cause data loss
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?