---
name: database-migration-assistant
description: PostgreSQL migration assistant that plans, applies, and rolls back schema changes with drift detection for safe AI-agent execution.
author: Apple skelitalynn@gmail.com
version: 1.0.0
tags:
name: rollback_migrations
description: Roll back the latest migration or down to a target version.
type: python
file: rollback_migrations.py
timeout: 60
name: generate_migration
description: Generate a new migration SQL template.
type: python
file: generate_migration.py
timeout: 30
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 plan and review the output before apply.
In production, require explicit confirmation and a recent backup.
Treat migration files as append-only; never edit applied migrations.
1---2name: database-migration-assistant3description: ---4---5---6name: database-migration-assistant7description: PostgreSQL migration assistant that plans, applies, and rolls back schema changes with drift detection for safe AI-agent execution.8author: Apple <skelitalynn@gmail.com>9version: 1.0.010tags:11 - database12 - postgres13 - migration14 - rollback15 - schema16 - productivity17 - ai18triggers:19 - type: keyword20 keywords:21 - migration22 - database migration23 - schema migration24 - rollback25 - drift26 - postgres27 - schema change28parameters:29 - name: action30 type: string31 required: false32 description: Operation to perform (plan/apply/rollback/generate).33 - name: migrations_dir34 type: string35 required: false36 default: migrations37 description: Directory that contains versioned SQL migration files.38 - name: dry_run39 type: boolean40 required: false41 default: false42 description: If true, show planned SQL without executing it.43 - name: to_version44 type: string45 required: false46 description: Target version for apply or rollback.47 - name: name48 type: string49 required: false50 description: Migration name when generating a template.51prerequisites:52 env_vars:53 - DB_URL54 skills: []55composable: true56persist_state: true57scripts:58 enabled: true59 working_directory: ./scripts60 definitions:61 - name: plan_migrations62 description: Build a migration plan and detect drift.63 type: python64 file: plan_migrations.py65 timeout: 3066 - name: apply_migrations67 description: Apply pending up migrations (supports dry-run).68 type: python69 file: apply_migrations.py70 timeout: 6071 - name: rollback_migrations72 description: Roll back the latest migration or down to a target version.73 type: python74 file: rollback_migrations.py75 timeout: 6076 - name: generate_migration77 description: Generate a new migration SQL template.78 type: python79 file: generate_migration.py80 timeout: 3081---8283# Database Migration Assistant with Rollback8485A PostgreSQL migration assistant that makes schema changes safe and repeatable. 86It provides plan/apply/rollback workflows with drift detection, and exposes stable CLI tools for AI agents to call. 87Designed for production safety: preview first, confirm, then execute.888990## Quick Start9192```python93from spoon_ai.agents import SpoonReactSkill9495agent = SpoonReactSkill(96 name="db_migration_agent",97 skill_paths=["./ai-productivity"],98 scripts_enabled=True99)100101result = await agent.run("Plan database migrations for this project")102print(result)103104```105106## Scripts107108| Script | Purpose |109|--------|---------|110| [plan_migrations.py](scripts/plan_migrations.py) | Build a migration plan and detect drift |111| [apply_migrations.py](scripts/apply_migrations.py) | Apply pending up migrations (supports dry-run) |112| [rollback_migrations.py](scripts/rollback_migrations.py) | Roll back the latest migration or to a target version |113| [generate_migration.py](scripts/generate_migration.py) | Generate a new migration SQL template |114115## Environment Variables116117| Variable | Required | Description |118|----------|----------|-------------|119| `DB_URL` | Yes | PostgreSQL connection string, e.g. postgresql://user:pass@host:5432/db |120121## Best Practices1221231. Always run `plan` and review the output before `apply`.1242. In production, require explicit confirmation and a recent backup.1253. Treat migration files as append-only; never edit applied migrations.
Run npx skillmds@latest add xspoonai/database-migration-assistant in your terminal (requires Node.js), paste this page's agent-chat prompt into Claude, Cursor, or any MCP-connected agent, or download the SKILL.md file and copy it into your agent's skills directory.
--- It is listed under Coding & Dev Tools on SkillMD.
This skill has not completed SkillMD's automated safety review yet. SkillMD never runs a skill's scripts for you; review the SKILL.md before installing.
This skill is tagged as working with Claude Code, Claude.ai, OpenAI Codex. SKILL.md is an open format, so most agents that read a skills directory can load it too.
Yes. Installing skills from SkillMD is free, and the skill stays under its author's original license.
XSpoonAi (@xspoonai) published this skill. Their other Agent Skills are listed on their SkillMD profile.