A progressive Node.js framework for building efficient and scalable server-side applications.
Nest framework TypeScript starter repository.
$ yarn install
The project persist data using TypeORM. To accomplish this, it uses migrations as a database versioning system. It's important to follow the convention in order to encourage the maintainability of the project.
Every migration generated or created is located in the migrations folder.
The easiest way to make use of this migrations system is to follow the workflow proposed below. It make extensive use of the custom scripts located in the package.json file
The workflow to proper modify the database schema is the following:
- Make changes to your entities.
- Run
npm run migration:generate --name=YourMigrationName -- --dr
and watch the generated output. If it is correct, proceed to the next step, else go back and make changes to your entities again. - Run
npm run migration:generate --name=YourMigrationName
. - Do one of these:
- Launch the app building it before (
npm run build
and thennpm run start:dev
). - Run the migration manually using
npm run migration:run
- Launch the app building it before (
- Check your changes in the database. If there are unwanted changes, run
npm run migration:revert
, remove the previously generated file, and start again. - Commit your changes.
# generate migration based on your changes
$ npm run migration:generate --name=YourMigrationName
# generate migration in dry run (don't write anything)
$ npm run migration:generate --name=YourMigrationName -- --dr
# create an empty migration file
$ npm run migration:create --name=YourMigrationName
# run migrations manually
$ npm run migration:run
# revert last migration
$ npm run migration:revert
# development
$ yarn run start
# watch mode
$ yarn run start:dev
# production mode
$ yarn run start:prod
# unit tests
$ yarn run test
# e2e tests
$ yarn run test:e2e
# test coverage
$ yarn run test:cov
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.