Skip to content
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

Add cojo to Schema Config #5388

Merged
merged 3 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions specifyweb/specify/migrations/0007_schema_config_update.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ def update_fields(apps):
Splocalecontaineritem = apps.get_model('specify', 'Splocalecontaineritem')
Splocaleitemstr = apps.get_model('specify', 'Splocaleitemstr')

# Revert COG -> children before adding to avoid duplicates
revert_table_field_schema_config('CollectionObjectGroup', 'children', apps)
# Add StorageTreeDef -> institution and COG -> children
for discipline in Discipline.objects.all():
update_table_field_schema_config_with_defaults('StorageTreeDef', discipline.id, 'institution', apps)
Expand Down
31 changes: 31 additions & 0 deletions specifyweb/specify/migrations/0012_add_cojo_to_schema_config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
"""
This migration adds COG -> cojo and CO -> cojo to Schema Config.
"""
from django.db import migrations
from specifyweb.specify.update_schema_config import revert_table_field_schema_config, update_table_field_schema_config_with_defaults

def add_cojo_to_schema_config(apps):
Discipline = apps.get_model('specify', 'Discipline')
for discipline in Discipline.objects.all():
update_table_field_schema_config_with_defaults('CollectionObjectGroup', discipline.id, 'cojo', apps)
update_table_field_schema_config_with_defaults('CollectionObject', discipline.id, 'cojo', apps)

def remove_cojo_from_schema_config(apps):
revert_table_field_schema_config('CollectionObjectGroup', 'cojo', apps)
revert_table_field_schema_config('CollectionObject', 'cojo', apps)

class Migration(migrations.Migration):

dependencies = [
('specify', '0011_cascading_tree_nodes'),
]

def apply_migration(apps, schema_editor):
add_cojo_to_schema_config(apps)

def revert_migration(apps, schema_editor):
remove_cojo_from_schema_config(apps)

operations = [
migrations.RunPython(apply_migration, revert_migration, atomic=True),
]
Loading