AGENT SKILL

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

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

  1. Always run plan and review the output before apply.
  2. In production, require explicit confirmation and a recent backup.
  3. Treat migration files as append-only; never edit applied migrations.

04 同仓库更多 Skills