Skip to content
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

Add foreign key constraints for all projectids #1655

Merged
merged 1 commit into from
Aug 17, 2023

Conversation

williamjallen
Copy link
Collaborator

Our database schema is currently a mess. With no foreign keys defined, it is easy to accidentally forget to update a relationship field properly when an entity is created or deleted. Virtually all modern relational databases support foreign key constraints, and there is no reason for us to not add them.

In a first step towards #1442, this PR adds foreign key constraints to all of the table columns which reference a project's ID. This should be a relatively low risk operation for production systems, but it creates a bit of a headache when writing tests, because creating any model which references a project necessarily requires a project model to be created as well.

@williamjallen williamjallen changed the title Add foreign keys for all projectids Add foreign key constraints for all projectids Aug 14, 2023
@williamjallen williamjallen force-pushed the project-foreign-keys branch 2 times, most recently from 11b57de to 6fc310a Compare August 14, 2023 17:24
@williamjallen williamjallen marked this pull request as draft August 14, 2023 18:23
@williamjallen williamjallen marked this pull request as ready for review August 14, 2023 19:38
@josephsnyder josephsnyder added this pull request to the merge queue Aug 17, 2023
Merged via the queue into Kitware:master with commit e9272a7 Aug 17, 2023
1 check passed
@williamjallen williamjallen deleted the project-foreign-keys branch August 17, 2023 21:30
github-merge-queue bot pushed a commit that referenced this pull request Aug 30, 2023
This PR builds upon the work in #1655, and adds foreign key constraints
to all buildid columns. Like #1655, a handful of changes to our test
suite were required to ensure that the constraints were fully met during
the testing process.

This is related to issue #1442.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants