Rework attachment handling during database migrations#7191
Merged
labkey-adam merged 12 commits intorelease25.11-SNAPSHOTfrom Nov 12, 2025
Merged
Rework attachment handling during database migrations#7191labkey-adam merged 12 commits intorelease25.11-SNAPSHOTfrom
labkey-adam merged 12 commits intorelease25.11-SNAPSHOTfrom
Conversation
…ernal data source. Adjust the attachment copying code to use this new mechanism.
…pecimen requests.
labkey-jeckels
approved these changes
Nov 12, 2025
Contributor
labkey-jeckels
left a comment
There was a problem hiding this comment.
There's a fair amount of edits in codepaths beyond migration. Hopefully automated tests will give good coverage without needing separate manual testing?
experiment/src/org/labkey/experiment/ExperimentMigrationSchemaHandler.java
Show resolved
Hide resolved
Contributor
Author
The changes (outside migration) are primarily adjusting AttachementTypes, right? These aren't really used, other than one code path (that I've tested multiple times during this development). I doubt there's any automated testing of the admin page that uses them. My leveraging AttachmentType here means they've gotten more use than ever and I've fixed several issues that no one noticed. |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Rationale
Repackage API classes into
org.labkey.api.migrationThe
Documentstable lives incorebut is effectively owned and managed by many different modules. The previous approach to migrating this table attempted to copy all attachments at once, which accommodated container filtering and (barely) the global attachment approach of Labbook, but not domain row and other complex filtering. As a result, we copied far too many rows that shouldn't have ended up in the cloned database and wasted hours of copying time.This new approach makes each schema handler responsible for copying the documents it manages, immediately after its tables have been populated. The schema handlers can usually delegate all the work to the existing
AttachmentTypeimplementations, which already know how to retrieve parent EntityIds for each type. I've adjusted AttachmentType slightly to make it more flexible (supporting the original use case where we selected EntityIds from the documents table and the new use case where we select those EntityIds from the populated tables instead).Also,
TempTableInClauseGeneratorwas hard-coded to create temp tables in the LabKey data source temp schema, which of course fails when using a large IN clause against an external data source. Teach TempTableInClauseGenerator how to use a different temp schema and introduce aSqlDialect.appendInClauseSql()variant that takes a customized InClauseGenerator for this purpose. The attachment copying code collects potentially large sets of EntityIds and RowIds from the target tables, then uses this mechanism to select the appropriate rows from the source database's core.Documents table.