update erd db and add display name to user access table
This commit is contained in:
1 parent
ed84d989b7
commit
ae2ea27ae2
13 files changed
+91
-10
No files matched your search
@@ -0,0 +1,25 @@
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
def backfill_display_name(apps, schema_editor):
|
||||
User = apps.get_model("accounts", "User")
|
||||
for user in User.objects.all().iterator():
|
||||
if not (user.display_name or "").strip():
|
||||
User.objects.filter(pk=user.pk).update(display_name=user.user_name)
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
("accounts", "0004_sync_status_flags"),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name="user",
|
||||
name="display_name",
|
||||
field=models.CharField(default="", max_length=100),
|
||||
preserve_default=False,
|
||||
),
|
||||
migrations.RunPython(backfill_display_name, migrations.RunPython.noop),
|
||||
]
|
||||
Reference in new issue
Block a user