+8
-33
@@ -12,9 +12,8 @@ Create `.env` in the project root:
|
||||
# Database
|
||||
DB_PASSWORD=<generate-a-strong-password>
|
||||
|
||||
# JWT secrets — generate with: openssl rand -hex 64
|
||||
# JWT secret — generate with: openssl rand -hex 64
|
||||
JWT_SECRET=<64-char-hex-string>
|
||||
JWT_REFRESH_SECRET=<64-char-hex-string>
|
||||
|
||||
# URLs — set your actual domain/port
|
||||
DASHBOARD_URL=https://dashboard.yourdomain.com
|
||||
@@ -29,16 +28,16 @@ API_PORT=3001
|
||||
docker compose -f docker-compose.prod.yml up --build -d
|
||||
```
|
||||
|
||||
### 3. Seed the database (first time only)
|
||||
### 3. Create the venue and admin (first time only)
|
||||
|
||||
Migrations run automatically when the API container starts.
|
||||
|
||||
```bash
|
||||
# Generate Prisma client and run migrations
|
||||
docker compose -f docker-compose.prod.yml exec api npx prisma migrate deploy
|
||||
|
||||
# Seed demo data (or create your own venue/users)
|
||||
docker compose -f docker-compose.prod.yml exec api npx ts-node prisma/seed.ts
|
||||
docker compose -f docker-compose.prod.yml exec api node prisma/setup.js "My Venue" admin@myvenue.com '<strong password>'
|
||||
```
|
||||
|
||||
`setup.js` does nothing when a venue already exists. `--force` wipes ALL data and starts over.
|
||||
|
||||
### 4. Set up a reverse proxy (nginx/Caddy)
|
||||
|
||||
Example Caddyfile:
|
||||
@@ -70,22 +69,11 @@ GRANT ALL PRIVILEGES ON DATABASE kooltap TO kooltap;
|
||||
```env
|
||||
DATABASE_URL="postgresql://kooltap:your-password@localhost:5432/kooltap"
|
||||
JWT_SECRET="<random-64-char-string>"
|
||||
JWT_REFRESH_SECRET="<random-64-char-string>"
|
||||
PORT=3001
|
||||
CORS_ORIGIN="https://dashboard.yourdomain.com"
|
||||
```
|
||||
|
||||
### 3. Update Prisma schema for PostgreSQL
|
||||
|
||||
In `apps/api/prisma/schema.prisma`, change:
|
||||
```prisma
|
||||
datasource db {
|
||||
provider = "postgresql"
|
||||
url = env("DATABASE_URL")
|
||||
}
|
||||
```
|
||||
|
||||
### 4. Build and run
|
||||
### 3. Build and run
|
||||
|
||||
```bash
|
||||
cd apps/api
|
||||
@@ -98,19 +86,6 @@ node dist/main
|
||||
|
||||
---
|
||||
|
||||
## Migration Steps: SQLite → PostgreSQL
|
||||
|
||||
1. Update `schema.prisma` to use `postgresql` provider
|
||||
2. Update `DATABASE_URL` environment variable
|
||||
3. Run `prisma migrate dev` to create initial PostgreSQL migration
|
||||
4. Export SQLite data and import to PostgreSQL (using `prisma db pull` + manual script, or insert via seed)
|
||||
5. Run `prisma migrate deploy` on production
|
||||
|
||||
Key differences to handle:
|
||||
- SQLite uses `Int` for booleans → use `Boolean` in PostgreSQL
|
||||
- SQLite uses `String` for JSON → use `Json` type in PostgreSQL
|
||||
- UUID generation is handled by Prisma on both
|
||||
|
||||
## Security Checklist
|
||||
|
||||
- [ ] JWT secrets are 64+ random hex characters
|
||||
|
||||
Reference in New Issue
Block a user