PrevEmployment: add FK user_account → employee.user_account with ON UPDATE CASCADE

Đang mở
#141 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
55/100
Loại issue
Tính năng
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python, sqlalchemy
Lĩnh vực
backend, databases

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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 PrevEmployment row can reference a non-existent user (referential integrity)
  • remapping employee.user_account (e.g. during the planned account fusion migration) updates PrevEmployment automatically

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_employment rows whose user_account has no matching employee row, 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/onupdate via sa_column_kwargs or sa_column)
  • Test: updating employee.user_account cascades to prev_employment.user_account
  • Test: inserting a PrevEmployment with an unknown user_account fails
Out of scope
  • Changes to the PrevEmployment endpoints

Related: #138

Ngôn ngữ chính
Python
Star
0
Fork
0
Merge trung bình
29 phút
Pull request đã merge (30 ngày)
14

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của ClockGU/clockwork-backend

Tất cả issue của ClockGU/clockwork-backend

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.