-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement multiple external IDs for participants and samples (#659)
* Create participant_external_id and sample_external_id database tables * Pluralise external_ids in participant and sample models * Query *_external_id tables and implement upserting into them Change these simple sample/participant table SELECTs to also join the *_external_id table into the query. Update comments of SampleLayer etc methods that call through to these to indicate that they can look up samples via this table too. In WebDb._project_summary_sample_query(), we use a hack to divert external_id queries to the appropriate peid/seid *_external_id table. Fix documentation typo in SampleTable.get_sample_by_id(). Add from_db_json() utility, the opposite of to_db_json(). Add PRIMARY_EXTERNAL_ORG constant to clarify primary org name usage. Decode JSON-encoded external_ids fields in SampleInternal.from_db() and ParticipantInternal.from_db() routines. * Use the primary external_id for GraphQLParticipant/GraphQLSample [TODO] In future we will want to represent the extra external_ids in GraphQLParticipant/GraphQLSample too. But this stopgap lets us defer that until after the tests/ directory is adjusted. * Use the primary external_id for ParsedParticipant/ParsedSample et al [TODO] In future we will want to represent the extra external_ids in ParsedParticipant/ParsedSample too. But this stopgap lets us defer that until after the tests/ directory is adjusted. [TODO] These would prefer metamist.models to export PRIMARY_EXTERNAL_ORG (or from somewhere similar) so they didn't need to define it themselves. * Adjust tests to account for s/external_id/external_ids/g test_sample.py: Add a test exercising get_sample_id_map_by_external_ids(). test_upsert.py: Update direct SQL queries to use the new tables and to ensure that their rows are returned in the expected order. * Add tests exercising multiple external_id functionality * Remove obsolete participant/sample table external_id constraints But first we need to create indexes for the correspondingly named foreign keys, which previously re-used these constraints' composite indexes. This avoids "Cannot drop index needed in a foreign key constraint" errors. * Bodge SampleLayer.get_history_of_sample() Attempting to update the history query interfered with the intended behaviour of audit_log_ids. Revert the changes to propagate audit_log_id within untouched sample_external_id rows, and revert to the previous sample-table-only get_history_of_sample() with limitations: for now, it doesn't return external_ids or audit_log_ids. * Update db/project.xml per review Make external_ids unique per project regardless of external org (name) and adjust tests accordingly. Make the new tables' audit_log_id field non-NULL, and cons up a new audit_log entry for the external_id migrations to refer to. Drop the old external_id fields' not-NULL constraint before clearing their values -- previously omitted as this was tested only on empty tables! This is in a separate changeSet as system_versioning_alter_history=1 is needed, and we'd prefer not to set that during the main changeSet. * For now, create_test_subset.py copies only the primary external_id [TODO] In future we will represent the extra external_ids in GraphQLSample too and be able to copy all of them. * Bump version: 7.0.3 → 7.1.0
- Loading branch information
Showing
46 changed files
with
990 additions
and
241 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.