Backend Migrations

Generate reversible database migration files with rollback methods and index management.

Updated Mar 13, 2023
One-click install
npx skills add https://github.com/pdovhomilja/dovhomilja-cz --skill backend-migrations-pdovhomilja
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: Backend Migrations
Source: https://github.com/pdovhomilja/dovhomilja-cz/tree/main/.claude/skills/backend-migrations
Command: npx skills add https://github.com/pdovhomilja/dovhomilja-cz --skill backend-migrations-pdovhomilja

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill ensures that database schema changes and data migrations are handled correctly, preventing errors, maintaining data integrity, and ensuring consistency across your application. It guides the AI to follow best practices for robust and reversible database evolution.

Core Features & Use Cases

  • Schema Evolution: Create and manage database migration files for adding, modifying, or removing tables and columns.
  • Data Integrity: Implement reversible migrations with rollback methods and manage database indexes for robust data handling.
  • Zero-Downtime Deployments: Guides the AI in separating schema changes from data migrations to support seamless updates.
  • Use Case: When adding a new feature that requires a new table and column, this skill guides the AI to generate a migration file that adheres to project standards, includes rollback logic, and considers strategies for zero-downtime deployment.

Quick Start

Generate a new database migration to add a 'status' column (string, nullable) to the 'users' table, ensuring it includes a rollback method and follows best practices for naming.

Frequently Asked Questions about Backend Migrations

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I create database migrations safely without downtime?

Database migrations apply schema changes reversibly by separating structural updates from data transformations. Use versioned migration files with rollback methods to enable zero-downtime deployments, ensuring backward compatibility and allowing you to revert changes if issues arise.

What's the best way to handle schema changes with Prisma?

Prisma migrations generate timestamped files in prisma/migrations that track all schema changes version-controlled. Write descriptive migration names, implement down methods for rollbacks, and manage constraints like foreign keys and NOT NULL to maintain data integrity across deployments.

How do I add columns to existing tables while maintaining data integrity?

Alter table migrations add or modify columns with proper constraint handling—use nullable columns for existing rows, then tighten constraints in follow-up migrations. Index large tables strategically and separate schema changes from data population to prevent locks and ensure consistency.

Can I rollback database migrations if something goes wrong?

Reversible migrations include down methods that undo schema changes, allowing safe rollback if deployment fails. Version control tracks all migration files, letting you revert to previous states and diagnose issues without data loss.

Why separate schema migrations from data migrations?

Splitting schema changes from data transformations enables zero-downtime deployments—deploy schema first, then data migrations in background jobs. This prevents application downtime, reduces lock contention on large tables, and lets you abort data operations independently if needed.

Do I need descriptive migration file names?

Descriptive naming—like `add_status_column_to_users`—documents intent, aids debugging, and helps teams understand schema evolution. Combined with timestamps, it prevents naming conflicts and makes version control history readable across your entire database changelog.