database-migrations-sql-migrations
SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, and SQL Server. Focus on data integrity and rollback plans.
About this skill
This skill transforms an AI agent into a specialized SQL database migration expert. It enables the agent to design and implement robust migration strategies for PostgreSQL, MySQL, and SQL Server, prioritizing zero-downtime deployments and stringent data integrity. The agent can generate comprehensive migration scripts, including detailed rollback procedures, essential validation checks, and performance optimization considerations. This ensures that database schema and data changes are executed safely, efficiently, and with minimal impact on live applications.
Best use case
Planning and executing complex database schema or data changes. Ensuring high availability during database updates. Developing robust rollback strategies for mission-critical systems. Generating precise SQL scripts for various database systems. Seeking best practices and checklists for production-ready migrations.
SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, and SQL Server. Focus on data integrity and rollback plans.
Comprehensive SQL migration scripts tailored for PostgreSQL, MySQL, or SQL Server. Detailed rollback plans to revert changes safely. Validation checks and performance optimization strategies. Guidance on zero-downtime deployment best practices. Checklists and strategic advice for robust database migrations.
Practical example
Example input
I need to add a new `email` column (VARCHAR(255), NULLABLE) to the `users` table in a PostgreSQL production database. The `users` table currently has `id`, `name`, `created_at`. Provide a zero-downtime migration script, a rollback plan, and specify any necessary validation steps. Assume the application code will be updated to use the new column after the migration.
Example output
-- Migration Plan for PostgreSQL: Add 'email' column to 'users' table -- Database: PostgreSQL -- Table: users -- New Column: email VARCHAR(255) NULL -- Strategy: Zero-downtime, staged deployment -- Phase 1: Add the new column as NULLABLE -- This is a non-blocking operation in PostgreSQL for adding a NULLABLE column. ALTER TABLE users ADD COLUMN email VARCHAR(255) NULL; -- Validation Step 1: Verify column existence SELECT column_name, data_type, is_nullable FROM information_schema.columns WHERE table_name = 'users' AND column_name = 'email'; -- Expected outcome: 'email' column exists, data_type is 'character varying', is_nullable is 'YES'. -- Rollback Plan (Phase 1): -- If an issue occurs after Phase 1 but before applications start using the new column: -- ALTER TABLE users DROP COLUMN email; -- Phase 2: Deploy application code that starts writing to the 'email' column. -- (This step is external to SQL scripts but critical for the zero-downtime strategy.) -- Ensure old application versions continue to function without errors. -- Phase 3: Backfill existing data (if necessary, e.g., if emails can be inferred from other data) -- For this scenario, assuming 'email' will be populated by new user actions or separate bulk import. -- If existing data needed migration: -- UPDATE users SET email = some_derived_value WHERE email IS NULL; -- Phase 4: Make the column NOT NULL (optional, if future data integrity requires it) -- This requires a separate migration *after* all existing rows have valid email addresses and applications are writing it. -- ALTER TABLE users ALTER COLUMN email SET NOT NULL; -- (This phase might require a further zero-downtime strategy of its own if the table is very large). -- Final Validation: -- After application deployment and some data has been written: -- SELECT id, name, email FROM users LIMIT 10; -- Check application logs for errors related to the new column. -- General Notes: -- - Monitor database performance and application logs closely during and after deployment. -- - Ensure adequate testing in staging environments before production. -- - Consider adding an index to the 'email' column if it will be frequently queried (e.g., for login). -- CREATE INDEX idx_users_email ON users (email);
When to use this skill
- When performing SQL database migrations that require zero-downtime.
- When changing database schemas (e.g., adding/modifying tables, columns, indexes).
- When migrating or transforming data within a SQL database.
- When needing guidance on best practices, checklists, or comprehensive strategies for database changes.
When not to use this skill
- When migrating NoSQL databases (e.g., MongoDB, Cassandra).
- When performing non-database-related tasks.
- When migrating data between entirely different database types (e.g., SQL to NoSQL, unless specifically for the SQL source/target part).
- When only requiring simple data inserts or updates that do not involve schema changes or complex migration logic.
Installation
Claude Code / Cursor / Codex
Manual Installation
- Download SKILL.md from GitHub
- Place it in
.claude/skills/database-migrations-sql-migrations/SKILL.mdinside your project - Restart your AI agent — it will auto-discover the skill
How database-migrations-sql-migrations Compares
| Feature / Agent | database-migrations-sql-migrations | Standard Approach |
|---|---|---|
| Platform Support | Claude | Limited / Varies |
| Context Awareness | High | Baseline |
| Installation Complexity | easy | N/A |
Frequently Asked Questions
What does this skill do?
SQL database migrations with zero-downtime strategies for PostgreSQL, MySQL, and SQL Server. Focus on data integrity and rollback plans.
Which AI agents support this skill?
This skill is designed for Claude.
How difficult is it to install?
The installation complexity is rated as easy. You can find the installation instructions above.
Where can I find the source code?
You can find the source code on GitHub using the link provided at the top of the page.
Related Guides
Best AI Skills for Claude
Explore the best AI skills for Claude and Claude Code across coding, research, workflow automation, documentation, and agent operations.
AI Agents for Startups
Explore AI agent skills for startup validation, product research, growth experiments, documentation, and fast execution with small teams.
AI Agents for Coding
Browse AI agent skills for coding, debugging, testing, refactoring, code review, and developer workflows across Claude, Cursor, and Codex.
SKILL.md Source
# SQL Database Migration Strategy and Implementation ## Overview You are a SQL database migration expert specializing in zero-downtime deployments, data integrity, and production-ready migration strategies for PostgreSQL, MySQL, and SQL Server. Create comprehensive migration scripts with rollback procedures, validation checks, and performance optimization. ## When to Use This Skill - Use when working on SQL database migration strategy and implementation tasks. - Use when needing guidance, best practices, or checklists for zero-downtime migrations. - Use when designing rollback procedures for critical schema changes. ## Do Not Use This Skill When - The task is unrelated to SQL database migration strategy. - You need a different domain or tool outside this scope. ## Context The user needs SQL database migrations that ensure data integrity, minimize downtime, and provide safe rollback options. Focus on production-ready strategies that handle edge cases, large datasets, and concurrent operations. ## Instructions - Clarify goals, constraints, and required inputs. - Apply relevant best practices and validate outcomes. - Provide actionable steps and verification. - If detailed examples are required, suggest checking implementation playbooks. ## Output Format 1. **Migration Analysis Report**: Detailed breakdown of changes 2. **Zero-Downtime Implementation Plan**: Expand-contract or blue-green strategy 3. **Migration Scripts**: Version-controlled SQL with framework integration 4. **Validation Suite**: Pre and post-migration checks 5. **Rollback Procedures**: Automated and manual rollback scripts 6. **Performance Optimization**: Batch processing, parallel execution 7. **Monitoring Integration**: Progress tracking and alerting ## Resources - Focus on production-ready SQL migrations with zero-downtime deployment strategies, comprehensive validation, and enterprise-grade safety mechanisms.
Related Skills
database-optimizer
Expert database optimizer specializing in modern performance tuning, query optimization, and scalable architectures.
database-migration
Master database schema and data migrations across ORMs (Sequelize, TypeORM, Prisma), including rollback strategies and zero-downtime deployments.
claimable-postgres
Provision instant temporary Postgres databases via Claimable Postgres by Neon (pg.new). No login or credit card required. Use for quick Postgres environments and throwaway DATABASE_URL for prototyping.
azure-cosmos-rust
Azure Cosmos DB SDK for Rust (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data.
azure-cosmos-py
Azure Cosmos DB SDK for Python (NoSQL API). Use for document CRUD, queries, containers, and globally distributed data.
azure-cosmos-db-py
Build production-grade Azure Cosmos DB NoSQL services following clean code, security best practices, and TDD principles.
food-database-query
Food Database Query
database
Database development and operations workflow covering SQL, NoSQL, database design, migrations, optimization, and data engineering.
database-migrations-migration-observability
Migration monitoring, CDC, and observability infrastructure
database-design
Database design principles and decision-making. Schema design, indexing strategy, ORM selection, serverless databases.
database-cloud-optimization-cost-optimize
You are a cloud cost optimization expert specializing in reducing infrastructure expenses while maintaining performance and reliability. Analyze cloud spending, identify savings opportunities, and implement cost-effective architectures across AWS, Azure, and GCP.
database-architect
Expert database architect specializing in data layer design from scratch, technology selection, schema modeling, and scalable database architectures.