Get the FREE Ultimate OpenClaw Setup Guide →

database-migration

npx machina-cli add skill gologo13/agent-skills/database-migration --openclaw
Files (1)
SKILL.md
1.7 KB

Database Migration

Overview

Help create and manage database migrations, generating complete migration files following the project's database framework conventions.

Steps

  1. Migration Analysis
    • Review current database schema changes needed
    • Identify data transformation requirements
    • Check for potential data loss or corruption risks
    • Analyze performance impact of schema changes
  2. Migration Script Generation
    • Create up and down migration scripts
    • Include proper indexing and constraint management
    • Add data migration logic where needed
    • Implement rollback procedures
  3. Best Practices
    • Ensure migrations are atomic and reversible
    • Add proper error handling and validation
    • Include progress monitoring for large datasets
    • Consider zero-downtime deployment strategies
  4. Testing Strategy
    • Create test data scenarios
    • Verify migration on staging environment
    • Plan rollback procedures and testing
    • Document deployment steps and timing

Database Migration Checklist

  • Reviewed schema changes and data transformation requirements
  • Checked for potential data loss or corruption risks
  • Created up and down migration scripts
  • Included proper indexing and constraint management
  • Ensured migrations are atomic and reversible
  • Added error handling and validation
  • Created test data scenarios
  • Verified migration on staging environment
  • Documented deployment steps and timing

Source

git clone https://github.com/gologo13/agent-skills/blob/main/skills/database-migration/SKILL.mdView on GitHub

Overview

This skill helps create and manage database migrations by generating complete migration files that follow your project's database framework conventions. It covers analysis of schema changes, script generation for up and down migrations, and testing strategies to minimize risk and downtime.

How This Skill Works

First, analyze the required schema changes and data transformation needs while assessing risk and performance impact. Then generate up and down migration scripts with proper indexing, constraints, and data migration steps, including rollback procedures and validation hooks. Finally, apply a testing strategy on staging to confirm correctness and plan deployment steps.

When to Use It

  • Planning a schema change that touches multiple tables
  • Transforming data with migrations that require data migration logic
  • Implementing atomic, reversible migrations with rollback procedures
  • Pursuing zero-downtime deployment strategies for large datasets
  • Testing migrations in a staging environment before production

Quick Start

  1. Step 1: Analyze required schema changes and data transformation needs
  2. Step 2: Generate up and down migration scripts with indexing, constraints, and rollback logic
  3. Step 3: Test on staging, verify data integrity, and document deployment steps

Best Practices

  • Ensure migrations are atomic and reversible
  • Add proper error handling and validation
  • Include progress monitoring for large datasets
  • Include proper indexing and constraint management
  • Plan rollback procedures and timing for zero-downtime deployment

Example Use Cases

  • Adding a new indexed column to users and creating a corresponding down script
  • Splitting a denormalized address field into a separate table with data migration logic
  • Converting a varchar date field to a timestamp with a data migration
  • Performing zero-downtime schema changes using online index builds and careful versioning
  • Testing and validating migrations on staging before production rollout

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers