Confirm successful installation by checking the skill directory location:
.cursor/skills/database-migrations
Restart Cursor to activate database-migrations. Access via /database-migrations in your agent's command palette.
β
Security Notice
We perform automated surface-level scans (Gen AI Scanner, Socket, Snyk) during installation. These checks detect common vulnerabilities but do not guarantee complete security. Always review skill source code and verify the publisher's reputation before production use.
Skills execute code in your environment. Always review source, verify the publisher, and test in isolation before production.
Safe, reversible database schema changes for production systems.
When to Activate
Creating or altering database tables
Adding/removing columns or indexes
Running data migrations (backfill, transform)
Planning zero-downtime schema changes
Setting up migration tooling for a new project
Core Principles
Every change is a migration β never alter production databases manually
Migrations are forward-only in production β rollbacks use new forward migrations
Schema and data migrations are separate β never mix DDL and DML in one migration
Test migrations against production-sized data β a migration that works on 100 rows may lock on 10M
Migrations are immutable once deployed β never edit a migration that has run in production
Migration Safety Checklist
Before applying any migration:
Migration has both UP and DOWN (or is explicitly marked irreversible)
No full table locks on large tables (use concurrent operations)
New columns have defaults or are nullable (never add NOT NULL without default)
Indexes created concurrently (not inline with CREATE TABLE for existing tables)
Data backfill is a separate migration from schema change
Tested against a copy of production data
Rollback plan documented
PostgreSQL Patterns
Adding a Column Safely
-- GOOD: Nullable column, no lockALTERTABLE users ADDCOLUMN avatar_url TEXT;-- GOOD: Column with default (Postgres 11+ is instant, no rewrite)ALTERTABLE users ADDCOLUMN is_active BOOLEANNOTNULLDEFAULTtrue;-- BAD: NOT NULL without default on existing table (requires full rewrite)ALTERTABLE users ADDCOLUMN role TEXTNOTNULL;-- This locks the table and rewrites every row
Adding an Index Without Downtime
-- BAD: Blocks writes on large tablesCREATEINDEX idx_users_email ON users (email);-- GOOD: Non-blocking, allows concurrent writesCREATEINDEX CONCURRENTLY idx_users_email ON users (email);-- Note: CONCURRENTLY cannot run inside a transaction block-- Most migration tools need special handling for this
Renaming a Column (Zero-Downtime)
Never rename directly in production. Use the expand-contract pattern:
-- Step 1: Add new column (migration 001)ALTERTABLE users ADDCOLUMN display_name TEXT;-- Step 2: Backfill data (migration 002, data migration)UPDATE users SET display_name = username WHERE display_name ISNULL;-- Step 3: Update application code to read/write both columns-- Deploy application changes-- Step 4: Stop writing to old column, drop it (migration 003)ALTERTABLE users DROPCOLUMN username;
Removing a Column Safely
-- Step 1: Remove all application references to the column-- Step 2: Deploy application without the column reference-- Step 3: Drop column in next migrationALTERTABLE orders DROPCOLUMN legacy_status;-- For Django: use SeparateDatabaseAndState to remove from model-- without generating DROP COLUMN (then drop in next migration)
Large Data Migrations
-- BAD: Updates all rows in one transaction (locks table)UPDATE users SET normalized_email = LOWER(email);-- GOOD: Batch update with progressDO $$
DECLARE batch_size INT :=10000; rows_updated INT;BEGINLOOPUPDATE users
SET normalized_email = LOWER(email)WHERE id IN(SELECT id FROM users
WHERE normalized_email ISNULLLIMIT batch_size
FORUPDATE SKIP LOCKED
); GET DIAGNOSTICS rows_updated = ROW_COUNT; RAISE NOTICE 'Updated % rows', rows_updated;EXITWHEN rows_updated =0;COMMIT;ENDLOOP;END $$;
Prisma (TypeScript/Node.js)
Workflow
# Create migration from schema changesnpx prisma migrate dev --name add_user_avatar
# Apply pending migrations in productionnpx prisma migrate deploy
# Reset database (dev only)npx prisma migrate reset
# Generate client after schema changesnpx prisma generate
Schema Example
model User {
id String @id @default(cuid())
email String @unique
name String?
avatarUrl String? @map("avatar_url")
createdAt DateTime @default(now()) @map("created_at")
updatedAt DateTime @updatedAt @map("updated_at")
orders Order[]
@@map("users")
@@index([email])
}
Custom SQL Migration
For operations Prisma cannot express (concurrent indexes, data backfills):
# Create empty migration, then edit the SQL manuallynpx prisma migrate dev --create-only --name add_email_index
-- migrations/20240115_add_email_index/migration.sql-- Prisma cannot generate CONCURRENTLY, so we write it manuallyCREATEINDEX CONCURRENTLY IFNOTEXISTS idx_users_email ON users (email);
# Initialize config file (kysely.config.ts)kysely init
# Create a new migration filekysely migrate make add_user_avatar
# Apply all pending migrationskysely migrate latest
# Rollback last migrationkysely migrate down
# Show migration statuskysely migrate list
Migration File
// migrations/2024_01_15_001_create_user_profile.tsimport{typeKysely, sql }from'kysely'// IMPORTANT: Always use Kysely<any>, not your typed DB interface.// Migrations are frozen in time and must not depend on current schema types.exportasyncfunctionup(db: Kysely<any>):Promise<void>{await db.schema
.createTable('user_profile').addColumn('id','serial',(col)=> col.primaryKey()).addColumn('email','varchar(255)',(col)=> col.notNull().unique()).addColumn
β
Make data-driven prioritization decisions faster
Stakeholder Communication
Draft PRDs, status updates, and stakeholder presentations
βΊAccess to product documentation and roadmap tools (Jira, Notion, etc.)
βΊUnderstanding of product management frameworks (RICE, Jobs-to-be-Done, etc.)
βΊStakeholder contact information and communication channels
Time Estimate
30-60 minutes to see productivity improvements
Steps
1Install product management skill
2Start with user story generation for known feature
3Progress to competitive analysis: research 2-3 competitors
4Use for roadmap prioritization: apply RICE/ICE scoring
5Draft stakeholder communications and refine based on feedback
6Build template library for recurring PM tasks
7Share effective prompts with product team
Common Pitfalls
β Not validating competitive researchβverify facts before sharing
β Accepting user stories without involving engineering team
β Over-relying on frameworks without qualitative judgment
β Not customizing outputs to company culture and communication style
β Skipping stakeholder validation of generated requirements
Best Practices
β Do
+Validate research and competitive analysis with real data
+Collaborate with engineering when generating technical requirements
+Customize frameworks and templates to your company context
+Use skill for first drafts, refine with stakeholder input
+Document successful prompt patterns for PM tasks
+Combine AI efficiency with human judgment and intuition
β Don't
βDon't publish competitive analysis without fact-checking
βDon't finalize user stories without engineering review
βDon't make prioritization decisions solely on AI scoring
βDon't skip customer validation of generated requirements
βDon't ignore company-specific context and culture
π‘ Pro Tips
β Provide context: company goals, constraints, customer feedback
β Ask for alternatives: 'Show 3 ways to prioritize this roadmap'
β Request stakeholder-specific formatting: 'Executive summary vs. engineering spec'
β Use skill for 70% generation + 30% customization to company needs
When to Use This
β Use when
Use for user story writing, competitive research, roadmap prioritization, stakeholder communication, and PRD drafting. Best for reducing repetitive documentation and research work.
β Avoid when
Avoid for strategic product vision (requires deep customer empathy), pricing decisions (needs market and financial expertise), or when face-to-face customer discovery is more valuable than speed.
Learning Path
1Basic: user stories, feature specs, status updates