Debug composite primary keys for Issue model
- Dominant language
- Python
- Stars
- 9
- Forks
- 31
- Avg merge
- 3d 19h
- Merged PRs (30d)
- 16
Description
Issue has a composite primary key, composed of `id` and `version`but our Django Model only considers `id` as the primary key and add `version` only in the `unique_together` meta field. We should investigate if this has had any problems with our queries, because not specifying the composite primary key could cause the Django ORM to perform incorrect joins in this table. The same goes for defining `issue_id` and `issue_version` as composite foreign keys in Incidents
We maybe haven't face any problem yet because we should always be passing the issue_version to `filter` when performing any queries in Incidents and/or Issues
- https://docs.djangoproject.com/en/dev/topics/composite-primary-key/
- https://docs.djangoproject.com/en/5.1/ref/models/options/#unique-together
Contributor guide
Research direction
Start by reading Django's composite primary key documentation and inspecting the Issue and Incident model definitions. Trace queries and joins involving issue_id, issue_version, and the unique_together constraint, then determine whether Django currently supports the required composite primary and foreign keys and document or test the affected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, database
- Issue type
- Refactor
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100