A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ npm install
# development
$ npm run start
# watch mode
$ npm run start:dev
# production mode
$ npm run start:prod
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov
To ensure the accurate generation of migrations, it is important to configure the schema in the src/tenant-migrations.config.ts
file to match an existing tenant schema in your database. This step is necessary because the migration generation script relies on the current state of the database to generate the appropriate migration script.
# generate migration
$ npm run migrations:g:t ./src/migrations/tenanted/MigrationName
After the migration is generated, you need to prefix all tables with the current schema configuration of the data source. This is to scope the migration within the schema configured in the data source. Follow this example for more details:
public async up(queryRunner: QueryRunner): Promise<void> {
const { schema } = queryRunner.connection
.options as SqlServerConnectionOptions;
await queryRunner.query(
`CREATE TABLE "${schema}"."cats" (...)`,
);
}
To run the migrations for all the tenant schemas in the database you can run the next script:
# run migrations
$ npm run migrations:run:t
Nest is an MIT-licensed open source project. It can grow thanks to the sponsors and support by the amazing backers. If you'd like to join them, please read more here.
- Author - Kamil Myśliwiec
- Website - https://nestjs.com
- Twitter - @nestframework
Nest is MIT licensed.