Add user_login field and migrate existing credentials.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b54624be96
commit
5a58dba347
3 files changed
+65
-8
No files matched your search
@@ -0,0 +1,32 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def copy_user_name_to_user_login(apps, schema_editor):
|
||||
User = apps.get_model("accounts", "User")
|
||||
for user in User.objects.all():
|
||||
user.user_login = user.user_name
|
||||
user.save(update_fields=["user_login"])
|
||||
|
||||
|
||||
def noop_reverse(apps, schema_editor):
|
||||
pass
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
dependencies = [
|
||||
("accounts", "0011_superuser_status"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="user_login",
|
||||
field=models.CharField(max_length=30, null=True),
|
||||
),
|
||||
migrations.RunPython(copy_user_name_to_user_login, noop_reverse),
|
||||
migrations.AlterField(
|
||||
model_name="user",
|
||||
name="user_login",
|
||||
field=models.CharField(max_length=30, unique=True),
|
||||
),
|
||||
]
|
||||
Reference in new issue
Block a user