adds a new class InvestigationSample to the schema
(representing a many-to-many relationship between Investigation and Sample)
changes the unique constraint for the Sample table from investigation, name to just pid
(adding a NOT NULL constraint for pid while also keeping the existing NOT NULL constraint for name)
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 the id attribute) for all samples where the pid is currently NULL. However, in the current ICAT schema, the pid field has no unique constraint. This means that there could already be two samples with the same pid (at least theoretically). Or perhaps there could be several samples with the pid 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 the Sample table are updated and the Sample.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.
This closes #231.
Here is a short summary of the changes:
InvestigationSample
to the schema (representing a many-to-many relationship betweenInvestigation
andSample
)Sample
table frominvestigation, name
to justpid
(adding a NOT NULL constraint forpid
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.