# Generated by Django 5.0.1 on 2024-01-31 23:18 from django.db import migrations def update_content_types(apps, schema_editor): ContentType = apps.get_model('contenttypes', 'ContentType') # Delete the new ContentTypes effected by the new models in the users app ContentType.objects.filter(app_label='users', model='user').delete() # Update the app labels of the original ContentTypes for auth.User to ensure # that any foreign key references are preserved ContentType.objects.filter(app_label='auth', model='user').update(app_label='users') netboxuser_ct = ContentType.objects.filter(app_label='users', model='netboxuser').first() if netboxuser_ct: user_ct = ContentType.objects.filter(app_label='users', model='user').first() CustomField = apps.get_model('extras', 'CustomField') CustomField.objects.filter(object_type_id=netboxuser_ct.id).update(object_type_id=user_ct.id) netboxuser_ct.delete() class Migration(migrations.Migration): dependencies = [ ('users', '0002_squashed_0004'), ] operations = [ # 0001_squashed had model with db_table=auth_user - now we switch it # to None to use the default Django resolution (users.user) migrations.AlterModelTable( name='user', table=None, ), migrations.RunPython( code=update_content_types, reverse_code=migrations.RunPython.noop ), ]