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
4 changes: 2 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ Dispatch is a self-hosted Next.js/TypeScript Kanban and work dispatch layer for
## Key Commands

```bash
npm install # Install dependencies
npm install # Install dependencies (runs `prisma generate` via postinstall)
npm run dev # Start development server
npm run build # Production build
npm run lint # Lint check
npm run typecheck # TypeScript check
npx prisma generate # Generate Prisma client
npm run db:generate # Regenerate Prisma client (also runs on postinstall; re-run after editing schema.prisma)
npm run db:push # Push schema (dev)
npm run db:deploy # Deploy migrations (prod)
```
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"test:watch": "NODE_ENV=development vitest",
"test:coverage": "NODE_ENV=development vitest run --coverage",
"typecheck": "NODE_ENV=development tsc --noEmit",
"postinstall": "test -f prisma/schema.prisma && prisma generate || true",
"db:generate": "prisma generate",
"db:push": "prisma db push",
"db:migrate": "prisma migrate dev",
Expand Down
16 changes: 7 additions & 9 deletions prisma.config.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
import { defineConfig } from "prisma/config";

// NOTE: do not throw when DATABASE_URL is unset. This config is loaded by every
// Prisma CLI invocation, including `prisma generate` (run on postinstall), which
// needs only the schema — not a live datasource URL. Throwing here broke fresh
// clones: `npm install` -> postinstall -> generate -> throw. The datasource URL
// is supplied only when present (for migrate/deploy/studio); the app enforces
// DATABASE_URL at runtime via src/lib/prisma.ts.
const databaseUrl = process.env.DATABASE_URL;

if (!databaseUrl) {
throw new Error(
"DATABASE_URL is not set. Please set the DATABASE_URL environment variable before starting the application.",
);
}

export default defineConfig({
schema: "prisma/schema.prisma",
datasource: {
url: databaseUrl,
},
...(databaseUrl ? { datasource: { url: databaseUrl } } : {}),
});