Get database migration best practices for safe schema changes and zero-downtime releases.
Copy the install command and let the AI configure it · recommended for beginners
Please install the "database-migrations" skill from askskill: 1. Download https://raw.githubusercontent.com/affaan-m/ECC/main/skills/database-migrations/SKILL.md 2. Save it as ~/.claude/skills/database-migrations/SKILL.md 3. Reload skills and tell me it's ready
I need to add a non-null status column to a PostgreSQL users table with lots of production data. Give me a zero-downtime migration plan with step-by-step SQL, backfill strategy, index handling, validation, and rollback steps.
A practical phased migration plan with SQL, risk controls, and rollback guidance.
Create database migration best practices for Prisma and TypeORM projects, covering naming conventions, review checklists, how to avoid destructive changes, data migration handling, and CI/CD release recommendations.
A reusable migration standard and checklist for ORM-based teams.
A production MySQL migration failed halfway and some data was already written. Help me analyze common causes and provide troubleshooting steps, rollback strategies, data consistency checks, and prevention advice.
A troubleshooting and recovery guide for failed migrations with prevention recommendations.
Safe, reversible database schema changes for production systems.
Before applying any migration:
-- GOOD: Nullable column, no lock
ALTER TABLE users ADD COLUMN avatar_url TEXT;
-- GOOD: Column with default (Postgres 11+ is instant, no rewrite)
ALTER TABLE users ADD COLUMN is_active BOOLEAN NOT NULL DEFAULT true;
-- BAD: NOT NULL without default on existing table (requires full rewrite)
ALTER TABLE users ADD COLUMN role TEXT NOT NULL;
-- This locks the table and rewrites every row
-- BAD: Blocks writes on large tables
CREATE INDEX idx_users_email ON users (email);
-- GOOD: Non-blocking, allows concurrent writes
CREATE INDEX CONCURRENTLY idx_users_email ON users (email);
-- Note: CONCURRENTLY cannot run inside a transaction block
-- Most migration tools need special handling for this
Never rename directly in production. Use the expand-contract pattern:
-- Step 1: Add new column (migration 001)
ALTER TABLE users ADD COLUMN display_name TEXT;
-- Step 2: Backfill data (migration 002, data migration)
UPDATE users SET display_name = username WHERE display_name IS NULL;
-- Step 3: Update application code to read/write both columns
-- Deploy application changes
-- Step 4: Stop writing to old column, drop it (migration 003)
ALTER TABLE users DROP COLUMN username;
-- Step 1: Remove all application references to the column
-- Step 2: Deploy application without the column reference
-- Step 3: Drop column in next migration
ALTER TABLE orders DROP COLUMN legacy_status;
-- For Django: use SeparateDatabaseAndState to remove from model
-- without generating DROP COLUMN (then drop in next migration)
-- BAD: Updates all rows in one transaction (locks table)
UPDATE users SET normalized_email = LOWER(email);
-- GOOD: Batch update with progress
DO $$
DECLARE
batch_size INT := 10000;
rows_updated INT;
BEGIN
LOOP
UPDATE users
SET normalized_email = LOWER(email)
WHERE id IN (
SELECT id FROM users
WHERE normalized_email IS NULL
LIMIT batch_size
FOR UPDATE SKIP LOCKED
);
GET DIAGNOSTICS rows_updated = ROW_COUNT;
RAISE NOTICE 'Updated % rows', rows_updated;
EXIT WHEN rows_updated = 0;
COMMIT;
END LOOP;
END $$;
# Create migration from schema changes
npx prisma migrate dev --name add_user_avatar
# Apply pending migrations in production
npx prisma migrate deploy
# Reset database (dev only)
npx prisma migrate reset
# Generate client after schema changes
npx prisma generate
…
Audit Claude skills and commands with quick scans or full stocktakes.
Create iOS liquid glass interfaces with dynamic visuals and interactive morphing.
Record polished web app UI demo videos for walkthroughs, tutorials, and showcases.
Plan demand forecasts, safety stock, and replenishment for multi-location retail inventory.
Unify multi-channel notifications for routing, deduplication, escalation, and inbox consolidation.
Audit, plan, and implement SEO improvements for better search visibility.
Manage schemas, run queries, and inspect SQLite and PostgreSQL databases with Drizzle.
Get PostgreSQL best practices for optimization, schema design, indexing, and security.
Detect dangerous PostgreSQL migration locks and suggest safer rewrite strategies.
Connect to major databases for efficient querying, analysis, and data management.
Connect to PostgreSQL for CRUD, schema management, and database introspection.
Plan Convex schema and data migrations for safe, zero-downtime rollouts.