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: 3 additions & 1 deletion .cursor/skills/signbank-data-model/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,9 @@ Frontend phonology filters and Typesense facets mirror these enum string values.

## Migration rules

1. Edit `schema.prisma`, then `npx prisma migrate dev --name <name>` (development).
**Use `signbank-prisma-migrate` skill** — always generate migrations with `prisma migrate dev`; never hand-write `migration.sql`.

1. Edit `schema.prisma`, then `npx prisma migrate dev --name <name>` (via Docker exec in dev).
2. Containers apply with `prisma migrate deploy` on startup — never edit applied migration SQL retroactively.
3. Seed (`backend/prisma/seed.ts`) is dev/test only; production bootstraps admin via `AppService.onApplicationBootstrap`.

Expand Down
12 changes: 7 additions & 5 deletions .cursor/skills/signbank-dev-environment/SKILL.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,15 @@ Source of truth: `.env.example`. Key vars:

## Common workflows

**Schema change:**
**Schema change:** follow `signbank-prisma-migrate` skill — edit `schema.prisma`, then:

```bash
# Dev: create migration inside backend container or locally with DATABASE_URL set
npx prisma migrate dev --name describe_change
make migrate # deploy in running stack
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate dev --name describe_change
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate status
```

Deploy only (migrations already committed): `make migrate` or the `migrate deploy` exec above.

**Backend debug:** Node inspector on `9229` when using local compose.

**Full reset:**
Expand All @@ -86,7 +88,7 @@ openssl req -x509 -nodes -days 365 -newkey rsa:2048 \

| Symptom | Check |
|---------|-------|
| 502 from nginx | `make logs`, ensure backend/frontend are healthy |
| Frontend changes not hot-reloading (Windows/macOS) | Ensure `CHOKIDAR_USEPOLLING=true` in local compose; recreate frontend: `make rebuild s=frontend` |
| DB connection errors | `DATABASE_URL_DOCKER` in backend env, postgres healthcheck |
| Search empty/stale | Typesense init runs on backend boot; see `signbank-search-typesense` skill |
| Videos 404 | Dufs volume `./FileServer`; nginx path `/lscassets` → dufs |
Expand Down
103 changes: 103 additions & 0 deletions .cursor/skills/signbank-prisma-migrate/SKILL.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
---
name: signbank-prisma-migrate
description: SignBank database schema changes via Prisma migrate dev (generated SQL, never hand-written). Use when editing backend/prisma/schema.prisma, adding tables/columns/enums, creating migrations, or when the user asks to update the database structure.
---

# SignBank Prisma Migrations

Schema: `backend/prisma/schema.prisma`. Migrations: `backend/prisma/migrations/`.

## Golden rule

**Never hand-write migration SQL** when changing the database structure. Always let Prisma generate it from `schema.prisma`.

| Do | Don't |
|----|-------|
| Edit `schema.prisma`, then run `prisma migrate dev` | Create or edit `migrations/*/migration.sql` by hand |
| Commit the generated migration folder + updated schema | Patch applied migrations retroactively |
| Run `prisma generate` after schema changes | Skip client regeneration |

## Workflow

### 1. Edit the schema

Change `backend/prisma/schema.prisma` only. See `signbank-data-model` for entity conventions.

### 2. Generate and apply the migration (Docker)

Stack must be running (`docker compose -f docker-compose-local.yaml ps`).

```bash
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate dev --name describe_change
```

Use a short **snake_case** name: `compound_signs`, `optional_lexical_category`, `add_category_model`.

Prisma will:
- Diff schema vs database
- Create `backend/prisma/migrations/<timestamp>_describe_change/migration.sql`
- Apply the migration to the dev database
- Run `prisma generate`

### 3. Verify

```bash
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate status
```

Expect: `Database schema is up to date!`

If seed data depends on new models, update `backend/prisma/seed.ts` (or `backend/prisma/seed/`) and run:

```bash
docker compose -f docker-compose-local.yaml exec backend npx prisma db seed
```

### 4. Deploy-only (CI / already-generated migrations)

When migration files already exist and you only need to apply them:

```bash
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate deploy
```

Backend containers also run `migrate deploy` on startup in deployed environments.

## Review SQL before applying (rare)

Only when you must inspect SQL without applying:

```bash
docker compose -f docker-compose-local.yaml exec backend npx prisma migrate dev --name describe_change --create-only
```

Review the generated file, then apply with `migrate dev` (no `--create-only`) or `migrate deploy`.

## Windows without `make`

Use `docker compose -f docker-compose-local.yaml exec backend …` instead of `make migrate` / `make seed`.

## Host-side alternative

If `DATABASE_URL` in `.env` points at `localhost:5432` (postgres exposed), you can run from `backend/`:

```bash
npx prisma migrate dev --name describe_change
```

Prefer the **Docker exec** path so `DATABASE_URL` matches the running stack.

## Checklist

```
- [ ] schema.prisma updated
- [ ] prisma migrate dev --name … (generated SQL, not hand-written)
- [ ] prisma migrate status shows up to date
- [ ] seed updated if needed and re-run
- [ ] backend code uses new Prisma types (generate ran)
```

## Related skills

- `signbank-data-model` — entities, enums, relationships
- `signbank-dev-environment` — Docker stack, compose files, troubleshooting
3 changes: 2 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@ POSTGRES_DB=signbank
DATABASE_URL=postgresql://postgres:postgres@localhost:5432/signbank
DATABASE_URL_DOCKER=postgresql://postgres:postgres@postgres:5432/signbank

# --- Admin account (created on first startup via seed) ---
# --- Admin bootstrap (only used when no admin exists in DB; local seed creates admin1–10) ---
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=changeme
# Local dev login after seed: admin1@signbank.com / admin1123 (pattern admin{N}@signbank.com / admin{N}123)

# --- Typesense search engine ---
TYPESENSE_API_KEY=your-typesense-api-key-here
Expand Down
156 changes: 0 additions & 156 deletions Examples/0001_menjar.json

This file was deleted.

Loading
Loading