Add many-to-many relationship InvestigationSample to the schema #240
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.
This closes #231.
Here is a short summary of the changes:
InvestigationSample
to the schema(representing a many-to-many relationship between
Investigation
andSample
)Sample
table frominvestigation, name
to justpid
(adding a NOT NULL constraint for
pid
while also keeping the existing NOT NULL constraint forname
)Note that this is still very much a work in progress. A few points to note:
The upgrade script initializes the value of the
Sample.pid
field with 'local:<id>' (reusing theid
attribute) for all samples where thepid
is currentlyNULL
. However, in the current ICAT schema, thepid
field has no unique constraint. This means that there could already be two samples with the samepid
(at least theoretically). Or perhaps there could be several samples with thepid
set to '' (an empty string). The upgrade script currently does not handle these cases (as they are very unlikely to occur in practice).The upgrade script also needs to move the existing one-to-many relationship between Investigation and Sample over to the new
InvestigationSample
table. Once this is done, the unique constraints on theSample
table are updated and theSample.investigation_id
column is dropped. I'm not sure if the current implementation of the upgrade script handles all of this correctly. In other words: thorough testing is needed.