Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,29 @@ Open http://localhost:3000 and sign in with the seeded admin account:
admin@datashield.local / ChangeMe123!
```

### Switching machines / after `git pull`

The Prisma client is regenerated automatically on `npm install` (`postinstall`).
The database is **not** migrated automatically: `npm run dev` only *warns* if
migrations are pending (it never applies them on boot). After pulling changes
that add a migration, apply it explicitly before running the app:

```bash
npm run db:migrate # prisma migrate deploy, applies pending migrations
```

When you edit `prisma/schema.prisma` yourself, create the migration instead:

```bash
npx prisma migrate dev --name <change>
```

### Database commands

- `npm run db:init` starts a Postgres container (`compose.yml`), applies all
migrations and seeds demo data (breaches, employees, alerts).
- `npm run db:up` / `npm run db:down` start and stop the container.
- `npm run db:migrate` applies pending migrations to the current database.
- `npm run seed:dev` reseeds the demo data; `npm run seed` seeds only the admin.

No Docker? Point `DATABASE_URL` at your own PostgreSQL, then run
Expand Down
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"author": "Melvin PETIT (WhiteMuush)",
"type": "module",
"scripts": {
"predev": "prisma migrate status || echo '\\n[!] Pending migrations or DB unreachable. If the app errors on a missing table, run: npm run db:migrate\\n'",
"dev": "next dev",
"build": "next build",
"start": "next start",
Expand All @@ -23,6 +24,7 @@
"db:up": "docker compose up -d db",
"db:down": "docker compose down",
"db:init": "sh scripts/db-init.sh",
"db:migrate": "prisma migrate deploy",
"postinstall": "prisma generate",
"prepare": "sh .githooks/install.sh",
"seed:dev": "dotenv -e .env.local -- tsx prisma/seed.dev.ts"
Expand Down