-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve schema config migration utils #5475
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lot of nice changes here!
I haven't tested the changes yet, but the code looks good.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tested with a database that has never been used in development (last used on v7.9.6.2
):
specify7-1 | Applying specify.0002_geo... OK
specify7-1 | Applying businessrules.0003_catnum_constraint... OK
specify7-1 | Applying businessrules.0004_catnum_uniquerule... OK
specify7-1 | Applying businessrules.0005_cojo... OK
specify7-1 | Applying specify.0003_cotype_picklist... OK
specify7-1 | Applying specify.0004_stratigraphy_age... OK
specify7-1 | Applying specify.0005_collectionobjectgroup_parentcojo... OK
specify7-1 | Applying specify.0006_fix_tectonic_tree_fields... OK
specify7-1 | Applying specify.0007_schema_config_update... OK
specify7-1 | Applying specify.0008_ageCitations_fix... OK
specify7-1 | Applying specify.0009_tectonic_ranks... OK
specify7-1 | Applying specify.0010_updateDelete_parentcojo... OK
specify7-1 | Applying specify.0011_cascading_tree_nodes... OK
specify7-1 | Applying specify.0012_add_cojo_to_schema_config... OK
specify7-1 | [16/Dec/2024 15:42:21] [WARNING] [specifyweb.specify.migration_utils.update_schema_config:164] Field does not exist in latest state of the datamodel, skipping Schema Config entry for: CollectionObjectGroup -> parentCog
specify7-1 | Applying specify.0013_collectionobjectgroup_parentcog... OK
specify7-1 | Applying specify.0014_spqueryfield_strict... OK
specify7-1 | Applying specify.0015_add_version_to_ages... OK
specify7-1 | Applying specify.0016_collectionobjecttype_catalognumformatname... OK
specify7-1 | Applying specify.0017_schemaconfig_fixes... OK
specify7-1 | Applying specify.0018_cot_catnum_schema... OK
specify7-1 | Applying specify.0019_remove_parentCog... OK
specify7-1 | Watching for file changes with StatReloader
👍
Fixes #5469
get_or_create()
instead ofcreate()
to avoid duplicate Schema Config entries. Ideally, we should no longer need to revert an entry before adding it anymore like here:specify7/specifyweb/specify/migrations/0015_add_version_to_ages.py
Lines 6 to 13 in c75cf54
Checklist
and self-explanatory (or properly documented)
Testing instructions
Dev testing only?
0013
migration manually