Repository navigation
Done
Labels
adminAdmin dashboard (apps/admin)backendBackend changesdata-layerData layer / CRUD operationsphase-1Phase 1: Foundation & Data Layerv2-migrationV2 schema migration work
Description
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.tswith--schema public,v2(seeapps/admin/README.md). It should gaincompanies,photos,photo_guests,guests.company_idandevents.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: addcompanyId(and the joinedcompanyfor display), sotitleis just the job title.types/event.ts: replacecoverPathandcoverPhotoIdwithposterPath, and keeppictureUrlbuilt from it.
Storage
lib/server/storage.ts: addguest-photos,event-photosandcompany-logostoBUCKETS.- Bug:
lib/data/guests.tsuploads guest headshots toteam-images. They belong inguest-photosunder<guest_id>/<file>(as documented in01_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 incompany-logos. Logos are raster only (no SVG).lib/data/photos.ts+hooks/usePhotos.ts: list (by event, team photos, by guest), add (upload toevent-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 throughevents.poster_path(event-media/<event_id>/) instead ofapplyCoverPhotowritingevent_photoscover rows. Delete the old poster file when it's replaced or removed. Coordinate with the site, which still reads covers fromevent_photos(see 3.2).
Site cache
- Add an
.sqlstep insupabase/v2/that addssite_data_versionstriggers for the v2 tables, so the site's cache refreshes when the admin edits v2 (pattern inmigrations/20261121200000_site_data_versions.sql). Reuse theeventsandteamareas, and add new areas if the site needs them (for exampleguests,photos). Updatesupabase/v2/README.md.
Tests
- Tests in
apps/admin/tests/lib/data/for the new modules, usingsupabase-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 anyon 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 testandpnpm buildpass inapps/admin
Metadata
Metadata
Assignees
Labels
adminAdmin dashboard (apps/admin)backendBackend changesdata-layerData layer / CRUD operationsphase-1Phase 1: Foundation & Data Layerv2-migrationV2 schema migration work
Activity
Flapjacck commentedon Nov 28, 2026
Progress from the admin stack (#311 to #316):
Done
BUCKETSnow hasguest-photos,event-photosandcompany-logos(Admin: photo library data, listing and uploading photos in v2 #311, Admin: guest and company data, with who speaks where #312)guest-photosinstead ofteam-images(Admin: guest and company data, with who speaks where #312)types/company.ts,types/photo.tsandguests.companyId(Admin: photo library data, listing and uploading photos in v2 #311, Admin: guest and company data, with who speaks where #312)lib/data/companies.ts+useCompanies: list, create and update with face and card logos incompany-logos(Admin: guest and company data, with who speaks where #312, Admin: Companies page, with a logo framed for a speaker's face and for their card #316)lib/data/photos.ts+usePhotos: list, upload, edit, delete, guest tagging and the event, team and guest reorders (Admin: photo library data, listing and uploading photos in v2 #311, Admin: select, edit and arrange photos #314). Guest tagging lives inphotos.ts, not a separatephoto-guests.ts, and that's fine.database.types.tsregenerated withcompanies,photos,photo_guestsandguests.company_id(Admin: photo library data, listing and uploading photos in v2 #311)site_data_versionstriggers for v2 are already on main (supabase/v2/09_site_data_versions.sql, 30e8fe6)Still to do
database.types.tsstill has noevents.poster_path, andlib/data/events.tsstill saves covers throughapplyCoverPhotointov2.event_photos.types/event.tsstill hascoverPathandcoverPhotoId. Switch these toposter_path(the site already readsposter_pathas of b88796e), then regenerate the types again.deleteCompanyoruseDeleteCompanyyet, including removing the logo files.Flapjacck commentedon Nov 30, 2026
Done, checked against main:
The leftover event_photos code is tracked in #307.