From aj-geddes-useful-ai-prompts-4
Manages database migrations and schema versioning for PostgreSQL and MySQL. Covers rollback strategies, data transformations, and production deployment patterns.
How this skill is triggered — by the user, by Claude, or both
Slash command
/aj-geddes-useful-ai-prompts-4:database-migration-managementThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
- [Overview](#overview)
Implement robust database migration systems with version control, rollback capabilities, and data transformation strategies. Includes migration frameworks and production deployment patterns.
Minimal working example:
-- Create migrations tracking table
CREATE TABLE schema_migrations (
version BIGINT PRIMARY KEY,
name VARCHAR(255) NOT NULL,
executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
duration_ms INTEGER,
checksum VARCHAR(64)
);
-- Create migration log table
CREATE TABLE migration_logs (
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
version BIGINT NOT NULL,
status VARCHAR(20) NOT NULL,
error_message TEXT,
rolled_back_at TIMESTAMP,
executed_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);
-- Function to record migration
CREATE OR REPLACE FUNCTION record_migration(
p_version BIGINT,
p_name VARCHAR,
p_duration_ms INTEGER
) RETURNS void AS $$
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Adding Columns | Adding Columns |
| Renaming Columns | Renaming Columns |
| Creating Indexes Non-blocking | Creating Indexes Non-blocking |
| Data Transformations | Data Transformations |
| Table Structure Changes | Table Structure Changes |
npx claudepluginhub aj-geddes/useful-ai-promptsCreates, validates, executes, and rolls back schema migrations for PostgreSQL, MySQL, MongoDB using Flyway, Alembic, Prisma, Knex.
Plans and executes safe database schema migrations with rollback strategies, zero-downtime deployments, and data transformations. Covers Drizzle, Prisma, and raw SQL migrations.
Provides patterns for safe database schema changes, data migrations, rollbacks, and zero-downtime deployments across PostgreSQL, MySQL, and common ORMs.