# Add database with Prisma and PostgreSQL

Set up Prisma ORM with PostgreSQL and create the initial database schema.

## What to Create

1. **Install Prisma**:
   - Install `prisma` (dev) and `@prisma/client`
   - Run `npx prisma init`

2. **Configure database connection**:
   - Update `.env.example` with `DATABASE_URL`
   - Set PostgreSQL connection string format in docs:
     ```
     DATABASE_URL="postgresql://user:password@localhost:5432/dbname?schema=public"
     ```

3. **Define schema** in `prisma/schema.prisma`:
   - User model:
     - id: String (cuid, primary key)
     - email: String (unique)
     - password: String
     - name: String
     - createdAt, updatedAt: DateTime
   - Project model:
     - id: String (cuid, primary key)
     - name: String
     - description: String (optional)
     - ownerId: String (relation to User)
     - createdAt, updatedAt: DateTime
   - Task model:
     - id: String (cuid, primary key)
     - title: String
     - description: String (optional)
     - status: Enum (TODO, IN_PROGRESS, DONE)
     - priority: Enum (LOW, MEDIUM, HIGH)
     - dueDate: DateTime (optional)
     - projectId: String (relation to Project)
     - assignedToId: String (relation to User)
     - createdById: String (relation to User)
     - createdAt, updatedAt: DateTime

4. **Set up Prisma client**:
   - Create `src/db/prisma.ts`:
     - Export singleton Prisma client instance
     - Handle disconnect on shutdown

5. **Create initial migration**:
   - Run `npx prisma migrate dev --name init`
   - Verify migration files created

6. **Add database scripts** to package.json:
   - `db:migrate`: Run migrations
   - `db:studio`: Open Prisma Studio
   - `db:seed`: Seed database (create empty seed file)

7. **Update .gitignore**:
   - Add `.env`
   - Keep `.env.example`

## Acceptance

- Prisma schema defines all three models with relationships
- Running `npm run db:migrate` creates database tables
- Prisma client can be imported: `import { prisma } from './db/prisma'`
- `npx prisma studio` opens database GUI
- Schema includes all required fields and enums
