-
Notifications
You must be signed in to change notification settings - Fork 183
[database] Clean up mri_scan_type #9304
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
Merged
driusan
merged 6 commits into
aces:main
from
maximemulder:improve-database-mri-scan-type
Jan 7, 2025
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
4fe6ea4
add patch
maximemuldermcgill 95a6803
address suggestions
maximemulder a1691df
update single use tool
maximemulder c3ae03e
Update modules/mri_violations/php/protocolcheckviolationprovisioner.c…
maximemulder 9b494d6
use change instead of rename
maximemulder 3b4c0ac
Merge branch 'improve-database-mri-scan-type' of https://github.com/M…
maximemulder File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
-- Rename foreign key fields for consistency | ||
|
||
ALTER TABLE `mri_scan_type` | ||
CHANGE `ID` `MriScanTypeID` int(11) unsigned NOT NULL auto_increment; | ||
|
||
ALTER TABLE `mri_scan_type` | ||
CHANGE `Scan_type` `MriScanTypeName` VARCHAR(255) NOT NULL; | ||
|
||
ALTER TABLE `mri_protocol` | ||
CHANGE `Scan_type` `MriScanTypeID` int(10) unsigned NOT NULL; | ||
|
||
ALTER TABLE `mri_protocol_checks` | ||
CHANGE `Scan_type` `MriScanTypeID` int(11) unsigned DEFAULT NULL; | ||
|
||
ALTER TABLE `mri_violations_log` | ||
CHANGE `Scan_type` `MriScanTypeID` int(11) unsigned DEFAULT NULL; | ||
|
||
ALTER TABLE `files` | ||
CHANGE `AcquisitionProtocolID` `MriScanTypeID` int(10) unsigned default NULL; | ||
|
||
-- Add unique constraints on table that benefit from them | ||
|
||
ALTER TABLE `mri_protocol_group_target` | ||
ADD CONSTRAINT `UK_mri_protocol_group_target` | ||
UNIQUE (`ProjectID`, `CohortID`, `Visit_label`); | ||
cmadjar marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
ALTER TABLE `mri_scan_type` | ||
ADD CONSTRAINT `UK_mri_scan_type_name` | ||
UNIQUE KEY `MriScanTypeName` (`MriScanTypeName`); | ||
|
||
-- Drop wrong default | ||
|
||
ALTER TABLE `mri_protocol` | ||
ALTER `MriScanTypeID` DROP DEFAULT; | ||
|
||
-- Add missing foreign key constraints | ||
|
||
ALTER TABLE `mri_protocol` | ||
ADD CONSTRAINT `FK_mri_protocol_scan_type` | ||
FOREIGN KEY (`MriScanTypeID`) REFERENCES `mri_scan_type` (`MriScanTypeID`); | ||
|
||
ALTER TABLE `mri_violations_log` | ||
ADD CONSTRAINT `FK_mri_violations_log_scan_type` | ||
FOREIGN KEY (`MriScanTypeID`) REFERENCES `mri_scan_type` (`MriScanTypeID`); | ||
|
||
-- Rename the existing constraints for consistency | ||
|
||
ALTER TABLE `mri_protocol_checks` | ||
DROP FOREIGN KEY `FK_mriProtocolChecks_ScanType`, | ||
ADD CONSTRAINT `FK_mri_protocol_checks_scan_type` | ||
FOREIGN KEY (`MriScanTypeID`) REFERENCES `mri_scan_type` (`MriScanTypeID`); |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
@nicolasbrossard @driusan I am curious what you think of the
DEFAULT NULL
forMriScanTypeID
of tablemri_violations_log
. My understanding is that it can never beNULL
based on the code since the violations log happen after scan identification. But before we remove theDEFAULT NULL
from this table, I'd like your input. :)Thank you!
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.
@cmadjar I agree with you: I don't think a
DEFAULT NULL
makes sense here so I'd remove it.Uh oh!
There was an error while loading. Please reload this page.
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.
@cmadjar I agree that if this can not be
NULL
we might just add aNOT NULL
constraint, but should it really be in this (already quite large) PR ?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.
That's fine, it can be in a different PR. @maximemulder Could you create an issue for it so we do not forget about it?