PrevEmployment: add FK user_account → employee.user_account with ON UPDATE CASCADE
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
Research direction
Start with api/db/schema/prev_employment.py and the Alembic migration for #138 to follow the existing foreign key pattern. Check how migrations detect and report orphaned prev_employment rows, then add the constraint with ON UPDATE CASCADE and default delete behavior. Add tests for cascading employee account updates and rejecting unknown accounts; done when both behaviors pass and orphan handling is explicit.
Written by the indexing model from the issue text.
Description
PrevEmployment.user_account is a bare UUID column with no relation to Employee. Align it with the decision made for StudentDocuments in #138.
Goal
Add a foreign key PrevEmployment.user_account → employee.user_account with ON UPDATE CASCADE, so that:
- no
PrevEmploymentrow can reference a non-existent user (referential integrity) - remapping
employee.user_account(e.g. during the planned account fusion migration) updatesPrevEmploymentautomatically
Lookups keep using the JWT sub directly; no join through Employee is needed.
Tasks
- Alembic migration adding the FK constraint (
ON UPDATE CASCADE; delete behaviour stays as default/restrict) - Before adding the constraint: detect orphaned
prev_employmentrows whoseuser_accounthas no matchingemployeerow, and decide how to handle them (delete / report). The migration must not fail silently. - Update the SQLModel schema
api/db/schema/prev_employment.py(foreign_key="employee.user_account",ondelete/onupdateviasa_column_kwargsorsa_column) - Test: updating
employee.user_accountcascades toprev_employment.user_account - Test: inserting a
PrevEmploymentwith an unknownuser_accountfails
Out of scope
- Changes to the PrevEmployment endpoints
Related: #138
- Dominant language
- Python
- Stars
- 0
- Forks
- 0
- Avg merge
- 39m
- Merged PRs (30d)
- 10
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- No contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from ClockGU/clockwork-backend
-
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
ClockGU/clockwork-backend#169 ·
Maintainers usually reply within 1 day
-
Difficulty 4/5 3-5 days Newbie friendliness 20/100
ClockGU/clockwork-backend#165 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
ClockGU/clockwork-backend#164 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 20/100
ClockGU/clockwork-backend#163 ·
Maintainers usually reply within 1 day
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
ClockGU/clockwork-backend#162 ·
Maintainers usually reply within 1 day
All issues in ClockGU/clockwork-backend
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
Nixtla/mlforecast#823 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
microsoft/ML-For-Beginners#1061 ·
-
bot-found documentation priority: P3
Difficulty 2/5 Under an hour Newbie friendliness 82/100
madenvel/KalinkaPlayer#503 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
EleutherAI/lm-evaluation-harness#4508 ·
Maintainers usually reply within 1 day