diff --git a/specifyweb/backend/stored_queries/format.py b/specifyweb/backend/stored_queries/format.py index c3998084018..768d499f7de 100644 --- a/specifyweb/backend/stored_queries/format.py +++ b/specifyweb/backend/stored_queries/format.py @@ -89,16 +89,29 @@ def lookup_name(name: str) -> Element | None: return None def getFormatterFromSchema() -> Element: - - try: - formatter_name = Splocalecontainer.objects.get( - name=specify_model.name.lower(), - schematype=0, - discipline=self.collection.discipline - ).format - except Splocalecontainer.DoesNotExist: + containers = Splocalecontainer.objects.filter( + name=specify_model.name.lower(), + schematype=0, + discipline=self.collection.discipline, + ).order_by('-timestampmodified', '-id') + container_count = containers.count() + if container_count == 0: return None + formatter_name = ( + containers.exclude(format__isnull=True) + .exclude(format='') + .values_list('format', flat=True) + .first() + ) + if container_count > 1: + logger.warning( + "Multiple Splocalecontainer rows found for %s in discipline %s using formatter %r", + specify_model.name.lower(), + self.collection.discipline_id, + formatter_name, + ) + if formatter_name: return lookup_name(formatter_name) else: diff --git a/specifyweb/backend/trees/tests/test_trees.py b/specifyweb/backend/trees/tests/test_trees.py index a3acd477518..2c6628d068f 100644 --- a/specifyweb/backend/trees/tests/test_trees.py +++ b/specifyweb/backend/trees/tests/test_trees.py @@ -455,6 +455,77 @@ def _run_for_row(): ] self.assertCountEqual(results, expected) + def test_taxon_rows_include_author_and_synonyms(self): + root = self.make_taxontree( + "Life", + "Taxonomy Root", + definition=self.taxontreedef, + ) + animalia = self.make_taxontree( + "Animalia", + "Kingdom", + definition=self.taxontreedef, + parent=root, + author="L.", + ) + metazoa = self.make_taxontree( + "Metazoa", + "Kingdom", + definition=self.taxontreedef, + parent=root, + acceptedtaxon=animalia, + fullname="Metazoa", + author="Haeckel", + ) + animalia.refresh_from_db() + metazoa.refresh_from_db() + + @contextmanager + def _run_for_row(): + with TreeViewsTest.test_session_context() as session: + set_group_concat_max_len(connection.cursor()) + yield session + + with _run_for_row() as session: + results = get_tree_rows( + self.taxontreedef.id, + "Taxon", + root.id, + "name", + True, + session, + ) + expected = [ + ( + animalia.id, + animalia.name, + animalia.fullname, + animalia.nodenumber, + animalia.highestchildnodenumber, + animalia.rankid, + None, + None, + animalia.author, + 0, + metazoa.fullname, + ), + ( + metazoa.id, + metazoa.name, + metazoa.fullname, + metazoa.nodenumber, + metazoa.highestchildnodenumber, + metazoa.rankid, + animalia.id, + animalia.fullname, + metazoa.author, + 0, + None, + ), + ] + + self.assertCountEqual(results, expected) + class AddDeleteRankResourcesTest(ApiTests): def test_add_ranks_without_defaults(self): diff --git a/specifyweb/backend/trees/views.py b/specifyweb/backend/trees/views.py index bd04ec2522f..a207cfc1e76 100644 --- a/specifyweb/backend/trees/views.py +++ b/specifyweb/backend/trees/views.py @@ -182,44 +182,45 @@ def get_tree_rows(treedef, tree, parentid, sortfield, include_author, session): treedef_col = getattr(node, tree_table.name + "TreeDefID") orderby = getattr(node, tree_table.get_field_strict(sortfield).name) + child_counts = ( + select( + child.ParentID.label("parent_id"), + func.count(child._id).label("child_count"), + ) + .group_by(child.ParentID) + .subquery() + ) + synonym_names = ( + select( + synonym.AcceptedID.label("accepted_id"), + group_concat(distinct(synonym.fullName), separator=", ").label("synonyms"), + ) + .where(synonym.AcceptedID.is_not(None)) + .group_by(synonym.AcceptedID) + .subquery() + ) - # We use min for grouped columns because for some reason, SQL is rejecting - # the group_by in some dbs due to "only_full_group_by". It is somehow not - # smart enough to see that there is no dependency in the columns going from - # main table to the to-manys (child, and syns). - # I want to use ANY_VALUE() but that's not supported by MySQL 5.6- and MariaDB. - # I don't want to disable "only_full_group_by" in case someone misuses it... - # applying min to fool into thinking it is aggregated. - # these values are guarenteed to be the same cols = [ node._id.label("id"), - func.min(node.name).label("name"), - func.min(node.fullName).label("full_name"), - func.min(node.nodeNumber).label("node_number"), - func.min(node.highestChildNodeNumber).label("highest_child_number"), - func.min(node.rankId).label("rank_id"), - - func.min(node.AcceptedID).label("accepted_id"), - func.min(accepted.fullName).label("accepted_fullname"), - - ( - func.min(node.author) - if include_author - else func.min(literal("NULL")) - ).label("author"), - - func.count(distinct(child._id)).label("child_count"), - group_concat(distinct(synonym.fullName), separator=", ").label("synonyms"), + node.name.label("name"), + node.fullName.label("full_name"), + node.nodeNumber.label("node_number"), + node.highestChildNodeNumber.label("highest_child_number"), + node.rankId.label("rank_id"), + node.AcceptedID.label("accepted_id"), + accepted.fullName.label("accepted_fullname"), + (node.author if include_author else literal("NULL")).label("author"), + func.coalesce(child_counts.c.child_count, 0).label("child_count"), + synonym_names.c.synonyms.label("synonyms"), ] query = ( select(*cols) - .outerjoin(child, child.ParentID == node._id) .outerjoin(accepted, node.AcceptedID == accepted._id) - .outerjoin(synonym, synonym.AcceptedID == node._id) + .outerjoin(child_counts, child_counts.c.parent_id == node._id) + .outerjoin(synonym_names, synonym_names.c.accepted_id == node._id) .where(treedef_col == int(treedef)) .where(node.ParentID == parentid) - .group_by(node._id) .order_by(orderby) ) diff --git a/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx b/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx index 26f4696c407..790b3373284 100644 --- a/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx +++ b/specifyweb/frontend/js_src/lib/components/Notifications/NotificationRenderers.tsx @@ -395,9 +395,7 @@ export const notificationRenderers: IR< ); }, 'collection-creation-starting'() { - return ( -

