1.0.11 • Published 1 year ago
@watchnest/pg-controller v1.0.11
Database Migrations
This project uses TypeORM for managing database migrations. Follow the steps below to generate and run migrations.
Prerequisites
- Ensure you have TypeScript installed.
- Ensure your TypeORM configuration is correctly set up.
Build the Project
Before running migrations, compile the TypeScript files to JavaScript:
npm run build
Generating a Migration
To generate a new migration, use the typeorm
CLI.
This example demonstrates adding a new column isAdmin
to the users table:
npx typeorm migration:generate -d ./dist/data-source ./src/migration/CreateUserTable
Running Migrations
To apply the generated migrations to the database, run the following command:
npx typeorm migration:run -d ./dist/data-source.js