snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled

This commit is contained in:
upstream-mirror
2026-09-15 15:05:30 +05:00
commit 64898b2c79
8999 changed files with 1757358 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
import secrets
import uuid
from django.db import migrations, models
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.migrations.state import StateApps
def generate_api_key() -> str:
"""
This is a copy of zerver.lib.utils.generate_api_key. Importing code that's prone
to change in a migration is something we generally avoid, to ensure predictable,
consistent behavior of the migration across time.
"""
api_key = ""
while len(api_key) < 32:
api_key += secrets.token_urlsafe(3 * 9).replace("_", "").replace("-", "")
return api_key[:32]
def generate_realm_uuid_owner_secret() -> str:
token = generate_api_key()
return f"zuliprealm_{token}"
def backfill_realm_uuid_and_secret(
apps: StateApps, schema_editor: BaseDatabaseSchemaEditor
) -> None:
Realm = apps.get_model("zerver", "Realm")
max_id = Realm.objects.aggregate(models.Max("id"))["id__max"]
if max_id is None:
# Nothing to do if there are no realms yet.
return
BATCH_SIZE = 100
lower_bound = 0
while lower_bound < max_id:
realms_to_update = []
for realm in Realm.objects.filter(
id__gt=lower_bound,
id__lte=lower_bound + BATCH_SIZE,
# We're setting uuid and uuid_owner_secret together, so it's enough
# to query for one of them being None.
uuid=None,
).only("id", "uuid", "uuid_owner_secret"):
realm.uuid = uuid.uuid4()
realm.uuid_owner_secret = generate_realm_uuid_owner_secret()
realms_to_update.append(realm)
lower_bound += BATCH_SIZE
Realm.objects.bulk_update(realms_to_update, ["uuid", "uuid_owner_secret"])
class Migration(migrations.Migration):
atomic = False
dependencies = [
("zerver", "0479_realm_uuid_realm_uuid_owner_secret"),
]
operations = [
migrations.RunPython(
backfill_realm_uuid_and_secret,
reverse_code=migrations.RunPython.noop,
elidable=True,
),
]