mirror of
https://github.com/netbox-community/netbox.git
synced 2025-08-17 21:18:16 -06:00
12795 users.User migration
This commit is contained in:
parent
bf518d44e1
commit
7897203723
31
netbox/users/migrations/0005_alter_user_table.py
Normal file
31
netbox/users/migrations/0005_alter_user_table.py
Normal file
@ -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
|
||||
),
|
||||
]
|
Loading…
Reference in New Issue
Block a user