Run the below command to install project dependencies packages.
npm install
Run the docker compose file with the below command:
docker compose up development-db -d
If started correctly and running the first below command you can see your container. Get the container id and run the second command to see its logs. You should see, that the database is ready to accept connections.
docker ps
docker logs container-id-here
Install the VS code prisma extension for syntax highlight and autocomplete.
While developing a new project run below command
npx prisma init
To create migrations run the below command. It will generate the migrations folder in the prisma folder. Every next time we apply some changes to our rpisma schema we will run again this command to generate updated migrations.
npx prisma migrate dev
By running the below command, we will be given url on which we can inspect our data.
npx prisma studio
Run the below commands in the root folder of the project.
Run the below command to start the docker container and run the migrations. With Windows use the bash terminal, VS code terminal might not like the sleep command.
npm run dev:db:restart
Run the below command to start browser window, where you can inspect the data.
npm run dev:prisma:studio
Run the below command to start the dev server
npm run start:dev
You can preview the test database with the following command
npx dotenv -e .env.test -- prisma studio
@nestjs/config
- configuration module. Used for getting .env variablesprisma
- database ORM@prisma/client
- needed for prismaargon2
- for hashing passwords@nestjs/passport
- authentication@nestjs/jwt
- authenticationpassport
- authenticationpassport-jwt
- authentication@types/passport-jwt
- authenticationpactum
- testingdotenv-cli
- allow us to import custom env files. In this case the .env.test file which is used for the e2e tests
dev:prisma:dev
- run the migrations in dev environment based on the schema. The changes are applied automatically.dev:prisma:deploy
- run the migrations in prod environment based on the schema. The changes are applied after the user confirms the prompt.dev:db:remove
- remove the docker containerdev:db:start
- start the docker containerdev:db:restart
- remove the container, then start it, then run the migrations. The timeout command is for Windows.test:prisma:deploy
- run the migrations using the test env filetest:db:remove
- remove the docker container used for running the e2e teststest:db:start
- start the docker container used for running the e2e teststest:db:restart
- remove the container, then start it, then run the migrations for e2e test. The timeout command is for Windows.pretest:e2e
- before running the scripttest:e2e
run the scripttest:db:restart
posttest:e2e
- after running the scripttest:e2e
run the scripttest:db:remove
start
- start the projectstart:dev
- start the project in watch mode to watch for file changestest:e2e
- run e2e tests
- for this script
test:prisma:deploy
we will use the help of dotenv-cli dev dependency package to use different env file.