How to setup developer's environment? - hyter99/AI_22-23_L1 GitHub Wiki
What's needed
- Database suppported by prisma (MySQL, Postgres, SQL Server etc.)
- Node.js with version > 16
Steps to set up
1. Clone the repository:
git clone https://github.com/hyter99/AI_22-23_L1.git
2. Install dependencies:
cd AI_22-23-L1
npm ci
3. Duplicate file .env.example in the root, rename it to .env and fill in the blanks.
4. Change provider field in file ./prisma/schema.prisma to the provider you've selected.
Available providers:
postgresql, mysql, sqlite, sqlserver, mongodb, cockroachdb
5. Generate PrismaClient:
npx prisma generate
6. Generate migration file (optionally):
npx prisma migrate dev --create-only [--name <name_of_migration>]
Where name_of_migration is optional custom string which content should correspond to changes made to model.
Note:
If --create-only option is ommited, migration will be created and immediately applied to existing database.
7. Apply migrations to database (and create migration file, if it wasn't done previously):
npx prisma migrate dev [--name <name_of_migration>]
or
npx prisma migrate deploy [--name <name_of_migration>]
Note:
Command with dev is safer than command with deploy ending (the second one doesn't check previous migration and database integrity - it just forces the migration to be performed).
Useful commands:
- Reset prisma migration (when there was new migration and we want to reset data in DB)
npx prisma migrate reset
- Apply seed.ts file
npx prisma db seed
- command to create models in schema.prisma file from existing database schema:
npx prisma db pull
Note (for
npx prisma db pull
):All models inside schema.prisma file should be removed before running this command. There should be only specified datasource db object (with proper database type and connection string).
Start development
Backend:
npm run start:dev
Frontend:
npm run start:vite