feat: link a Job/Contract's employer to a network Organization #375
Labels
No labels
area:auth
area:ci
area:db
area:infra
area:native
area:pwa
area:service
epic
feature
foundation
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
james/carol#375
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
Tie a company you've worked at (a Job's/Contract's employer, currently free-text
jobs.company) to a tracked network Organization, mirroring the people↔organizations "link-or-stub" pattern. Discussed + agreed design below.Model
organization_idFK on thejobstable (ON DELETE SET NULL). Jobs are 1:1 with an employer, so it's a column, not a junction.companytext holds the name — every existing job keeps working untouched (it's the stub).organization_idpoints at an Organization; the org's name is the live source for display (rename the org → the job reflects it).companyis kept as a fallback snapshot.jobstable,is_contractflag).Decisions (settled in discussion)
person_organizations, which usesstub_nameonly when unlinked).OrganizationsRepository.deleteById, before removing the org,UPDATE jobs SET company = <org.name>, organization_id = NULL WHERE organization_id = <id>so linked jobs gracefully degrade to a stub with the last-known name (no data loss). The FKON DELETE SET NULLis the belt-and-suspenders safety net.Build (API-first, then client)
Backend (PR 1):
jobs.organization_idnullable FK →organizations(id)ON DELETE SET NULL.JobsRepository: acceptorganizationIdon create/update; resolve the live org name (LEFT JOIN organizations) so the DTO carriesorganizationId+organizationName; addlistByOrganizationId(userId, orgId)for the reverse view.OrganizationsRepository.deleteById: the copy-down before delete.zJobCreate/zJobUpdategain optionalorganizationId(nullable; per-user 404 if it points at someone else's org or a missing one);zJobDtogainsorganizationId+organizationName.idea.md(Jobs: "company, optionally linked to a network Organization").Client (PR 2, follow-up):
Out of scope (follow-up)
link_job_to_org, mirroringlink_person_to_org).Updates
idea.md. Per-user isolation throughout; cross-user org links return 404.