2019-09-23 22:51:31 +02:00
|
|
|
# Generated by Django 1.11.24 on 2019-09-23 20:39
|
|
|
|
|
|
|
|
from django.db import migrations
|
2022-05-27 23:33:51 +02:00
|
|
|
from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditor
|
2019-09-23 22:51:31 +02:00
|
|
|
from django.db.migrations.state import StateApps
|
|
|
|
|
2020-01-14 21:59:46 +01:00
|
|
|
|
2022-05-27 23:33:51 +02:00
|
|
|
def fix_bot_email_property(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:
|
2021-02-12 08:20:45 +01:00
|
|
|
UserProfile = apps.get_model("zerver", "UserProfile")
|
2019-09-23 22:51:31 +02:00
|
|
|
for user_profile in UserProfile.objects.filter(is_bot=True):
|
|
|
|
if user_profile.email != user_profile.delivery_email:
|
|
|
|
user_profile.email = user_profile.delivery_email
|
|
|
|
user_profile.save(update_fields=["email"])
|
|
|
|
|
2021-02-12 08:19:30 +01:00
|
|
|
|
2019-09-23 22:51:31 +02:00
|
|
|
class Migration(migrations.Migration):
|
|
|
|
|
|
|
|
dependencies = [
|
2021-02-12 08:20:45 +01:00
|
|
|
("zerver", "0241_usermessage_bigint_id_migration_finalize"),
|
2019-09-23 22:51:31 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
operations = [
|
2021-02-12 08:19:30 +01:00
|
|
|
migrations.RunPython(
|
|
|
|
fix_bot_email_property, reverse_code=migrations.RunPython.noop, elidable=True
|
|
|
|
),
|
2019-09-23 22:51:31 +02:00
|
|
|
]
|