-
Notifications
You must be signed in to change notification settings - Fork 252
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
fix(sqlite): enable foreign keys for sqlite #98
fix(sqlite): enable foreign keys for sqlite #98
Conversation
@@ -35,7 +35,7 @@ func NewSQLLiteLoader(outFilename string) (*SQLLoader, error) { | |||
CREATE TABLE IF NOT EXISTS package ( | |||
name TEXT PRIMARY KEY, | |||
default_channel TEXT, | |||
FOREIGN KEY(default_channel) REFERENCES channel(name) | |||
FOREIGN KEY(name, default_channel) REFERENCES channel(package_name,name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
referencing a field that's part of a compound primary key requires referencing the full primary key - this was the main issue.
@@ -53,9 +53,7 @@ func NewSQLLiteLoader(outFilename string) (*SQLLoader, error) { | |||
replaces INTEGER, | |||
depth INTEGER, | |||
FOREIGN KEY(replaces) REFERENCES channel_entry(entry_id) DEFERRABLE INITIALLY DEFERRED, | |||
FOREIGN KEY(channel_name) REFERENCES channel(name), | |||
FOREIGN KEY(package_name) REFERENCES channel(package_name), | |||
FOREIGN KEY(operatorbundle_name) REFERENCES operatorbundle(name) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had to remove the foreign key to operator_bundle, since synthesized channel entries for skip
ed releases may not have a corresponding bundle.
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: ecordell, gallettilance, njhale The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Description of the change:
Foreign key constraints were not being enforced - thanks @gallettilance for finding this issue!
There were a couple of problems with the foreign keys that are fixed in this PR
Motivation for the change:
We want to rely on sqlite's enforcement of foreign keys so that we don't need to enforce them ourselves.
Reviewer Checklist
/docs