Skip to content

Conversation

@grantfitzsimmons
Copy link
Member

@grantfitzsimmons grantfitzsimmons commented Feb 8, 2026

Fixes #7564 and starts to fix #7426

Adds a tool to create new schema config records for tables and fields present in the data model that do not have schema records.

This still needs to be invoked in a migration (or ideally when we run the 'self-heal' function)...

  • Added new command sync_schema_config_fields.py to identify (and create if) missing schema config tables and fields for a given discipline. Can be run in verbose mode to see every addition, and can identify without immediately adding.
  • Introduced utility functions find_missing_schema_config_fields and create_missing_schema_config_fields in update_schema_config.py to support the management command and allow programmatic access to these operations.

It should look something like this (plus many {table}Id fields):

Discipline: Vertebrate Zoology (id=3)

Missing containers:
- DNASequencingRunAttachment
- LocalityUpdate
- LocalityUpdateRowResult

Missing fields:
- Attachment: spDataSetAttachments
- CollectionObject: collectionObjectType
- DNASequencingRunAttachment: ordinal, remarks, timestampCreated, timestampModified, version, attachment, createdByAgent, dnaSequencingRun, modifiedByAgent
- Discipline: tectonicUnitTreeDef
- Locality: collectingEvents
- LocalityUpdate: status, timestampcreated, timestampmodified, recordset, collection, specifyuser, createdbyagent, modifiedbyagent
- LocalityUpdateRowResult: rownumber, result, localityupdate
- SpQueryField: isStrict

Checklist

  • Self-review the PR after opening it to make sure the changes look good and
    self-explanatory (or properly documented)
  • Add relevant issue to release milestone
  • Add pr to documentation list
  • Add automated tests
  • Add a reverse migration if a migration is present in the PR

Testing instructions

  • Identify the discipline ID for any discipline in a database
  • Inside the container, run the following, replacing 13 with the ID of the discipline you wish to test this on
    • See all missing tables and fields:
     ve/bin/python manage.py sync_schema_config_fields --discipline-id 13
    
    • Create all missing table and field records for the schema config:
     ve/bin/python manage.py sync_schema_config_fields --discipline-id 13 --apply
    
    • Create all missing table and field records for the schema config with logging for each addition:
     ve/bin/python manage.py sync_schema_config_fields --discipline-id 13 --apply --verbose
    

Fixes #7564 and starts to fix #7426

Adds a tool to create new schema config records for tables and fields present in the data model that do not have schema records.
Triggered by 38a8223 on branch refs/heads/issue-7564
@grantfitzsimmons
Copy link
Member Author

@acwhite211 Your thoughts on this would be appreciated!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: 📋Back Log

Development

Successfully merging this pull request may close these issues.

Some tables do not have Schema Config records, making them unhideable

1 participant