database-migration

Master database schema and data migrations across ORMs (Sequelize, TypeORM, Prisma), including rollback strategies and zero-downtime deployments.

By sickn33 · 442 installs

npx skills add sickn33/agentic-awesome-skills --skill database-migration

Source repository · Upstream listing

Supporting material availability This catalog copy contains the inline guidance below, but does not include the following supporting paths. They are external prerequisites, not bundled files: <support root /references/orm switching.md <support root /references/schema migration.md <support root /references/data transformation.md <support root /references/rollback strategies.md <support root /assets/schema migration template.sql <support root /assets/data migration script.py <support root /scripts/test migration.sh Ask for the original supporting material or an existing installation before using a step that depends on these paths; this catalog does not identify a verified download source for them. Resolve each path relative to that installation, inspect its contents, and verify any applicable license and execution prerequisites. Do not run a command or claim a referenced procedure was followed until its required file exists. Do not fabricate the missing scripts or treat an unrelated file with the same name as equivalent. Independent steps fully documented here can proceed within the user’s authorized scope; report any dependent step as unavailable. Database Migration Master database schema and data migrations across ORMs (Sequelize, TypeORM, Prisma), including rollback strategies and zero downtime deployments. Do not use this skill when The task is unrelated to database migration You need a different domain or tool outside this scope Instructions Clarify goals, constraints, and required inputs. Apply relevant best practices and validate outcomes. Provide actionable steps and verification. Use this skill when Migrating between different ORMs Performing schema transformations Moving data between databases Implementing rollback procedures Zero downtime deployments Database version upgrades Data model refactoring ORM Migrations Sequelize Migrations TypeORM Migrations Prisma Migrations Schema Transformations Adding Columns with Defaults Renaming Columns (Expand/Contract Sketch) This sketch is not sufficient for concurrent writes. Deploy compatible dual writes before a bounded backfill, reconcile changes during backfill, switch reads only after validation, and drop the old column only after all readers/writers migrate. A one time UPDATE alone can lose updates. Changing Column Types This example is a breaking, potentially lossy migration, not a zero downtime recipe. Validate casts and range/null handling first. Preserve original values until a separately approved contract step; casting back cannot recover discarded data. Data Transformations Complex Data Migration Illustrative parsing only: define and validate an address schema first; splitting on commas is lossy. Use bounded batches with checkpoints and keep the source column until reconciliation and a tested recovery plan pass. The down() reconstruction below does not recover original formatting. Rollback Strategies Transaction Based Migrations Checkpoint Based Recovery Use the database engine's tested backup/snapshot and point in time recovery procedure, verified in a disposable restore environment. Record the recovery point, schema, constraints, indexes, sequences, permissions and application compatibility before migration. A CREATE TABLE AS SELECT copy is not a complete backup and must never be used to DROP and recreate a live table during automatic error recovery. It omits important schema properties and can lose concurrent writes. Stop on uncertain partial state and reconcile before retrying. Zero Downtime Migrations Blue Green Deployment Strategy Cross Database Migrations PostgreSQL to MySQL Resources references/orm switching.md : ORM migration guides references/schema migration.md : Schema transformation patterns references/data transformation.md : Data migration scripts references/rollback strategies.md : Rollback procedures assets/schema migration template.sql : SQL migration templates assets/data migration script.py : Data migration utilities scripts/test migration.sh : Migration testing script Best Practices 1. Plan Recovery : Provide a tested down() only when genuinely reversible; otherwise document a forward fix or tested restore and the data loss boundary 2. Test Migrations : Test on staging first 3. Use Transactions : Atomic migrations when possible 4. Backup First : Always backup before migration 5. Small Changes : Break into small, incremental steps 6. Monitor : Watch for errors during deployment 7. Document : Explain why and how 8. Idempotent : Migrations should be rerunnable Common Pitfalls Not testing rollback procedures Making breaking changes without downtime strategy Forgetting to handle NULL values Not considering index performance Ignoring foreign key constraints Migrating too much data at once Limitations Use this skill only when the task clearly matches the scope described above. Do not treat the output as a substitute for environment specific validation, testing, or expert review. Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.