how-to-write-typeorm-migrations-in-packmind

Solid

Write TypeORM migrations in the Packmind monorepo to manage and version database schema changes with consistent logging, reversible rollbacks, and shared helpers. Use this skill whenever creating or modifying database tables, columns, or foreign-key relationships — including any time schema changes need to be tracked, versioned, or rolled back. Invoke even if the user just says "add a column", "create a table", or "update the DB schema".

API & Backend 303 stars 15 forks Updated today Apache-2.0

Install

View on GitHub

Quality Score: 86/100

Stars 20%
83
Recency 20%
100
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

Write TypeORM migrations in the Packmind monorepo to manage database schema changes effectively while ensuring proper logging and rollback capabilities. ## When to Use - When you need to create new database tables - When adding or modifying columns in existing tables - When creating or updating foreign key relationships - When making any database schema changes that need to be version controlled ## Context Validation Checkpoints * [ ] Have you identified the exact database schema changes needed? * [ ] Do you know the TypeORM column types for all fields? * [ ] Have you planned the rollback strategy (down method)? * [ ] Are you familiar with the shared migration utilities in @packmind/shared? ## Recipe Steps ### Step 1: Create Migration File Using TypeORM CLI IMPORTANT: Always create migration files using the TypeORM CLI command. Never create migration files manually. The CLI automatically generates a timestamp prefix and sets up the basic structure. ```bash # Create new migration file (TypeORM will automatically add timestamp) npx typeorm migration:create packages/migrations/src/migrations/DescriptiveName ``` ### Step 2: Set Up Basic Migration Structure with Logging Implement the migration class with PackmindLogger for comprehensive logging. Include try-catch blocks and log start, progress, completion, and any errors. ```typescript import { MigrationInterface, QueryRunner } from 'typeorm'; import { PackmindLogger, LogLevel } from '@packmind/shared'; export class Yo...

Details

Author
PackmindHub
Repository
PackmindHub/packmind
Created
10 months ago
Last Updated
today
Language
TypeScript
License
Apache-2.0

Similar Skills

Semantically similar based on skill content — not just same category