database-migration

Generates and applies reversible TypeORM migrations for multi-tenant PostgreSQL schemas.

Updated Apr 4, 2026
One-click install
npx skills add https://github.com/SleyiW/iWana-neXt --skill database-migration-sleyiw
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: database-migration
Source: https://github.com/SleyiW/iWana-neXt/tree/main/.agents/skills/database-migration
Command: npx skills add https://github.com/SleyiW/iWana-neXt --skill database-migration-sleyiw

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires typeorm.

What problem does it solve? Managing schema changes in a multi-tenant PostgreSQL application is risky: a single bad migration can destroy production data or block rollbacks. This Skill enforces versioned, reversible TypeORM migrations with zero-downtime strategies so schema changes ship safely across public and tenant schemas. ## Core Features & Use Cases - Versioned Migration Generation: Create, apply, and revert TypeORM migrations using the repo's actual pnpm and TypeORM CLI commands. - Multi-Tenant Schema Handling: Apply tenant-schema changes dynamically via runInTenantSchema instead of hardcoding schema names. - Zero-Downtime Patterns: Add NOT NULL columns to large tables safely using nullable-column, backfill, and constraint phases, plus CREATE INDEX CONCURRENTLY. - Use Case: After adding a new column to a TypeORM entity, generate the migration, verify the down() rollback works with migration:revert, and deploy without locking the table. ## Quick Start Ask the assistant to generate a reversible TypeORM migration for your entity change following the iWana neXt migration rules.

Frequently Asked Questions about database-migration

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

FAQPage Schema
How do I generate a TypeORM migration in a pnpm monorepo?

Run pnpm --filter @iwana/db migration:generate -- src/migrations/public/NombreMigracion from the monorepo root, or use npx typeorm migration:generate with the -d flag pointing to your data-source.ts file inside packages/database.

How to add a NOT NULL column to a large PostgreSQL table without downtime?

Add the column as nullable first, backfill values in batches, then add the NOT NULL constraint in a separate migration. Never run ALTER TABLE ADD COLUMN NOT NULL without a default on tables containing data.

How do TypeORM migrations work in a multi-tenant PostgreSQL setup?

Public schema changes are versioned as migration files, while tenant schema changes run dynamically through a helper like runInTenantSchema that resolves the schema from request context. Never hardcode tenant schema names in migrations.

Why should synchronize be false in TypeORM production config?

synchronize: true auto-alters the schema to match entities and can drop columns or data in production without warning. Versioned migrations with tested down() methods provide controlled, reversible schema changes instead.

When should I not use TypeORM migrations for a database task?

Skip migrations when the task is only queries or business logic with no schema change. This approach also does not apply to other ORMs like Prisma, Sequelize, or Drizzle, which have their own migration systems.