Skip to content

Phase 1.3 [Backend]: Catch the admin up to the new v2 schema (companies, photos, posters) #294

Done

Description

@Flapjacck

Overview

Bring the admin's data layer up to date with the v2 schema changes from 7f32a8f (07_companies_photos_posters.sql): v2.companies, v2.guests.company_id, v2.photos, v2.photo_guests and v2.events.poster_path. The admin's types and data functions don't know any of these yet. Everything else in Phase 2 builds on this.

Part of #201. There's no frontend issue for this phase; the UI for it is in 2.2, 2.3 and 2.4.

What to do

Types

  • Regenerate apps/admin/src/types/database.types.ts with --schema public,v2 (see apps/admin/README.md). It should gain companies, photos, photo_guests, guests.company_id and events.poster_path.
  • New types/company.ts: CompanySchema (id, name, colour #rrggbb, logoPath, logoUrl), Company, CompanyFields.
  • New types/photo.ts: PhotoSchema (id, path, url, alt, eventId, isTeamPhoto, sortOrder, guestIds), Photo, PhotoFields.
  • types/guest.ts: add companyId (and the joined company for display), so title is just the job title.
  • types/event.ts: replace coverPath and coverPhotoId with posterPath, and keep pictureUrl built from it.

Storage

  • lib/server/storage.ts: add guest-photos, event-photos and company-logos to BUCKETS.
  • Bug: lib/data/guests.ts uploads guest headshots to team-images. They belong in guest-photos under <guest_id>/<file> (as documented in 01_schema.sql). Fix the upload, the public URL and the delete.

Data functions and hooks (same style as lib/data/team.ts and hooks/useTeam.ts)

  • lib/data/companies.ts + hooks/useCompanies.ts: list, get, create, update, delete, with logo upload, replace and remove in company-logos. Logos are raster only (no SVG).
  • lib/data/photos.ts + hooks/usePhotos.ts: list (by event, team photos, by guest), add (upload to event-photos), update alt / event / team flag, delete (row + file), reorder.
  • lib/data/photo-guests.ts: tag and untag a guest in a photo, and reorder one guest's photos (their first photo is the one Meet the Professionals shows).
  • lib/data/events.ts: read and write the poster through events.poster_path (event-media/<event_id>/) instead of applyCoverPhoto writing event_photos cover rows. Delete the old poster file when it's replaced or removed. Coordinate with the site, which still reads covers from event_photos (see 3.2).

Site cache

  • Add an .sql step in supabase/v2/ that adds site_data_versions triggers for the v2 tables, so the site's cache refreshes when the admin edits v2 (pattern in migrations/20261121200000_site_data_versions.sql). Reuse the events and team areas, and add new areas if the site needs them (for example guests, photos). Update supabase/v2/README.md.

Tests

  • Tests in apps/admin/tests/lib/data/ for the new modules, using supabase-v2-mock.ts.
  • Update the existing events and guests tests for the poster and bucket changes.

Done when

  • Types regenerated, and the new types compile with no as any on the new tables
  • Guest photos go to guest-photos
  • Companies, photos and photo-guests functions and hooks exist and are tested
  • Event poster saved in events.poster_path
  • The v2 tables bump site_data_versions
  • pnpm test and pnpm build pass in apps/admin

Activity

  1. added
    admin
    backend
    v2-migration
    phase-1
    data-layer
    on Nov 28, 2026
  2. Flapjacck commented on Nov 28, 2026

    @Flapjacck
    MemberAuthor

    Progress from the admin stack (#311 to #316):

    Done

    Still to do

    • Event posters: database.types.ts still has no events.poster_path, and lib/data/events.ts still saves covers through applyCoverPhoto into v2.event_photos. types/event.ts still has coverPath and coverPhotoId. Switch these to poster_path (the site already reads poster_path as of b88796e), then regenerate the types again.
    • Company delete: there's no deleteCompany or useDeleteCompany yet, including removing the logo files.
    • Update the events tests for the poster change.
  3. Flapjacck commented on Nov 30, 2026

    @Flapjacck
    MemberAuthor

    Done, checked against main:

    The leftover event_photos code is tracked in #307.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    adminbackenddata-layerphase-1v2-migration

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions