-
Notifications
You must be signed in to change notification settings - Fork 687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Enable foreign key support #5503
Comments
As part of the 9/17-10/1 sprint, we agreed during sprint planning to have a preliminary discussion and investigation focused on enabling foreign key support, e.g.:
We'll set up an initial tech chat about this (probably a small group), and go from there, aiming to limit our commitment for this sprint to about about 4-8 hours total. |
We discussed this a bit more in the context of #5467 in the last sprint, and will likely continue that discussion at the next tech meeting. Keeping the issue on the sprint, but only to capture emerging consensus. |
We'll likely revisit this after we've completed the complex template consolidation effort (in the SecureDrop Workstation project, see freedomofpress/securedrop-workstation#471), and after #5467 has landed, which is one important prerequisite. |
Just to close the loop on my own (pedantic) point of confusion during yesterday's discussion of #5467 (comment): A SQLite sqlite> PRAGMA foreign_keys = ON; -- as above
sqlite> insert into source_stars (source_id, starred) values ('b', 1); -- as above
Error: FOREIGN KEY constraint failed
sqlite> insert into source_stars (source_id, starred) values (null, 1);
sqlite> SELECT * FROM source_stars;
1||1 So the reasons to avoid null |
@cfm - it's a good point that I missed when I created this issue. Null is a special case in sqlite and will not cause a foreign key contraint error, e.g.
One might assume both update statements would fail due to the table constraint: Update: I elaborate on the reason the current |
Moving this out of the 2.2.0 milestone (and moving #6192 in) - at this stage it's too ambitious to get it into the next release. |
Description
Right now we do not have foreign key support enabled for db.sqlite so we're not getting foreign key protections to ensure referential integrity, see https://docs.sqlalchemy.org/en/13/dialects/sqlite.html#foreign-key-support.
Steps to Reproduce
To enable foreign keys and see them working:
Expected Behavior
For foreign keys to be enforced.
Actual Behavior
Foreign keys are not enforced.
The text was updated successfully, but these errors were encountered: