Open
Description
Current state
Currently there are no foreign key constraints in the db.
Expected state
Adding some would have the following advantages:
- Prevent unforeseen runtime errors caused by broken references in future changes
- Enhance manual crawling: Crawling through the DB is difficult due to broken references
- Prevent bloated DB size
- Prevent data from partially not being removed, when removal was specifically requested by a user due to GDPR requests
- Tooling: Lots of DB viewers (such as DBeaver) support following foreign keys by ctrl clicking on them and other features like automated ERD generation.
Difficulty
Looking through the DB dump of my own foodcoop I found a lot of inconsistencies. (also see #158) Those will first have to be cleaned up by either deleting the records or setting foreign keys to NULL
. (Which of the two depends on the way each of them is used in the application and on whether they are nullable.)
Also it will have to be decided how to best set which of the constraints (on delete cascade/set null/restrict).