From 7897203723d12f9b9a88d7a744d35773a41d0812 Mon Sep 17 00:00:00 2001 From: Arthur Date: Wed, 31 Jan 2024 15:52:45 -0800 Subject: [PATCH] 12795 users.User migration --- .../users/migrations/0005_alter_user_table.py | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 netbox/users/migrations/0005_alter_user_table.py diff --git a/netbox/users/migrations/0005_alter_user_table.py b/netbox/users/migrations/0005_alter_user_table.py new file mode 100644 index 000000000..ae32351b0 --- /dev/null +++ b/netbox/users/migrations/0005_alter_user_table.py @@ -0,0 +1,31 @@ +# 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') + + +class Migration(migrations.Migration): + + dependencies = [ + ('users', '0002_squashed_0004'), + ] + + operations = [ + migrations.AlterModelTable( + name='user', + table=None, + ), + migrations.RunPython( + code=update_content_types, + reverse_code=migrations.RunPython.noop + ), + ]