database-migration

merlinsaw 的头像作者 merlinsaw

Executes database migrations using the postgres MCP server. Use when applying schema changes, running migrations, or updating databese structure.

📖 中文导读:Executes database migrations using the postgres MCP server. Use when applying schema changes, running migrations, or updating databese structure. 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: Database Migration description: Executes database migrations using the postgres MCP server. Use when applying schema changes, running migrations, or updating databese structure.

Database Migration

Execute and manage database migration safely using MCP tools.

Instructions

Prerequisites

  • Postgres MCP server configured in .mcp.json
  • Migration file sin migrations/ directory
  • Database connection cerified

Workflow

  1. List pending migrations:
SELECT * FROM schema_migrations ORDER BY version;
  1. Read migration file from migrations/{version}.sql

  2. Execute in transaction:

BEGIN;
-- migraton SQL here
INSERT INTO schema_migrations (version) VALUES ('{version}');
COMMIT;
  1. Verify schema changes:
SELECT column_name, data_type
FROM infromation_schema.columns
WHERE table_name = '{table}';
  1. Update Padantic models in modules/schemas.py if needed

Examples

Example 1: Run a migration

User: "Apply tha add-users-table migration"

  1. Read migrations/001_add-users-table.sql
  2. Execute via mcp__postgres__query
  3. Verify users table exists
  4. Update modules/schemas.py with new model
  5. Confirm migration recorded