50 lines
821 B
Markdown
50 lines
821 B
Markdown
# TypeORM Migrations Guide
|
|
|
|
This project uses TypeORM migrations for database schema management in production environments.
|
|
|
|
## Migration Commands
|
|
|
|
### Generate Migration
|
|
|
|
Generate a migration file based on entity changes:
|
|
|
|
```bash
|
|
# Start the database first
|
|
yarn docker:dev:detached
|
|
|
|
# Generate migration from entity changes
|
|
yarn migration:generate src/migrations/YourMigrationName
|
|
```
|
|
|
|
### Create Empty Migration
|
|
|
|
Create an empty migration file for custom SQL:
|
|
|
|
```bash
|
|
yarn migration:create src/migrations/YourMigrationName
|
|
```
|
|
|
|
### Run Migrations
|
|
|
|
Apply pending migrations to the database:
|
|
|
|
```bash
|
|
yarn migration:run
|
|
```
|
|
|
|
### Revert Migration
|
|
|
|
Revert the last applied migration:
|
|
|
|
```bash
|
|
yarn migration:revert
|
|
```
|
|
|
|
### Show Migration Status
|
|
|
|
Show which migrations have been applied:
|
|
|
|
```bash
|
|
yarn migration:show
|
|
```
|