Repository navigation
Store Gamma IDs instead of names for bookings - #120
Merged
Merged
Conversation
Bookings stored the super group name in booked_as and the booker's cid in booked_by. The "booked by" and "booking as" links pointed at gamma.chalmers.it with those values, but Gamma only routes users and super groups by ID, so both links went to "not found". Bookings now store Gamma UUIDs in uuid columns. Names are looked up in Gamma and cached in memory: the group's pretty name, and the booker as First "Nick" Last. Links use ISSUER_BASE_URL, so they also work against the local Gamma. Existing bookings are converted automatically on the first start of the new version. Data migrations that need more than SQL live in bookit/src/data-migrations and run once, before the server accepts requests, tracked in a new data_migration table. If Gamma can't be reached, startup fails and the next start retries; nothing is changed until it succeeds. Sessions now hold super group IDs, so everyone is signed out once.
There was a problem hiding this comment.
🟡 Changes recommended
The user cache retains personal data after privacy cleanup because expired entries are never removed, allowing retention beyond the stated period until process restart.
1 open issue
What changed in this PR
This PR switches booking ownership from Gamma names and cids to UUIDs, enabling working profile links and readable names while updating permissions and privacy cleanup.
Changes:
- Adds transactional startup migrations to convert existing bookings and record completed conversions.
- Resolves Gamma display names through an in-memory cache and builds profile links from
ISSUER_BASE_URL. - Updates booking forms, authorization checks, schemas, documentation, and tests for ID-based ownership.
| File | Description |
|---|---|
| README.md | Documents Gamma links, caching, and upgrade behavior. |
| frontend/src/pages/booking.tsx | Displays Gamma names and ID-based profile links. |
| frontend/src/lib/privacy.ts | Updates disclosures for Gamma IDs and displayed names. |
| frontend/src/generated/graphql.ts | Regenerates frontend types and query documents. |
| frontend/src/components/booking-form.tsx | Uses group IDs with readable dropdown labels. |
| frontend/src/api/operations.graphql | Requests Gamma names, groups, and base URL. |
| e2e/permissions.spec.ts | Expects pretty names in group options. |
| e2e/booking-lifecycle.spec.ts | Checks displayed names and Gamma profile links. |
| e2e/booking-helpers.ts | Selects booking groups by display label. |
| codegen.ts | Maps GraphQL users to session-user types. |
| bookit/src/tests/groups.test.ts | Updates group eligibility tests for IDs. |
| bookit/src/tests/gamma.test.ts | Tests ownership conversion and display-name formatting. |
| bookit/src/tests/event.test.ts | Tests permissions with UUIDs and nullable ownership. |
| bookit/src/tests/directory.test.ts | Tests cache sharing, refreshes, and retries. |
| bookit/src/tests/booking-group.test.ts | Tests group validation and Gamma failure handling. |
| bookit/src/services/rule.service.ts | Removes ownership from the rule-booking type requirement. |
| bookit/src/services/event.service.ts | Uses IDs and nullable ownership in booking logic. |
| bookit/src/schemas/v1/user.gql | Adds Gamma profile types and URL query. |
| bookit/src/schemas/v1/event.gql | Adds resolved profiles and nullable ownership fields. |
| bookit/src/resolvers/user.resolver.ts | Exposes the configured Gamma base URL. |
| bookit/src/resolvers/index.ts | Wires profile lookups and ID-based phone access. |
| bookit/src/resolvers/gamma.resolver.ts | Formats Gamma profiles with lookup fallbacks. |
| bookit/src/resolvers/event.resolver.ts | Validates booking groups and stores user IDs. |
| bookit/src/index.ts | Runs data migrations before serving requests. |
| bookit/src/generated/schema.ts | Regenerates backend schema and resolver types. |
| bookit/src/gamma/directory.ts | Adds Gamma directory access and caching. |
| bookit/src/data-migrations/index.ts | Coordinates and records transactional data migrations. |
| bookit/src/data-migrations/0001-gamma-ids.ts | Converts legacy ownership values to Gamma UUIDs. |
| bookit/src/cleanup.ts | Clears booker IDs using NULL. |
| bookit/src/auth/session-store.ts | Invalidates sessions using the previous ownership format. |
| bookit/src/auth/groups.ts | Derives bookable memberships using group IDs. |
| bookit/prisma/schema.prisma | Defines nullable UUID ownership and migration records. |
| bookit/prisma/migrations/20261028000001_gamma_id_columns/migration.sql | Converts columns directly when legacy lookup is unnecessary. |
| bookit/prisma/migrations/20261028000000_data_migration/migration.sql | Creates the data-migration tracking table. |
Review effort: Balanced
The user cache never removed entries, so a booker's name could stay in memory after the cleanup had cleared them from the booking.
This was referenced Oct 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Clicking "Booked by" or "Booking as" on a booking took you to gamma.chalmers.it, which no longer hosts Gamma, and even on auth.chalmers.it the links would 404. Gamma only routes users and super groups by ID, and we stored the super group name and the booker's cid.
What changed
booked_asis the super group ID andbooked_bythe user ID, both asuuidcolumns. A cleared booker isNULLinstead of''.First "Nick" Last, fetched from Gamma and cached in memory. Both link to Gamma by ID.ISSUER_BASE_URL, so the links also work against the local Gamma in development.Upgrading: nothing to do by hand
Existing bookings are converted automatically the first time the new version starts:
prisma migrate deployruns as usual from the entrypoint.bookit/src/data-migrations. This one looks up group names and cids in Gamma and replaces them with IDs. Each data migration runs once and is recorded in a newdata_migrationtable, so later starts skip it.A few things to know:
NULLand logged by booking ID: groups Gamma no longer has, old private bookings, and bookers who no longer accept BookIT in Gamma. A booking without a booker works like one whose personal data was already cleared.Testing
mainagainst Postgres, Redis and the local Gamma, made bookings through the old app (plus an unknown group, an old private booking and a cleared booker), then started this branch on the same database. Everything was converted on startup,updated_atwas untouched, old sessions were signed out, the links opened the right pages in Gamma, members could still edit, move and delete their old bookings, phone numbers stayed private, and a restart didn't convert again. Starting with Gamma down failed and left the data untouched, then worked once Gamma was back.