{setupToolText.collectionCreationStarted()}

- ); + return

{setupToolText.collectionCreationStarted()}

; }, default(notification) { console.error('Unknown notification type', { notification }); diff --git a/specifyweb/specify/migrations/0045_add_indexes.py b/specifyweb/specify/migrations/0045_add_indexes.py new file mode 100644 index 00000000000..43715ed0b40 --- /dev/null +++ b/specifyweb/specify/migrations/0045_add_indexes.py @@ -0,0 +1,669 @@ +# -*- coding: utf-8 -*- +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('specify', '0044_alter_deletion_cascade'), + ] + + operations = [ + # Agentidentifier + migrations.AddIndex( + model_name='agentidentifier', + index=models.Index( + fields=['identifier'], + name='agentidentifier_identifier_idx', + ), + ), + migrations.AddIndex( + model_name='agentidentifier', + index=models.Index( + fields=['identifiertype'], + name='agid_identifiertype_idx', + ), + ), + + # Agentspecialty + migrations.AddIndex( + model_name='agentspecialty', + index=models.Index( + fields=['ordernumber'], + name='agentspecialty_ordernumber_idx', + ), + ), + migrations.AddIndex( + model_name='agentspecialty', + index=models.Index( + fields=['specialtyname'], + name='agsp_specialtyname_idx', + ), + ), + + # Agentvariant + migrations.AddIndex( + model_name='agentvariant', + index=models.Index( + fields=['name'], + name='agentvariant_name_idx', + ), + ), + + # Attachmentmetadata + migrations.AddIndex( + model_name='attachmentmetadata', + index=models.Index( + fields=['name'], + name='attachmentmetadata_name_idx', + ), + ), + + # Author + migrations.AddIndex( + model_name='author', + index=models.Index( + fields=['ordernumber'], + name='author_ordernumber_idx', + ), + ), + + # Collectionobject + migrations.AddIndex( + model_name='collectionobject', + index=models.Index( + fields=['name'], + name='collectionobject_name_idx', + ), + ), + migrations.AddIndex( + model_name='collectionobject', + index=models.Index( + fields=['projectnumber'], + name='colobj_projectnumber_idx', + ), + ), + + # Collectionobjectproperty + migrations.AddIndex( + model_name='collectionobjectproperty', + index=models.Index( + fields=['guid'], + name='collectionobjectprop_guid_idx', + ), + ), + + # Collectionreltype + migrations.AddIndex( + model_name='collectionreltype', + index=models.Index( + fields=['name'], + name='collectionreltype_name_idx', + ), + ), + + # Exchangein + migrations.AddIndex( + model_name='exchangein', + index=models.Index( + fields=['exchangeinnumber'], + name='exchin_exchinnum_idx', + ), + ), + + # Exsiccataitem + migrations.AddIndex( + model_name='exsiccataitem', + index=models.Index( + fields=['number'], + name='exsiccataitem_number_idx', + ), + ), + + # Geography + migrations.AddIndex( + model_name='geography', + index=models.Index( + fields=['commonname'], + name='geography_commonname_idx', + ), + ), + migrations.AddIndex( + model_name='geography', + index=models.Index( + fields=['guid'], + name='geography_guid_idx', + ), + ), + migrations.AddIndex( + model_name='geography', + index=models.Index( + fields=['highestchildnodenumber'], + name='geography_hchnodenum_idx', + ), + ), + migrations.AddIndex( + model_name='geography', + index=models.Index( + fields=['nodenumber'], + name='geography_nodenumber_idx', + ), + ), + + # Geographytreedef + migrations.AddIndex( + model_name='geographytreedef', + index=models.Index( + fields=['name'], + name='geographytreedef_name_idx', + ), + ), + + # Geographytreedefitem + migrations.AddIndex( + model_name='geographytreedefitem', + index=models.Index( + fields=['name'], + name='geogtreedefitem_name_idx', + ), + ), + + # Geologictimeperiod + migrations.AddIndex( + model_name='geologictimeperiod', + index=models.Index( + fields=['highestchildnodenumber'], + name='geotime_highchildnodenumb_idx', + ), + ), + migrations.AddIndex( + model_name='geologictimeperiod', + index=models.Index( + fields=['nodenumber'], + name='geotime_nodenumber_idx', + ), + ), + + # Geologictimeperiodtreedef + migrations.AddIndex( + model_name='geologictimeperiodtreedef', + index=models.Index( + fields=['name'], + name='geotimetreedef_name_idx', + ), + ), + + # Geologictimeperiodtreedefitem + migrations.AddIndex( + model_name='geologictimeperiodtreedefitem', + index=models.Index( + fields=['name'], + name='geotimetreedefitem_name_idx', + ), + ), + + # Institutionnetwork + migrations.AddIndex( + model_name='institutionnetwork', + index=models.Index( + fields=['altname'], + name='institutionnetwork_altname_idx', + ), + ), + + # Latlonpolygon + migrations.AddIndex( + model_name='latlonpolygon', + index=models.Index( + fields=['name'], + name='latlonpolygon_name_idx', + ), + ), + + # Lithostrat + migrations.AddIndex( + model_name='lithostrat', + index=models.Index( + fields=['highestchildnodenumber'], + name='lithostrat_hchnode_idx', + ), + ), + migrations.AddIndex( + model_name='lithostrat', + index=models.Index( + fields=['nodenumber'], + name='lithostrat_nodenumber_idx', + ), + ), + + # Lithostrattreedef + migrations.AddIndex( + model_name='lithostrattreedef', + index=models.Index( + fields=['name'], + name='lithostratdef_name_idx', + ), + ), + + # Lithostrattreedefitem + migrations.AddIndex( + model_name='lithostrattreedefitem', + index=models.Index( + fields=['name'], + name='lithostratdefitem_name_idx', + ), + ), + + # Locality + migrations.AddIndex( + model_name='locality', + index=models.Index( + fields=['guid'], + name='locality_guid_idx', + ), + ), + + # Materialsample + migrations.AddIndex( + model_name='materialsample', + index=models.Index( + fields=['guid'], + name='materialsample_guid_idx', + ), + ), + + # Morphbankview + migrations.AddIndex( + model_name='morphbankview', + index=models.Index( + fields=['viewname'], + name='morphbankview_viewname_idx', + ), + ), + + # Otheridentifier + migrations.AddIndex( + model_name='otheridentifier', + index=models.Index( + fields=['identifier'], + name='otheridentifier_identifier_idx', + ), + ), + + # Picklist + migrations.AddIndex( + model_name='picklist', + index=models.Index( + fields=['fieldname'], + name='picklist_fieldname_idx', + ), + ), + migrations.AddIndex( + model_name='picklist', + index=models.Index( + fields=['filterfieldname'], + name='picklist_filterfieldname_idx', + ), + ), + migrations.AddIndex( + model_name='picklist', + index=models.Index( + fields=['tablename'], + name='picklist_tablename_idx', + ), + ), + + # Preptype + migrations.AddIndex( + model_name='preptype', + index=models.Index( + fields=['name'], + name='preptype_name_idx', + ), + ), + + # Preparationproperty + migrations.AddIndex( + model_name='preparationproperty', + index=models.Index( + fields=['guid'], + name='preparationprop_guid_idx', + ), + ), + + # Referencework + migrations.AddIndex( + model_name='referencework', + index=models.Index( + fields=['librarynumber'], + name='refwork_librarynum_idx', + ), + ), + + # Spauditlogfield + migrations.AddIndex( + model_name='spauditlogfield', + index=models.Index( + fields=['fieldname'], + name='spauditlogfield_fieldname_idx', + ), + ), + + # Spexportschema + migrations.AddIndex( + model_name='spexportschema', + index=models.Index( + fields=['schemaname'], + name='spexportschema_schemaname_idx', + ), + ), + + # Spexportschemaitem + migrations.AddIndex( + model_name='spexportschemaitem', + index=models.Index( + fields=['fieldname'], + name='spexpschemaitem_fieldname_idx', + ), + ), + + # Spexportschemaitemmapping + migrations.AddIndex( + model_name='spexportschemaitemmapping', + index=models.Index( + fields=['exportedfieldname'], + name='spexpitemmap_expfld_idx', + ), + ), + + # Spexportschemamapping + migrations.AddIndex( + model_name='spexportschemamapping', + index=models.Index( + fields=['mappingname'], + name='spexpschemamap_mappingname_idx', + ), + ), + + # Spfieldvaluedefault + migrations.AddIndex( + model_name='spfieldvaluedefault', + index=models.Index( + fields=['fieldname'], + name='spfieldvaluedef_fieldname_idx', + ), + ), + migrations.AddIndex( + model_name='spfieldvaluedefault', + index=models.Index( + fields=['tablename'], + name='spfieldvaluedef_tablename_idx', + ), + ), + + # Splocalecontainer + migrations.AddIndex( + model_name='splocalecontainer', + index=models.Index( + fields=['picklistname'], + name='splocalecont_picklistname_idx', + ), + ), + + # Splocalecontaineritem + migrations.AddIndex( + model_name='splocalecontaineritem', + index=models.Index( + fields=['picklistname'], + name='splocalecontitem_picklist_idx', + ), + ), + migrations.AddIndex( + model_name='splocalecontaineritem', + index=models.Index( + fields=['weblinkname'], + name='splocalecontitem_weblink_idx', + ), + ), + + # Sppermission + migrations.AddIndex( + model_name='sppermission', + index=models.Index( + fields=['name'], + name='sppermission_name_idx', + ), + ), + + # Spprincipal + migrations.AddIndex( + model_name='spprincipal', + index=models.Index( + fields=['name'], + name='spprincipal_name_idx', + ), + ), + + # Spquery + migrations.AddIndex( + model_name='spquery', + index=models.Index( + fields=['contextname'], + name='spquery_contextname_idx', + ), + ), + + # Spqueryfield + migrations.AddIndex( + model_name='spqueryfield', + index=models.Index( + fields=['fieldname'], + name='spqueryfield_fieldname_idx', + ), + ), + migrations.AddIndex( + model_name='spqueryfield', + index=models.Index( + fields=['formatname'], + name='spqueryfield_formatname_idx', + ), + ), + + # Spviewsetobj + migrations.AddIndex( + model_name='spviewsetobj', + index=models.Index( + fields=['filename'], + name='spviewsetobj_filename_idx', + ), + ), + + # Specifyuser + migrations.AddIndex( + model_name='specifyuser', + index=models.Index( + fields=['name'], + name='specifyuser_name_idx', + ), + ), + + # Storage + migrations.AddIndex( + model_name='storage', + index=models.Index( + fields=['highestchildnodenumber'], + name='storage_highchildnodenumb_idx', + ), + ), + migrations.AddIndex( + model_name='storage', + index=models.Index( + fields=['nodenumber'], + name='storage_nodenumber_idx', + ), + ), + + # Storagetreedef + migrations.AddIndex( + model_name='storagetreedef', + index=models.Index( + fields=['name'], + name='storagetreedef_name_idx', + ), + ), + + # Storagetreedefitem + migrations.AddIndex( + model_name='storagetreedefitem', + index=models.Index( + fields=['name'], + name='storagetreedefitem_name_idx', + ), + ), + + # Taxon + migrations.AddIndex( + model_name='taxon', + index=models.Index( + fields=['cultivarname'], + name='taxon_cultivarname_idx', + ), + ), + migrations.AddIndex( + model_name='taxon', + index=models.Index( + fields=['groupnumber'], + name='taxon_groupnumber_idx', + ), + ), + migrations.AddIndex( + model_name='taxon', + index=models.Index( + fields=['highestchildnodenumber'], + name='taxon_highchildnodenumb_idx', + ), + ), + migrations.AddIndex( + model_name='taxon', + index=models.Index( + fields=['nodenumber'], + name='taxon_nodenumber_idx', + ), + ), + + # Taxontreedef + migrations.AddIndex( + model_name='taxontreedef', + index=models.Index( + fields=['name'], + name='taxontreedef_name_idx', + ), + ), + + # Taxontreedefitem + migrations.AddIndex( + model_name='taxontreedefitem', + index=models.Index( + fields=['name'], + name='taxontreedefitem_name_idx', + ), + ), + + # Voucherrelationship + migrations.AddIndex( + model_name='voucherrelationship', + index=models.Index( + fields=['vouchernumber'], + name='voucherrel_vouchernumber_idx', + ), + ), + + # Collectionobjecttype + migrations.AddIndex( + model_name='collectionobjecttype', + index=models.Index( + fields=['name'], + name='collectionobjecttype_name_idx', + ), + ), + + # Collectionobjectgrouptype + migrations.AddIndex( + model_name='collectionobjectgrouptype', + index=models.Index( + fields=['name'], + name='colobjgrouptype_name_idx', + ), + ), + + # Collectionobjectgroup + migrations.AddIndex( + model_name='collectionobjectgroup', + index=models.Index( + fields=['guid'], + name='collectionobjectgroup_guid_idx', + ), + ), + migrations.AddIndex( + model_name='collectionobjectgroup', + index=models.Index( + fields=['name'], + name='collectionobjectgroup_name_idx', + ), + ), + + # Tectonicunittreedef + migrations.AddIndex( + model_name='tectonicunittreedef', + index=models.Index( + fields=['name'], + name='tectunitdef_name_idx', + ), + ), + + # Tectonicunittreedefitem + migrations.AddIndex( + model_name='tectonicunittreedefitem', + index=models.Index( + fields=['name'], + name='tectunitdefitem_name_idx', + ), + ), + + # Tectonicunit + migrations.AddIndex( + model_name='tectonicunit', + index=models.Index( + fields=['fullname'], + name='tectonicunit_fullname_idx', + ), + ), + migrations.AddIndex( + model_name='tectonicunit', + index=models.Index( + fields=['guid'], + name='tectonicunit_guid_idx', + ), + ), + migrations.AddIndex( + model_name='tectonicunit', + index=models.Index( + fields=['highestchildnodenumber'], + name='tectonicunit_highchildnumb_idx', + ), + ), + migrations.AddIndex( + model_name='tectonicunit', + index=models.Index( + fields=['name'], + name='tectonicunit_name_idx', + ), + ), + migrations.AddIndex( + model_name='tectonicunit', + index=models.Index( + fields=['nodenumber'], + name='tectonicunit_nodenumber_idx', + ), + ), + ] diff --git a/specifyweb/specify/models.py b/specifyweb/specify/models.py index d8562fd1c60..3560232bb95 100644 --- a/specifyweb/specify/models.py +++ b/specifyweb/specify/models.py @@ -431,6 +431,10 @@ class Agentidentifier(models.Model): class Meta: db_table = 'agentidentifier' ordering = () + indexes = [ + models.Index(fields=['identifier'], name='agentidentifier_identifier_idx'), + models.Index(fields=['identifiertype'], name='agid_identifiertype_idx'), + ] save = partialmethod(custom_save) @@ -457,6 +461,10 @@ class Meta: db_table = 'agentspecialty' ordering = () unique_together = (('agent', 'ordernumber'),) + indexes = [ + models.Index(fields=['ordernumber'], name='agentspecialty_ordernumber_idx'), + models.Index(fields=['specialtyname'], name='agsp_specialtyname_idx'), + ] save = partialmethod(custom_save) @@ -485,6 +493,9 @@ class Agentvariant(models.Model): class Meta: db_table = 'agentvariant' ordering = () + indexes = [ + models.Index(fields=['name'], name='agentvariant_name_idx'), + ] save = partialmethod(custom_save) @@ -572,7 +583,7 @@ class Meta: models.Index(fields=['dateimaged'], name='DateImagedIDX'), models.Index(fields=['scopeid'], name='AttchScopeIDIDX'), models.Index(fields=['scopetype'], name='AttchScopeTypeIDX'), - models.Index(fields=['guid'], name='AttchmentGuidIDX') + models.Index(fields=['guid'], name='AttchmentGuidIDX'), ] @@ -639,6 +650,9 @@ class Attachmentmetadata(models.Model): class Meta: db_table = 'attachmentmetadata' ordering = () + indexes = [ + models.Index(fields=['name'], name='attachmentmetadata_name_idx'), + ] save = partialmethod(custom_save) @@ -717,6 +731,9 @@ class Meta: db_table = 'author' ordering = ('ordernumber',) unique_together = (('referencework', 'agent'),) + indexes = [ + models.Index(fields=['ordernumber'], name='author_ordernumber_idx'), + ] save = partialmethod(custom_save) @@ -1510,7 +1527,9 @@ class Meta: models.Index(fields=['uniqueidentifier'], name='COUniqueIdentifierIDX'), models.Index(fields=['altcatalognumber'], name='AltCatalogNumberIDX'), models.Index(fields=['guid'], name='ColObjGuidIDX'), - models.Index(fields=['collectionmemberid'], name='COColMemIDX') + models.Index(fields=['collectionmemberid'], name='COColMemIDX'), + models.Index(fields=['name'], name='collectionobject_name_idx'), + models.Index(fields=['projectnumber'], name='colobj_projectnumber_idx'), ] @@ -1941,7 +1960,8 @@ class Meta: db_table = 'collectionobjectproperty' ordering = () indexes = [ - models.Index(fields=['collectionmemberid'], name='COLOBJPROPColMemIDX') + models.Index(fields=['collectionmemberid'], name='COLOBJPROPColMemIDX'), + models.Index(fields=['guid'], name='collectionobjectprop_guid_idx'), ] @@ -1969,6 +1989,9 @@ class Collectionreltype(models.Model): class Meta: db_table = 'collectionreltype' ordering = () + indexes = [ + models.Index(fields=['name'], name='collectionreltype_name_idx'), + ] save = partialmethod(custom_save) @@ -3116,7 +3139,8 @@ class Meta: ordering = () indexes = [ models.Index(fields=['exchangedate'], name='ExchangeDateIDX'), - models.Index(fields=['descriptionofmaterial'], name='DescriptionOfMaterialIDX') + models.Index(fields=['descriptionofmaterial'], name='DescriptionOfMaterialIDX'), + models.Index(fields=['exchangeinnumber'], name='exchin_exchinnum_idx'), ] @@ -3336,6 +3360,9 @@ class Exsiccataitem(models.Model): class Meta: db_table = 'exsiccataitem' ordering = () + indexes = [ + models.Index(fields=['number'], name='exsiccataitem_number_idx'), + ] save = partialmethod(custom_save) @@ -3688,7 +3715,11 @@ class Meta: ordering = () indexes = [ models.Index(fields=['name'], name='GeoNameIDX'), - models.Index(fields=['fullname'], name='GeoFullNameIDX') + models.Index(fields=['fullname'], name='GeoFullNameIDX'), + models.Index(fields=['commonname'], name='geography_commonname_idx'), + models.Index(fields=['guid'], name='geography_guid_idx'), + models.Index(fields=['highestchildnodenumber'], name='geography_hchnodenum_idx'), + models.Index(fields=['nodenumber'], name='geography_nodenumber_idx'), ] @@ -3716,6 +3747,9 @@ class Geographytreedef(models.Model): class Meta: db_table = 'geographytreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='geographytreedef_name_idx'), + ] save = partialmethod(custom_save) @@ -3749,6 +3783,9 @@ class Geographytreedefitem(model_extras.Geographytreedefitem): class Meta: db_table = 'geographytreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='geogtreedefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -3794,7 +3831,9 @@ class Meta: indexes = [ models.Index(fields=['name'], name='GTPNameIDX'), models.Index(fields=['fullname'], name='GTPFullNameIDX'), - models.Index(fields=['guid'], name='GTPGuidIDX') + models.Index(fields=['guid'], name='GTPGuidIDX'), + models.Index(fields=['highestchildnodenumber'], name='geotime_highchildnodenumb_idx'), + models.Index(fields=['nodenumber'], name='geotime_nodenumber_idx'), ] @@ -3822,6 +3861,9 @@ class Geologictimeperiodtreedef(models.Model): class Meta: db_table = 'geologictimeperiodtreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='geotimetreedef_name_idx'), + ] save = partialmethod(custom_save) @@ -3855,6 +3897,9 @@ class Geologictimeperiodtreedefitem(model_extras.Geologictimeperiodtreedefitem): class Meta: db_table = 'geologictimeperiodtreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='geotimetreedefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -4167,7 +4212,8 @@ class Meta: db_table = 'institutionnetwork' ordering = () indexes = [ - models.Index(fields=['name'], name='InstNetworkNameIDX') + models.Index(fields=['name'], name='InstNetworkNameIDX'), + models.Index(fields=['altname'], name='institutionnetwork_altname_idx'), ] @@ -4229,6 +4275,9 @@ class Latlonpolygon(models.Model): class Meta: db_table = 'latlonpolygon' ordering = () + indexes = [ + models.Index(fields=['name'], name='latlonpolygon_name_idx'), + ] save = partialmethod(custom_save) @@ -4293,7 +4342,9 @@ class Meta: indexes = [ models.Index(fields=['name'], name='LithoNameIDX'), models.Index(fields=['fullname'], name='LithoFullNameIDX'), - models.Index(fields=['guid'], name='LithoGuidIDX') + models.Index(fields=['guid'], name='LithoGuidIDX'), + models.Index(fields=['highestchildnodenumber'], name='lithostrat_hchnode_idx'), + models.Index(fields=['nodenumber'], name='lithostrat_nodenumber_idx'), ] @@ -4321,6 +4372,9 @@ class Lithostrattreedef(models.Model): class Meta: db_table = 'lithostrattreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='lithostratdef_name_idx'), + ] save = partialmethod(custom_save) @@ -4354,6 +4408,9 @@ class Lithostrattreedefitem(model_extras.Lithostrattreedefitem): class Meta: db_table = 'lithostrattreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='lithostratdefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -4623,7 +4680,8 @@ class Meta: models.Index(fields=['discipline'], name='LocalityDisciplineIDX'), models.Index(fields=['namedplace'], name='NamedPlaceIDX'), models.Index(fields=['uniqueidentifier'], name='LocalityUniqueIdentifierIDX'), - models.Index(fields=['relationtonamedplace'], name='RelationToNamedPlaceIDX') + models.Index(fields=['relationtonamedplace'], name='RelationToNamedPlaceIDX'), + models.Index(fields=['guid'], name='locality_guid_idx'), ] @@ -4849,7 +4907,8 @@ class Meta: db_table = 'materialsample' ordering = () indexes = [ - models.Index(fields=['ggbn_sampledesignation'], name='DesignationIDX') + models.Index(fields=['ggbn_sampledesignation'], name='DesignationIDX'), + models.Index(fields=['guid'], name='materialsample_guid_idx'), ] @@ -4882,6 +4941,9 @@ class Morphbankview(models.Model): class Meta: db_table = 'morphbankview' ordering = () + indexes = [ + models.Index(fields=['viewname'], name='morphbankview_viewname_idx'), + ] save = partialmethod(custom_save) @@ -4925,6 +4987,9 @@ class Otheridentifier(models.Model): class Meta: db_table = 'otheridentifier' ordering = () + indexes = [ + models.Index(fields=['identifier'], name='otheridentifier_identifier_idx'), + ] indexes = [ models.Index(fields=['collectionmemberid'], name='OthIdColMemIDX') ] @@ -5121,7 +5186,10 @@ class Meta: db_table = 'picklist' ordering = () indexes = [ - models.Index(fields=['name'], name='PickListNameIDX') + models.Index(fields=['name'], name='PickListNameIDX'), + models.Index(fields=['fieldname'], name='picklist_fieldname_idx'), + models.Index(fields=['filterfieldname'], name='picklist_filterfieldname_idx'), + models.Index(fields=['tablename'], name='picklist_tablename_idx'), ] @@ -5174,6 +5242,9 @@ class Preptype(models.Model): class Meta: db_table = 'preptype' ordering = () + indexes = [ + models.Index(fields=['name'], name='preptype_name_idx'), + ] save = partialmethod(custom_save) @@ -5565,7 +5636,8 @@ class Meta: db_table = 'preparationproperty' ordering = () indexes = [ - models.Index(fields=['collectionmemberid'], name='PREPPROPColMemIDX') + models.Index(fields=['collectionmemberid'], name='PREPPROPColMemIDX'), + models.Index(fields=['guid'], name='preparationprop_guid_idx'), ] @@ -5723,7 +5795,8 @@ class Meta: models.Index(fields=['title'], name='RefWrkTitleIDX'), models.Index(fields=['publisher'], name='RefWrkPublisherIDX'), models.Index(fields=['guid'], name='RefWrkGuidIDX'), - models.Index(fields=['isbn'], name='ISBNIDX') + models.Index(fields=['isbn'], name='ISBNIDX'), + models.Index(fields=['librarynumber'], name='refwork_librarynum_idx'), ] @@ -6047,6 +6120,9 @@ class Spauditlogfield(models.Model): class Meta: db_table = 'spauditlogfield' ordering = () + indexes = [ + models.Index(fields=['fieldname'], name='spauditlogfield_fieldname_idx'), + ] save = partialmethod(custom_save) @@ -6081,6 +6157,9 @@ class Spexportschema(models.Model): class Meta: db_table = 'spexportschema' ordering = () + indexes = [ + models.Index(fields=['schemaname'], name='spexportschema_schemaname_idx'), + ] save = partialmethod(custom_save) @@ -6109,6 +6188,9 @@ class Spexportschemaitem(models.Model): class Meta: db_table = 'spexportschemaitem' ordering = () + indexes = [ + models.Index(fields=['fieldname'], name='spexpschemaitem_fieldname_idx'), + ] save = partialmethod(custom_save) @@ -6138,6 +6220,9 @@ class Spexportschemaitemmapping(models.Model): class Meta: db_table = 'spexportschemaitemmapping' ordering = () + indexes = [ + models.Index(fields=['exportedfieldname'], name='spexpitemmap_expfld_idx'), + ] save = partialmethod(custom_save) @@ -6165,7 +6250,8 @@ class Meta: db_table = 'spexportschemamapping' ordering = () indexes = [ - models.Index(fields=['collectionmemberid'], name='SPEXPSCHMMAPColMemIDX') + models.Index(fields=['collectionmemberid'], name='SPEXPSCHMMAPColMemIDX'), + models.Index(fields=['mappingname'], name='spexpschemamap_mappingname_idx'), ] @@ -6195,7 +6281,9 @@ class Meta: db_table = 'spfieldvaluedefault' ordering = () indexes = [ - models.Index(fields=['collectionmemberid'], name='SpFieldValueDefaultColMemIDX') + models.Index(fields=['collectionmemberid'], name='SpFieldValueDefaultColMemIDX'), + models.Index(fields=['fieldname'], name='spfieldvaluedef_fieldname_idx'), + models.Index(fields=['tablename'], name='spfieldvaluedef_tablename_idx'), ] @@ -6231,7 +6319,8 @@ class Meta: db_table = 'splocalecontainer' ordering = () indexes = [ - models.Index(fields=['name'], name='SpLocaleContainerNameIDX') + models.Index(fields=['name'], name='SpLocaleContainerNameIDX'), + models.Index(fields=['picklistname'], name='splocalecont_picklistname_idx'), ] @@ -6266,7 +6355,9 @@ class Meta: db_table = 'splocalecontaineritem' ordering = () indexes = [ - models.Index(fields=['name'], name='SpLocaleContainerItemNameIDX') + models.Index(fields=['name'], name='SpLocaleContainerItemNameIDX'), + models.Index(fields=['picklistname'], name='splocalecontitem_picklist_idx'), + models.Index(fields=['weblinkname'], name='splocalecontitem_weblink_idx'), ] @@ -6321,6 +6412,9 @@ class Sppermission(models.Model): class Meta: db_table = 'sppermission' ordering = () + indexes = [ + models.Index(fields=['name'], name='sppermission_name_idx'), + ] save = partialmethod(custom_save) @@ -6356,6 +6450,9 @@ class Spprincipal(models.Model): class Meta: db_table = 'spprincipal' ordering = () + indexes = [ + models.Index(fields=['name'], name='spprincipal_name_idx'), + ] save = partialmethod(custom_save) @@ -6392,7 +6489,8 @@ class Meta: db_table = 'spquery' ordering = () indexes = [ - models.Index(fields=['name'], name='SpQueryNameIDX') + models.Index(fields=['name'], name='SpQueryNameIDX'), + models.Index(fields=['contextname'], name='spquery_contextname_idx'), ] @@ -6436,6 +6534,10 @@ class Spqueryfield(models.Model): class Meta: db_table = 'spqueryfield' ordering = ('position',) + indexes = [ + models.Index(fields=['fieldname'], name='spqueryfield_fieldname_idx'), + models.Index(fields=['formatname'], name='spqueryfield_formatname_idx'), + ] save = partialmethod(custom_save) @@ -6594,7 +6696,8 @@ class Meta: db_table = 'spviewsetobj' ordering = () indexes = [ - models.Index(fields=['name'], name='SpViewObjNameIDX') + models.Index(fields=['name'], name='SpViewObjNameIDX'), + models.Index(fields=['filename'], name='spviewsetobj_filename_idx'), ] @@ -6664,6 +6767,9 @@ class Specifyuser(model_extras.Specifyuser): class Meta: db_table = 'specifyuser' ordering = () + indexes = [ + models.Index(fields=['name'], name='specifyuser_name_idx'), + ] # save = partialmethod(custom_save) @@ -6706,7 +6812,9 @@ class Meta: ordering = () indexes = [ models.Index(fields=['name'], name='StorNameIDX'), - models.Index(fields=['fullname'], name='StorFullNameIDX') + models.Index(fields=['fullname'], name='StorFullNameIDX'), + models.Index(fields=['highestchildnodenumber'], name='storage_highchildnodenumb_idx'), + models.Index(fields=['nodenumber'], name='storage_nodenumber_idx'), ] @@ -6760,6 +6868,9 @@ class Storagetreedef(models.Model): class Meta: db_table = 'storagetreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='storagetreedef_name_idx'), + ] save = partialmethod(custom_save) @@ -6793,6 +6904,9 @@ class Storagetreedefitem(model_extras.Storagetreedefitem): class Meta: db_table = 'storagetreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='storagetreedefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -6911,7 +7025,11 @@ class Meta: models.Index(fields=['commonname'], name='TaxonCommonNameIDX'), models.Index(fields=['name'], name='TaxonNameIDX'), models.Index(fields=['fullname'], name='TaxonFullNameIDX'), - models.Index(fields=['environmentalprotectionstatus'], name='EPSIDX') # Avoid error: The index name 'EnvironmentalProtectionStatusIDX' cannot be longer than 30 characters. + models.Index(fields=['environmentalprotectionstatus'], name='EPSIDX'), # Avoid error: The index name 'EnvironmentalProtectionStatusIDX' cannot be longer than 30 characters. + models.Index(fields=['cultivarname'], name='taxon_cultivarname_idx'), + models.Index(fields=['groupnumber'], name='taxon_groupnumber_idx'), + models.Index(fields=['highestchildnodenumber'], name='taxon_highchildnodenumb_idx'), + models.Index(fields=['nodenumber'], name='taxon_nodenumber_idx'), ] @@ -7188,6 +7306,9 @@ class Taxontreedef(models.Model): class Meta: db_table = 'taxontreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='taxontreedef_name_idx'), + ] save = partialmethod(custom_save) @@ -7222,6 +7343,9 @@ class Taxontreedefitem(model_extras.Taxontreedefitem): class Meta: db_table = 'taxontreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='taxontreedefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -7347,6 +7471,9 @@ class Voucherrelationship(models.Model): class Meta: db_table = 'voucherrelationship' ordering = () + indexes = [ + models.Index(fields=['vouchernumber'], name='voucherrel_vouchernumber_idx'), + ] indexes = [ models.Index(fields=['collectionmemberid'], name='VRXDATColMemIDX') ] @@ -7647,6 +7774,9 @@ class Collectionobjecttype(models.Model): class Meta: db_table = 'collectionobjecttype' ordering = () + indexes = [ + models.Index(fields=['name'], name='collectionobjecttype_name_idx'), + ] save = partialmethod(custom_save) @@ -7671,6 +7801,9 @@ class Collectionobjectgrouptype(models.Model): class Meta: db_table = 'collectionobjectgrouptype' ordering = () + indexes = [ + models.Index(fields=['name'], name='colobjgrouptype_name_idx'), + ] save = partialmethod(custom_save) @@ -7710,6 +7843,10 @@ class Collectionobjectgroup(models.Model): # aka. Cog class Meta: db_table = 'collectionobjectgroup' ordering = () + indexes = [ + models.Index(fields=['guid'], name='collectionobjectgroup_guid_idx'), + models.Index(fields=['name'], name='collectionobjectgroup_name_idx'), + ] save = partialmethod(custom_save) @@ -7968,6 +8105,9 @@ class Tectonicunittreedef(models.Model): class Meta: db_table = 'tectonicunittreedef' ordering = () + indexes = [ + models.Index(fields=['name'], name='tectunitdef_name_idx'), + ] save = partialmethod(custom_save) @@ -8000,6 +8140,9 @@ class Tectonicunittreedefitem(model_extras.Tectonicunittreedefitem): class Meta: db_table = 'tectonicunittreedefitem' ordering = () + indexes = [ + models.Index(fields=['name'], name='tectunitdefitem_name_idx'), + ] save = partialmethod(custom_save) @@ -8039,6 +8182,13 @@ class Tectonicunit(model_extras.Tectonicunit): class Meta: db_table = 'tectonicunit' ordering = () + indexes = [ + models.Index(fields=['fullname'], name='tectonicunit_fullname_idx'), + models.Index(fields=['guid'], name='tectonicunit_guid_idx'), + models.Index(fields=['highestchildnodenumber'], name='tectonicunit_highchildnumb_idx'), + models.Index(fields=['name'], name='tectonicunit_name_idx'), + models.Index(fields=['nodenumber'], name='tectonicunit_nodenumber_idx'), + ] save = partialmethod(custom_save) @@ -8179,4 +8329,4 @@ class Meta: db_table = 'sp_schema_mapping' constraints = [ models.UniqueConstraint(fields=["spexportschema", "spexportschemamapping"], name="exportschema_exportmapping") - ] \ No newline at end of file + ]