feat: pairs table with questions/statements placeholders
- pairs: status, answer_type enum (yes_no/text/word), difficulty_level, FK to questions + 2x statements (positive/negative), auto-timestamps - questions + statements placeholder tables for future use - Safe ALTER TABLE migration for existing pairs placeholder - /api/pairs CRUD route, answer_type required on create Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
46
README.md
46
README.md
@@ -152,12 +152,34 @@ words ──────────── word_pictures ───────
|
||||
|
||||
**Relations:** M2M mit `words`, `pictures`, `pairs` (pairs folgt später)
|
||||
|
||||
### Table: `pairs` (Platzhalter — Felder folgen)
|
||||
### Table: `pairs`
|
||||
|
||||
| Column | Type | Default | Description |
|
||||
|---|---|---|---|
|
||||
| `id` | `UUID` | `gen_random_uuid()` | Primary key |
|
||||
| `status` | `VARCHAR(20)` | `draft` | `draft` · `blocked` · `published` |
|
||||
| `answer_type` | `VARCHAR(20)` | — | `yes_no` · `text` · `word` (required) |
|
||||
| `difficulty_level` | `SMALLINT` | `null` | 1–50 |
|
||||
| `blocked_topic` | `TEXT` | `null` | Grund/Thema der Blockierung |
|
||||
| `question_id` | `UUID` FK | `null` | → `questions.id` (SET NULL on delete) |
|
||||
| `positive_statement_id` | `UUID` FK | `null` | → `statements.id` (SET NULL on delete) |
|
||||
| `negative_statement_id` | `UUID` FK | `null` | → `statements.id` (SET NULL on delete) |
|
||||
| `published_at` | `TIMESTAMPTZ` | `null` | Auto-set when status → `published` |
|
||||
| `blocked_at` | `TIMESTAMPTZ` | `null` | Auto-set when status → `blocked` |
|
||||
| `created_at` | `TIMESTAMPTZ` | `NOW()` | Auto-set on insert |
|
||||
| `updated_at` | `TIMESTAMPTZ` | `NOW()` | Auto-updated on every change (trigger) |
|
||||
|
||||
### Table: `questions` (Platzhalter — Felder folgen)
|
||||
| Column | Type |
|
||||
|---|---|
|
||||
| `id` | `UUID` PK |
|
||||
| `created_at` | `TIMESTAMPTZ` |
|
||||
| `updated_at` | `TIMESTAMPTZ` |
|
||||
| `created_at` / `updated_at` | `TIMESTAMPTZ` |
|
||||
|
||||
### Table: `statements` (Platzhalter — Felder folgen)
|
||||
| Column | Type |
|
||||
|---|---|
|
||||
| `id` | `UUID` PK |
|
||||
| `created_at` / `updated_at` | `TIMESTAMPTZ` |
|
||||
|
||||
### Table: `object_words` (Junction)
|
||||
| Column | Type |
|
||||
@@ -387,6 +409,24 @@ curl -X PATCH "$BASE/api/objects/<ID>" \
|
||||
|
||||
---
|
||||
|
||||
### Pairs
|
||||
|
||||
#### `GET /api/pairs` — Liste (`?status=draft&answer_type=yes_no&limit=50`)
|
||||
#### `GET /api/pairs/:id` — Einzelnes Pair
|
||||
#### `POST /api/pairs` — Neues Pair anlegen (`answer_type` ist Pflichtfeld)
|
||||
|
||||
```bash
|
||||
curl -X POST "$BASE/api/pairs" \
|
||||
-H "Authorization: Bearer $TOKEN" \
|
||||
-H "Content-Type: application/json" \
|
||||
-d '{"answer_type": "yes_no", "difficulty_level": 15}'
|
||||
```
|
||||
|
||||
#### `PATCH /api/pairs/:id` — Felder aktualisieren
|
||||
#### `DELETE /api/pairs/:id` — Pair löschen
|
||||
|
||||
---
|
||||
|
||||
### Utilities
|
||||
|
||||
#### `GET /api/tables`
|
||||
|
||||
Reference in New Issue
Block a user