mirror of
https://github.com/netbox-community/netbox.git
synced 2026-01-14 15:52:18 -06:00
* 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
36 lines
1.2 KiB
Python
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),
|
|
]
|