zulip/zerver
Sahil Batra 1d3f5a0368 migrations: Fix migration to set default for can_mention_group.
This commit updates `0455_set_default_for_can_mention_group`
migration to be more efficient when running for a large number
of UserGroup objects.

Previously, we did a loop over all UserGroup objects and
then did a `bulk_update`. All this happened in a single
transaction and the transaction was being hold for
unacceptably long time for a server with large number
of user groups. Also the SQL generated by Django for
`bulk_update` took almost quadratic time to evaluate,
as the SQL had linear length "CASE" statement which was
being resolved for each row.

We instead now use ".update" so that we can write the migration
without using loop and update the objects in batches of size
1000 so that we do not hold a transaction for very long time.
This also helps in avoiding the inefficient SQL that was being
executed due to using `bulk_update`.

We also update the queries to exclude the groups that already
have `can_mention_group` set to a non-null value, as this will
help in migration completing quickly when running it more than
once.
2023-07-21 14:41:18 -07:00
..
actions users: Directly access id of foreign keys instead of full object. 2023-07-20 10:44:39 -07:00
data_import ruff: Fix UP032 Use f-string instead of `format` call. 2023-07-19 16:14:59 -07:00
integration_fixtures/nagios
lib help: Remove "Invite users" relative help link. 2023-07-21 14:18:24 -07:00
management sync_ldap_user_data: Pass realm as arg to select_related. 2023-07-20 10:44:39 -07:00
migrations migrations: Fix migration to set default for can_mention_group. 2023-07-21 14:41:18 -07:00
openapi realm-settings: Make default_code_block_language empty string as default. 2023-07-21 18:54:02 +02:00
tests realm-settings: Make default_code_block_language empty string as default. 2023-07-21 18:54:02 +02:00
tornado mention: Send notifications for @topic wildcard mentions. 2023-07-17 09:39:24 -07:00
transaction_tests test_classes: Do not necessary wrap test cases in a transaction. 2023-07-06 11:44:50 -07:00
views realm-settings: Make default_code_block_language empty string as default. 2023-07-21 18:54:02 +02:00
webhooks gitea: Support missing head/base refs. 2023-07-21 14:18:52 -07:00
worker error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
__init__.py
apps.py requirements: Upgrade Python requirements. 2023-04-03 22:39:21 -07:00
context_processors.py emails: Add corporate_enabled to context for emails. 2023-05-01 10:32:43 -07:00
decorator.py logging_util: Remove dependence on get_current_request. 2023-07-11 22:23:47 -07:00
filters.py error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
forms.py python: Convert translated positional {} fields to {named} fields. 2023-07-18 15:19:07 -07:00
logging_handlers.py error_notify: Remove custom email error reporting handler. 2023-07-20 11:00:09 -07:00
middleware.py logging_util: Remove dependence on get_current_request. 2023-07-11 22:23:47 -07:00
models.py realm-settings: Make default_code_block_language empty string as default. 2023-07-21 18:54:02 +02:00
signals.py requirements: Upgrade to Django 4.0. 2022-07-13 16:07:17 -07:00