Database Migration Assistant with Rollback
A PostgreSQL migration assistant that makes schema changes safe and repeatable.
It provides plan/apply/rollback workflows with drift detection, and exposes stable CLI tools for AI agents to call.
Designed for production safety: preview first, confirm, then execute.
Quick Start
from spoon_ai.agents import SpoonReactSkill
agent = SpoonReactSkill(
name="db_migration_agent",
skill_paths=["./ai-productivity"],
scripts_enabled=True
)
result = await agent.run("Plan database migrations for this project")
print(result)
Scripts
| Script | Purpose |
|--------|---------|
| plan_migrations.py | Build a migration plan and detect drift |
| apply_migrations.py | Apply pending up migrations (supports dry-run) |
| rollback_migrations.py | Roll back the latest migration or to a target version |
| generate_migration.py | Generate a new migration SQL template |
Environment Variables
| Variable | Required | Description |
|----------|----------|-------------|
| DB_URL | Yes | PostgreSQL connection string, e.g. postgresql://user:pass@host:5432/db |
Best Practices
- Always run
planand review the output beforeapply. - In production, require explicit confirmation and a recent backup.
- Treat migration files as append-only; never edit applied migrations.