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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ EXPOSE 3000

USER node

CMD ["sh", "-c", "npx prisma db push && node dist/index.js"]
CMD ["sh", "-c", "npx prisma migrate deploy && node dist/index.js"]
2 changes: 1 addition & 1 deletion Dockerfile.dev
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ ENV NODE_ENV=development

EXPOSE 3000

CMD ["sh", "-c", "npx prisma db push && npx nodemon"]
CMD ["sh", "-c", "npx prisma migrate deploy && npx nodemon"]
8 changes: 6 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,19 @@ services:
- JWT_SECRET=${JWT_SECRET:-}
- JWT_ACCESS_EXPIRY=${JWT_ACCESS_EXPIRY:-15m}
- JWT_REFRESH_EXPIRY_SECONDS=${JWT_REFRESH_EXPIRY_SECONDS:-604800}
- RESET_TOKEN_TTL_SECONDS=${RESET_TOKEN_TTL_SECONDS:-900}
- RESET_TOKEN_TTL_SECONDS=${RESET_TOKEN_TTL_SECONDS:-3600}
- CORS_ORIGINS=${CORS_ORIGINS:-http://localhost:5173}
- OAUTH_FRONTEND_URL=${OAUTH_FRONTEND_URL:-http://localhost:5173}
- CORS_CREDENTIALS=${CORS_CREDENTIALS:-true}
- FRONTEND_URL=${FRONTEND_URL:-http://localhost:5173}
- GOOGLE_CLIENT_ID=${GOOGLE_CLIENT_ID:-}
- GOOGLE_CLIENT_SECRET=${GOOGLE_CLIENT_SECRET:-}
- GOOGLE_CALLBACK_URL=${GOOGLE_CALLBACK_URL:-http://localhost:3000/api/v1/auth/oauth/google/callback}
- GITHUB_CLIENT_ID=${GITHUB_CLIENT_ID:-}
- GITHUB_CLIENT_SECRET=${GITHUB_CLIENT_SECRET:-}
- GITHUB_CALLBACK_URL=${GITHUB_CALLBACK_URL:-http://localhost:3000/api/v1/auth/oauth/github/callback}
- RESEND_API_KEY=${RESEND_API_KEY:-}
- RESET_PASSWORD_EMAIL=${RESET_PASSWORD_EMAIL:-}
- RESET_PASSWORD_TEMPLATE_ID=${RESET_PASSWORD_TEMPLATE_ID:-}
- NODE_TLS_REJECT_UNAUTHORIZED=0
restart: unless-stopped
depends_on:
Expand Down
26 changes: 26 additions & 0 deletions docs/migrations.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# Prisma Migrations

## How It Works

1. You edit `prisma/schema.prisma`
2. You run `npm run db:migrate` — this generates a new SQL migration file and applies it to your local DB
3. You commit the generated `prisma/migrations/<timestamp>_<name>/migration.sql`
4. In Docker, `prisma migrate deploy` runs on startup and applies any pending migrations

## Creating a Migration

```sh
npm run db:migrate
```

Prisma will prompt you for a migration name (e.g. `add_user_avatar`). This creates `prisma/migrations/<timestamp>_add_user_avatar/migration.sql`.

## Deploying

Both `Dockerfile` and `Dockerfile.dev` run `prisma migrate deploy` on container start. This only applies migrations that haven't been applied yet.

## Key Rules

- **Always** commit migration files to version control
- **Never** edit a migration file after it has been applied to any environment
- Run `npm run db:migrate` locally, not in Docker — Docker only runs `deploy`
2 changes: 2 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ module.exports = {
'^@models/(.*)$': '<rootDir>/src/models/$1',
'^@constants/(.*)$': '<rootDir>/src/constants/$1',
'^@generated/(.*)$': '<rootDir>/src/generated/$1',
'^@queues/(.*)$': '<rootDir>/src/queues/$1',
'^@workers/(.*)$': '<rootDir>/src/workers/$1',
},
clearMocks: true,
collectCoverageFrom: [
Expand Down
2 changes: 1 addition & 1 deletion overrides/api.dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ services:
- ${API_DIR}/prisma:/app/prisma
- ${API_DIR}/prisma.config.ts:/app/prisma.config.ts
- ${API_DIR}/nodemon.json:/app/nodemon.json
- ${API_DIR}/tsconfig.json:/app/tsconfig.json
- ${API_DIR}/tsconfig.json:/app/tsconfig.json
Loading
Loading