Create a migration to fix tree structure issues due to an old WorkBench bug #5131
Labels
1 - Enhancement
Improvements or extensions to existing behavior
2 - Database/Schema
Issues that are related to the underlying database and schema
Milestone
Is your feature request related to a problem? Please describe.
Since the release of the WorkBench (v7.6.1) until sometime around the release of Specify v7.9.0, taxon records uploaded via the WorkBench did not have
isAccepted
as true by default.This results in a "Bad tree structure" error, preventing children from being added to any node (or any descendent of any node) that has
IsAccepted
as false yet still is not a synonym.The underlying issue is not apparent to the user nor to some troubleshooting this.
Describe the solution you'd like
We should automatically fix all such cases.
You can return erroneous not accepted Taxon records here:
This SQL query performs the following operations:
SELECT t1.TaxonID
: This part of the query selects theTaxonID
column from thetaxon
table, which is aliased ast1
.FROM taxon t1
: This part of the query specifies thetaxon
table as the primary table, and assigns the aliast1
to it.LEFT JOIN taxon t2 ON t1.AcceptedID = t2.TaxonID
: This part of the query performs a left join between thetaxon
table (aliased ast1
) and thetaxon
table (aliased ast2
). The join condition is that theAcceptedID
column int1
must match theTaxonID
column int2
.WHERE t1.IsAccepted = 0 AND t2.TaxonID IS NULL
: This part of the query applies a filter to the result set. It selects only the rows where:t1.IsAccepted
is 0 (i.e., the taxon is not accepted)t2.TaxonID
isNULL
(i.e., there is no matching accepted taxon in thet2
table)This essentially retrieves the
TaxonID
values for all taxa that are not accepted, and for which there is no corresponding accepted taxon in the database. This should only include problem taxa.To fix cases like this, we can simply run:
but it seems like a good candidate for a migration so that this is handled on all databases once since the issue is most likely widespread and present on self-hosted institution databases as well.
The text was updated successfully, but these errors were encountered: