diff --git a/netbox/users/migrations/0005_alter_user_table.py b/netbox/users/migrations/0005_alter_user_table.py index 6c4a815dd..e07db6875 100644 --- a/netbox/users/migrations/0005_alter_user_table.py +++ b/netbox/users/migrations/0005_alter_user_table.py @@ -1,5 +1,3 @@ -# Generated by Django 5.0.1 on 2024-01-31 23:18 - from django.db import migrations @@ -27,12 +25,26 @@ class Migration(migrations.Migration): ] operations = [ - # 0001_squashed had model with db_table=auth_user - now we switch it - # to None to use the default Django resolution (users.user) + # The User table was originally created as 'auth_user'. Now we nullify the model's + # db_table option, so that it defaults to the app & model name (users_user). This + # causes the database table to be renamed. migrations.AlterModelTable( name='user', table=None, ), + + # Rename auth_user_* sequences + migrations.RunSQL("ALTER TABLE auth_user_groups_id_seq RENAME TO users_user_groups_id_seq"), + migrations.RunSQL("ALTER TABLE auth_user_id_seq RENAME TO users_user_id_seq"), + migrations.RunSQL("ALTER TABLE auth_user_user_permissions_id_seq RENAME TO users_user_user_permissions_id_seq"), + + # Rename auth_user_* indexes + migrations.RunSQL("ALTER INDEX auth_user_pkey RENAME TO users_user_pkey"), + # Hash is deterministic; generated via schema_editor._create_index_name() + migrations.RunSQL("ALTER INDEX auth_user_username_6821ab7c_like RENAME TO users_user_username_06e46fe6_like"), + migrations.RunSQL("ALTER INDEX auth_user_username_key RENAME TO users_user_username_key"), + + # Update ContentTypes migrations.RunPython( code=update_content_types, reverse_code=migrations.RunPython.noop