Files
netbox/netbox/extras/migrations/0102_move_configrevision.py
Jeremy Stretch 343a4af591 Closes #18022: Extend linter (ruff) to enforce line length limit (120 chars) (#18067)
* Enable E501 rule
* Configure ruff formatter
* Reformat migration files to fix line length violations
* Fix various E501 errors
* Move table template code to template_code.py & ignore E501 errors
* Reformat raw SQL
2024-11-21 15:58:11 -05:00

36 lines
1.2 KiB
Python

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 = [
('extras', '0101_eventrule'),
]
operations = [
migrations.SeparateDatabaseAndState(
state_operations=[
migrations.DeleteModel(
name='ConfigRevision',
),
],
database_operations=[
migrations.AlterModelTable(
name='ConfigRevision',
table='core_configrevision',
),
],
),
migrations.RunPython(code=update_content_type, reverse_code=migrations.RunPython.noop),
]