database-migration-assistant
PostgreSQL migration assistant that plans, applies, and rolls back schema changes with drift detection for safe AI-agent execution.
- License 许可
- AGPL-3.0
- 最近更新
- 2026-11-13
- Stars
- ★ 81
- Forks
- 17
01 前言 Front Matter
- name
- database-migration-assistant
- tags
- [ "database", "postgres", "migration", "rollback", "schema", "productivity", "ai" ]
- author
- Apple <skelitalynn@gmail.com>
- scripts
- { "enabled": true, "definitions": [ { "file": "plan_migrations.py", "name": "plan_migrations", "type": "python", "timeout": 30, "description": "Build a migration plan and detect drift." }, { "file": "apply_migrations.py", "name": "apply_migrations", "type": "python", "timeout": 60, "description": "Apply pending up migrations (supports dry-run)." }, { "file": "rollback_migrations.py", "name": "rollback_migrations", "type": "python", "timeout": 60, "description": "Roll back the latest migration or down to a target version." }, { "file": "generate_migration.py", "name": "generate_migration", "type": "python", "timeout": 30, "description": "Generate a new migration SQL template." } ], "working_directory": "./scripts" }
- version
- 1.0.0
- triggers
- [ { "type": "keyword", "keywords": [ "migration", "database migration", "schema migration", "rollback", "drift", "postgres", "schema change" ] } ]
- composable
- true
- parameters
- [ { "name": "action", "type": "string", "required": false, "description": "Operation to perform (plan/apply/rollback/generate)." }, { "name": "migrations_dir", "type": "string", "default": "migrations", "required": false, "description": "Directory that contains versioned SQL migration files." }, { "name": "dry_run", "type": "boolean", "default": false, "required": false, "description": "If true, show planned SQL without executing it." }, { "name": "to_version", "type": "string", "required": false, "description": "Target version for apply or rollback." }, { "name": "name", "type": "string", "required": false, "description": "Migration name when generating a template." } ]
- description
- PostgreSQL migration assistant that plans, applies, and rolls back schema changes with drift detection for safe AI-agent execution.
- persist_state
- true
- prerequisites
- { "skills": [], "env_vars": [ "DB_URL" ] }
02 资源文件 13
- 脚本examples/demo_agent.py639 B
- 参考文档examples/demo_prompt.txt93 B
- 参考文档examples/example_usage.md267 B
- 其他examples/example.env57 B
- 其他migrations/20260208_091909_create_users_table.sql234 B
- 参考文档README.md7.4 KB
- 脚本scripts/apply_migrations.py3.6 KB
- 脚本scripts/generate_migration.py2.3 KB
- 脚本scripts/migration_utils.py4.3 KB
- 脚本scripts/plan_migrations.py2.3 KB
- 脚本scripts/rollback_migrations.py3.6 KB
- 参考文档SOURCE.md389 B
- 参考文档TRUST.auto.yaml2.1 KB
03 SKILL.md 正文
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.
04 同仓库更多 Skills
recipe-performance
Diagnose a specific MetaMask user flow's real-app performance and Sentry critical-user-flow telemetry with deterministic mm-harness recipes. Use for CUF boundaries, cold/warm/background-resume behavior, latency regressions, lifecycle tags, duplicate or blocking network requests, long tasks, layout/paint cost, screen redraws, React rerenders, or browser trace analysis where tests alone cannot prove the real app.
mexc-spot-websocket
MEXC Spot WebSocket workflows for public streams, protobuf handling, depth maintenance, listen keys, and private streams without exposing API keys.
mexc-spot-rest
MEXC Spot REST workflows for public data, signed account requests, orders, wallet/admin actions, and secure signing without exposing API keys.
mexc-futures-websocket
MEXC Futures WebSocket workflows for public streams, private account/order/position streams, ping/pong, subscriptions, and depth maintenance.
0xklen-version-and-refresh-sanctions-lists
暂无简介
verify-tests-cover-changed-lines
Use when a PR adds code that the existing suite may not exercise. Measures patch coverage — the share of newly changed lines hit by tests — before approving.