diff --git a/CLAUDE.md b/CLAUDE.md index 4f7a888..abca6e6 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -4,7 +4,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co ## Project Overview -stammtisch-hersbruck.de is a SvelteKit 5 application using Svelte 5's new runes syntax ($state, $props, etc.) with PocketBase as the backend. The app manages events, runs, riders, times and teams for a motorsport/cycling event organization. +stammtisch-hersbruck.de is a SvelteKit 5 application using Svelte 5's new runes syntax ($state, $props, etc.) with PocketBase as the backend. The app manages events, stages, riders, times and teams for a motorsport/cycling event organization. The repository is a monorepo: the SvelteKit app lives in `frontend/`, the PocketBase instance in `backend/`. @@ -60,7 +60,7 @@ docker compose down Container und müssen mit `docker compose cp` ins Repo geholt werden; siehe `backend/README.md`. - **Type-safe client**: The PocketBase client is typed using auto-generated types in `frontend/src/lib/types.d.ts` -- **Collections**: users, teams, team_invites, events, runs, riders, times, +- **Collections**: users, teams, team_invites, events, stages, riders, times, trails, trail_versions, trail_flags, trail_markers, trail_comments, event_participants, event_series - **Regeln**: Jede Zugriffsregel, die `@request.auth.id` erwähnt, beginnt mit diff --git a/backend/README.md b/backend/README.md index d60c210..e1a1519 100644 --- a/backend/README.md +++ b/backend/README.md @@ -21,7 +21,7 @@ Damit das Frontend gegen diese Instanz läuft, in `../frontend/.env` Das Schema liegt als versionierte Migration in `pb_migrations/` und wird beim Start automatisch angewendet. Es enthält die sechs fachlichen Collections -`users`, `teams`, `events`, `runs`, `riders`, `times`. +`users`, `teams`, `events`, `stages`, `riders`, `times`. `1754400000_init_schema.js` ist ein Snapshot der produktiven Instanz. Er wurde per `GET /api/collections` abgezogen und ruft `importCollections` mit diff --git a/backend/pb_migrations/1754400000_init_schema.js b/backend/pb_migrations/1754400000_init_schema.js index efe36c8..3c4d8c9 100644 --- a/backend/pb_migrations/1754400000_init_schema.js +++ b/backend/pb_migrations/1754400000_init_schema.js @@ -588,7 +588,7 @@ migrate((app) => { "createRule": "team.users.id ?= @request.auth.id", "updateRule": "team.users.id ?= @request.auth.id", "deleteRule": "team.users.id ?= @request.auth.id", - "name": "runs", + "name": "stages", "type": "base", "fields": [ { @@ -916,7 +916,7 @@ migrate((app) => { "id": "ltfephwe", "maxSelect": 1, "minSelect": 0, - "name": "run", + "name": "stage", "presentable": false, "required": false, "system": false, diff --git a/backend/pb_migrations/1754502000_runs_become_stages.js b/backend/pb_migrations/1754502000_runs_become_stages.js new file mode 100644 index 0000000..a01ea26 --- /dev/null +++ b/backend/pb_migrations/1754502000_runs_become_stages.js @@ -0,0 +1,45 @@ +/// + +// Aus einem Run wird eine Stage. +// +// „Run" hiess in dieser App immer schon der abgesteckte Abschnitt eines +// Events, auf dem gefahren und gestoppt wird — also das, was im Rennsport +// Stage heisst. „Run" ist daneben der einzelne Durchgang eines Fahrers, und +// genau der steht hier als `times`. Zwei Bedeutungen fuer ein Wort, an einer +// Stelle, an der beide vorkommen. +// +// Umbenannt wird, nicht neu angelegt: Collection und Feld behalten ihre IDs, +// PocketBase benennt Tabelle und Spalte um, die Daten bleiben stehen. Ueber +// die ID gesucht statt ueber den Namen, damit die Migration auch auf einer +// frischen Datenbank durchlaeuft, deren Snapshot die Collection bereits +// `stages` nennt. + +const STAGES_COLLECTION_ID = 'jo49lycyfs2sz2c' + +migrate((app) => { + const stages = app.findCollectionByNameOrId(STAGES_COLLECTION_ID) + if (stages.name !== 'stages') { + stages.name = 'stages' + app.save(stages) + } + + const times = app.findCollectionByNameOrId('times') + const field = times.fields.getByName('run') + if (field) { + field.name = 'stage' + app.save(times) + } +}, (app) => { + const times = app.findCollectionByNameOrId('times') + const field = times.fields.getByName('stage') + if (field) { + field.name = 'run' + app.save(times) + } + + const stages = app.findCollectionByNameOrId(STAGES_COLLECTION_ID) + if (stages.name !== 'runs') { + stages.name = 'runs' + app.save(stages) + } +}) diff --git a/frontend/src/lib/components/Logo.svelte b/frontend/src/lib/components/Logo.svelte index 1790b51..a72bb9a 100644 --- a/frontend/src/lib/components/Logo.svelte +++ b/frontend/src/lib/components/Logo.svelte @@ -18,7 +18,7 @@ const url = $derived(team?.logo ? getFileURL(team, team.logo) : null) -