openedx / openedx/openedx-core
Implement a system check to verify integrity of our data models?
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 10
- Forks
- 32
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 12
Description
This is just an idea for now; it may be pretty low importance unless we learn that these issues have actually happened.
Many aspects of our data models are required to be a certain way, but we cannot make the database enforce that directly (without using triggers). We try to validate these things using clean() etc. but those checks are not always run (e.g. when using update()).
To help avoid and diagnose issues, we could write checks that use the Django system check framework to inspect the database and verify the integrity of our models.
Database checks are not run by default because they do more than static code analysis as regular checks do. They are only run by the migrate command or if you specify configured database aliases using the --database option when calling the check command.
Alternately, such validation checks could be written as a Django management command, or even a REST API that provides tooling and reporting via the admin console.
Issues that such system checks could look for:
LearningPackagewith no corresponding course/library (warning, not error)PublishableEntitywith no corresponding Component/Container/etc.component.learning_package_id != component.publishable_entity.learning_package_idcomponent_version.component.publishable_entity_id != component_version.publishable_entity_version.entity_idcontainer_version.container.publishable_entity_id != container_version.publishable_entity_version.entity_idpublish_log_record.entity.learning_package_id != publish_log_record.publish_log.learning_package_iddraft_change_log_record.entity.learning_package_id != draft_change_log_record.draft_change_log.learning_package_idcollection_publishable_entity.entity.learning_package_id != collection_publishable_entity.collection.learning_package_idcomponent_version_media.component_version.component.learning_package_id != component_version_media.media.learning_package_id
Contributor 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.
Research direction
Start by reviewing the Django system check framework and the model relationships named in the issue. Compare whether checks should run through migrate/check, a management command, or another reporting path. Done means an agreed scope and implementation that detects the listed integrity mismatches without treating the missing LearningPackage relationship as an error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- backend, databases
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 30/100