Fix SQL Server migration issues#7418
Conversation
| dd = ddArray.getFirst(); | ||
|
|
||
| // if someone has explicitly inserted a descriptor with the same URI as an existing one , | ||
| // and one of the two is in the shared project, use the project-level descriptor. | ||
| if (ddArray.size() > 1) | ||
| { | ||
| _log.debug("Multiple DomainDescriptors found for " + uriOrName); | ||
| if (dd.getProject().equals(ContainerManager.getSharedContainer())) | ||
| dd = ddArray.get(0); | ||
| dd = ddArray.getFirst(); |
There was a problem hiding this comment.
I know this wasn't your logic, but this doesn't right. dd = ddArray.getFirst(); then if it's the shared container dd = ddArray.getFirst(); again? Maybe the second one should be ddArray.get(1) or getLast()?
There was a problem hiding this comment.
The way I read the comment, we prefer a dd from the shared container. Seems like we should iterate over the list and return the first that's in shared else return the first. I'll tag Josh since it looks like he added this. @labkey-jeckels
There was a problem hiding this comment.
I agree that this code isn't doing anything useful today, and looks flawed when I committed it.
I believe the comment is saying the opposite. If we have a match in /Shared and another match in /MyProject, use the one from /MyProject.
We have a unique constraint on exp.DomainDescriptor(domainuri, container). We're passing in two container values in the WHERE clause (which could be the same), so in the URI case, we should have at most two matches. However, @XingY added the uriOrName argument afterward, and we have no constraint on (name, container).
Spinning the list and looking for the first one that's not in /Shared, and then falling back on the first entry sounds like the right approach.
There was a problem hiding this comment.
Got it... I was thinking "project" meant shared project not the other project. I can stick a fix in my other open platform PR. Unless you're dying to commit this fix.
Rationale
https://github.com/LabKey/kanban/issues/1577
Several inconsistencies in the migration code were uncovered when migrating TNPRC's SQL Server database to PostgreSQL:
issues.Issuesrows are presentChanges
GuidMapperColumninto API. Use it to lowercase linked schema GUIDs that are stored in theExternalSchema.DataSourcecolumn.DbSchemaType.MigrationALTER TABLE foo CHECK CONSTRAINT bar)