feat(people): cutover Person from department to teamId (Slice 2/2) #5
Reference in New Issue
Block a user
Delete Branch "feature/add-teams-slice-2"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Cuts over
Person.departmenttoPerson.teamId, drops thePersonDepartmentenum, and cleans up the legacy i18n keys. This is Slice 2 of 2 in theadd-teamschained PR. Depends on Slice 1 (#4), which added theTeamentity and management tab.What's in
Person.departmentreplaced withPerson.teamId(FK toTeam, nullable,onDelete: SetNull).Person.teamIdfrom the oldPersonDepartmentenum (using the 8 seed teams from Slice 1's migration), then drops thePerson.departmentcolumn, the@@index([department, deletedAt])index, and thePersonDepartmentenum — all in one transaction.person.schema.tsanduser.schema.tsupdated:teamIdreplacesdepartment. Empty string from the "Select a team" option is accepted and transformed tonullviaz.union + transform.PersonServiceread projections now includeteam: { id, name }so the person list and detail pages can renderperson.team?.name.person.use-cases.tsupdated:createPersonUseCase,updatePersonUseCase,createPersonUserUseCase,updatePersonUserUseCasenow handleteamId(preflight check against existing teams,teamNotFoundmapping).new.person.form.tsxandedit.person.form.tsx(replaces the old department select).person.team?.name(with—fallback when null).—fallback when null).inventory.people.departmentsremoved fromen.tsandes.ts. New keys:inventory.people.list.columns.team,inventory.people.detail.labels.team,inventory.people.form.{teamLabel,teamPlaceholder},inventory.people.fallback.noTeam,inventory.people.schema.teamIdInvalid,inventory.people.actions.teamNotFound,admin.users.form.{teamLabel,teamPlaceholder}.import.form.tsx+import.actions.ts) updated: department dropdown replaced with team picker; unknown department maps tonull(no team).person.use-cases.test.ts,person-user.use-cases.test.ts,update-person-user.use-cases.test.ts,person.schema.test.ts,unified-create.schema.test.ts,unified-update.schema.test.ts,core-schemas.test.ts, i18n dictionary tests, and helpers updated to useteamId.tests/e2e/people.spec.tscovering: tab routing via URL, team CRUD, person with team (shows in list and detail), person without team (shows—fallback).type="button"in mocked Button components).What's out
Nothing — this is the final slice of the add-teams change.
Hard delete decision
Team uses hard delete (no
deletedAt). FKonDelete: SetNullonPerson.teamIdhandles the cascade automatically.Empty string in team picker
The "Select a team" option sends an empty string. The Zod schema uses
z.union([z.string().uuid(), z.literal("")]).transform((val) => val === "" ? null : val)to accept it as "no team". This keeps the form's input type asstring(notunknown) so react-hook-form'szodResolvertype inference stays correct.PR chain
feature/add-teamsfeature/add-teams-slice-1— PR feat(teams): add Team entity foundation (Slice 1/2) (#4)feature/add-teams-slice-2Verification
bun run test:unit— 223 testsbun run test:integration— 86 testsbun run test:e2e— 4 people e2e tests passbunx tsc --noEmitbunx prisma validatebunx biome check .Diff: ~22 commits on top of Slice 1.
Related
openspec/changes/add-teams/proposal.mdopenspec/changes/add-teams/specs/team-management.md,openspec/changes/add-teams/specs/person-team.mdopenspec/changes/add-teams/design.mdopenspec/changes/add-teams/tasks.md