Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

migrations: Fix performance of migration 0436.

Mateusz Manderad0e9a77a57b5
diff --git a/zerver/migrations/0436_realmauthenticationmethods.py b/zerver/migrations/0436_realmauthenticationmethods.py
index 5c8b7b2e373..0716113e542 100644
--- a/zerver/migrations/0436_realmauthenticationmethods.py
+++ b/zerver/migrations/0436_realmauthenticationmethods.py
@@ -11,12 +11,13 @@ def fill_RealmAuthenticationMethod_data(
) -> None:
Realm = apps.get_model("zerver", "Realm")
RealmAuthenticationMethod = apps.get_model("zerver", "RealmAuthenticationMethod")
+ rows_to_create = []
for realm in Realm.objects.order_by("id"):
- rows_to_create = []
for key, value in realm.authentication_methods.iteritems():
if value:
rows_to_create.append(RealmAuthenticationMethod(name=key, realm_id=realm.id))
- RealmAuthenticationMethod.objects.bulk_create(rows_to_create)
+
+ RealmAuthenticationMethod.objects.bulk_create(rows_to_create, batch_size=10000)
class Migration(migrations.Migration):