mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-22 23:46:44 -06:00
Extend migration to update original content type for ConfigRevision
This commit is contained in:
parent
b567dfd09e
commit
e111af4764
@ -25,7 +25,7 @@ class Migration(migrations.Migration):
|
||||
},
|
||||
),
|
||||
],
|
||||
# Table has been renamed from extras_configrevision
|
||||
# Table will be renamed from extras_configrevision in extras/0101_move_configrevision
|
||||
database_operations=[],
|
||||
),
|
||||
]
|
||||
|
@ -1,6 +1,17 @@
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def update_content_type(apps, schema_editor):
|
||||
ContentType = apps.get_model('contenttypes', 'ContentType')
|
||||
|
||||
# Delete the new ContentType effected by the introduction of core.ConfigRevision
|
||||
ContentType.objects.filter(app_label='core', model='configrevision').delete()
|
||||
|
||||
# Update the app label of the original ContentType for extras.ConfigRevision to ensure any foreign key
|
||||
# references are preserved
|
||||
ContentType.objects.filter(app_label='extras', model='configrevision').update(app_label='core')
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
@ -21,4 +32,8 @@ class Migration(migrations.Migration):
|
||||
),
|
||||
],
|
||||
),
|
||||
migrations.RunPython(
|
||||
code=update_content_type,
|
||||
reverse_code=migrations.RunPython.noop
|
||||
),
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user