- create a postgreSQL database
example docker command :
docker run -itd -e POSTGRES_USER=<user> -e POSTGRES_PASSWORD=<password> -e POSTGRES_DB=leafloverdb -p 5432:5432 --name leaflovedb postgres
- create .env from .env.example and add the necessary info
for db created in example above :
DATABASE_URL="postgresql://<user>:<password>@localhost:5432/leafloverdb?schema=public"
- install dependencies
npm install
- run migrations
npx prisma migrate dev
- seed the database
npx prisma db seed
- start the project (dev mode)
npm run dev
windows :
npm run dev-windows
- build
npm run build
- start
npm start
npx prisma studio
-
open prisma/seed/generateImportData.ts and specify the ID range you want to fetch fro the external API
-
run
npx ts-node prisma/seed/generateImportData.ts
It will generate data from the external API to /seed/data/plantsSeedData{timestamp}.json
- seed the database
npx prisma db seed
this command will insert in the DB the data from files in prisma/seed/data/
- Vérifier si le port est déjà utilisé ( sous windows ) :
netstat -ano | findstr :5432
- Si déjà occupé, alors le kill en lançait CMD en admin et en renseignant le pid
taskkill /PID <pid> /F