Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
typing: Use BaseDatabaseSchemaEditor in place of DatabaseSchemaEditor.
Zixuan James Lid5517932cd69
diff --git a/analytics/migrations/0009_remove_messages_to_stream_stat.py b/analytics/migrations/0009_remove_messages_to_stream_stat.pyindex 8f3ff9b08d8..9d8376c3f0d 100644--- a/analytics/migrations/0009_remove_messages_to_stream_stat.py+++ b/analytics/migrations/0009_remove_messages_to_stream_stat.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef delete_messages_sent_to_stream_stat(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserCount = apps.get_model("analytics", "UserCount")StreamCount = apps.get_model("analytics", "StreamCount")diff --git a/analytics/migrations/0010_clear_messages_sent_values.py b/analytics/migrations/0010_clear_messages_sent_values.pyindex 5e690f01ada..5f6ff8c9683 100644--- a/analytics/migrations/0010_clear_messages_sent_values.py+++ b/analytics/migrations/0010_clear_messages_sent_values.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef clear_message_sent_by_message_type_values(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserCount = apps.get_model("analytics", "UserCount")StreamCount = apps.get_model("analytics", "StreamCount")diff --git a/analytics/migrations/0011_clear_analytics_tables.py b/analytics/migrations/0011_clear_analytics_tables.pyindex 715d3c56adb..46bfa0d128f 100644--- a/analytics/migrations/0011_clear_analytics_tables.py+++ b/analytics/migrations/0011_clear_analytics_tables.py@@ -1,9 +1,9 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def clear_analytics_tables(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def clear_analytics_tables(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserCount = apps.get_model("analytics", "UserCount")StreamCount = apps.get_model("analytics", "StreamCount")RealmCount = apps.get_model("analytics", "RealmCount")diff --git a/analytics/migrations/0015_clear_duplicate_counts.py b/analytics/migrations/0015_clear_duplicate_counts.pyindex c82e4684393..de50e1cfe74 100644--- a/analytics/migrations/0015_clear_duplicate_counts.py+++ b/analytics/migrations/0015_clear_duplicate_counts.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Count, Sum-def clear_duplicate_counts(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def clear_duplicate_counts(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""This is a preparatory migration for our Analytics tables.The backstory is that Django's unique_together indexes do not properlydiff --git a/confirmation/migrations/0009_confirmation_expiry_date_backfill.py b/confirmation/migrations/0009_confirmation_expiry_date_backfill.pyindex a041e6091b5..23304be744b 100644--- a/confirmation/migrations/0009_confirmation_expiry_date_backfill.py+++ b/confirmation/migrations/0009_confirmation_expiry_date_backfill.py@@ -5,12 +5,12 @@ from datetime import timedeltafrom django.conf import settingsfrom django.db import migrations, transaction-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef set_expiry_date_for_existing_confirmations(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Confirmation = apps.get_model("confirmation", "Confirmation")if not Confirmation.objects.exists():diff --git a/pgroonga/migrations/0002_html_escape_subject.py b/pgroonga/migrations/0002_html_escape_subject.pyindex 7115789e8eb..fd9b1af8192 100644--- a/pgroonga/migrations/0002_html_escape_subject.py+++ b/pgroonga/migrations/0002_html_escape_subject.py@@ -1,12 +1,12 @@from django.db import connection, migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom psycopg2.sql import SQLfrom zerver.lib.migrate import do_batch_update-def rebuild_pgroonga_index(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def rebuild_pgroonga_index(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:with connection.cursor() as cursor:do_batch_update(cursor,diff --git a/zerver/migrations/0001_initial.py b/zerver/migrations/0001_initial.pyindex 0a20b1029ce..f71c68260a4 100644--- a/zerver/migrations/0001_initial.py+++ b/zerver/migrations/0001_initial.py@@ -8,14 +8,16 @@ from django.conf import settingsfrom django.contrib.postgres.indexes import GinIndexfrom django.contrib.postgres.search import SearchVectorFieldfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models.functions import Upperfrom zerver.models import generate_email_token_for_stream-def migrate_existing_attachment_data(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def migrate_existing_attachment_data(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:Attachment = apps.get_model("zerver", "Attachment")Recipient = apps.get_model("zerver", "Recipient")Stream = apps.get_model("zerver", "Stream")diff --git a/zerver/migrations/0029_realm_subdomain.py b/zerver/migrations/0029_realm_subdomain.pyindex 1552d602373..9f7855ca1ea 100644--- a/zerver/migrations/0029_realm_subdomain.py+++ b/zerver/migrations/0029_realm_subdomain.py@@ -1,11 +1,13 @@from django.conf import settingsfrom django.core.exceptions import ObjectDoesNotExistfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def set_subdomain_of_default_realm(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_subdomain_of_default_realm(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:if settings.DEVELOPMENT:Realm = apps.get_model("zerver", "Realm")try:diff --git a/zerver/migrations/0032_verify_all_medium_avatar_images.py b/zerver/migrations/0032_verify_all_medium_avatar_images.pyindex 92399f9a45e..df10daf86cd 100644--- a/zerver/migrations/0032_verify_all_medium_avatar_images.py+++ b/zerver/migrations/0032_verify_all_medium_avatar_images.py@@ -3,7 +3,7 @@ from unittest.mock import patchfrom django.conf import settingsfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom zerver.lib.upload import upload_backend@@ -24,7 +24,7 @@ def patched_user_avatar_path(user_profile: UserProfile) -> str:@patch("zerver.lib.upload.user_avatar_path", patched_user_avatar_path)-def verify_medium_avatar_image(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def verify_medium_avatar_image(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:user_profile_model = apps.get_model("zerver", "UserProfile")for user_profile in user_profile_model.objects.filter(avatar_source="U"):upload_backend.ensure_avatar_image(user_profile, is_medium=True)diff --git a/zerver/migrations/0033_migrate_domain_to_realmalias.py b/zerver/migrations/0033_migrate_domain_to_realmalias.pyindex 906755f542a..d4efb1ee533 100644--- a/zerver/migrations/0033_migrate_domain_to_realmalias.py+++ b/zerver/migrations/0033_migrate_domain_to_realmalias.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef add_domain_to_realm_alias_if_needed(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")RealmAlias = apps.get_model("zerver", "RealmAlias")diff --git a/zerver/migrations/0037_disallow_null_string_id.py b/zerver/migrations/0037_disallow_null_string_id.pyindex 67803dc9444..ceb64a660e3 100644--- a/zerver/migrations/0037_disallow_null_string_id.py+++ b/zerver/migrations/0037_disallow_null_string_id.py@@ -1,10 +1,10 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.utils import IntegrityError-def set_string_id_using_domain(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_string_id_using_domain(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")for realm in Realm.objects.all():if not realm.string_id:diff --git a/zerver/migrations/0041_create_attachments_for_old_messages.py b/zerver/migrations/0041_create_attachments_for_old_messages.pyindex bb77415b995..2d48ab0140b 100644--- a/zerver/migrations/0041_create_attachments_for_old_messages.py+++ b/zerver/migrations/0041_create_attachments_for_old_messages.py@@ -2,7 +2,7 @@ import osimport refrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsattachment_url_re = re.compile(r"[/\-]user[\-_]uploads[/\.-].*?(?=[ )]|\Z)")@@ -14,7 +14,7 @@ def attachment_url_to_path_id(attachment_url: str) -> str:return re.sub("[.]+$", "", path_id_raw, re.M)-def check_and_create_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def check_and_create_attachments(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:STREAM = 2Message = apps.get_model("zerver", "Message")Attachment = apps.get_model("zerver", "Attachment")diff --git a/zerver/migrations/0057_realmauditlog.py b/zerver/migrations/0057_realmauditlog.pyindex d6bc02a4697..0ee5f19cf1f 100644--- a/zerver/migrations/0057_realmauditlog.py+++ b/zerver/migrations/0057_realmauditlog.py@@ -2,13 +2,13 @@import django.db.models.deletionfrom django.conf import settingsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.utils.timezone import now as timezone_nowdef backfill_user_activations_and_deactivations(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:migration_time = timezone_now()RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")@@ -33,7 +33,7 @@ def backfill_user_activations_and_deactivations()-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.objects.filter(event_type="user_created").delete()RealmAuditLog.objects.filter(event_type="user_deactivated").delete()diff --git a/zerver/migrations/0074_fix_duplicate_attachments.py b/zerver/migrations/0074_fix_duplicate_attachments.pyindex d306929e171..770a61c0fc8 100644--- a/zerver/migrations/0074_fix_duplicate_attachments.py+++ b/zerver/migrations/0074_fix_duplicate_attachments.py@@ -1,11 +1,11 @@# Generated by Django 1.10.5 on 2017-04-13 22:12from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Count-def fix_duplicate_attachments(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_duplicate_attachments(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Migration 0041 had a bug, where if multiple messages referenced thesame attachment, rather than creating a single attachment objectfor all of them, we would incorrectly create one for each message.diff --git a/zerver/migrations/0079_remove_old_scheduled_jobs.py b/zerver/migrations/0079_remove_old_scheduled_jobs.pyindex f341ecd61ae..91c0dfce3bb 100644--- a/zerver/migrations/0079_remove_old_scheduled_jobs.py+++ b/zerver/migrations/0079_remove_old_scheduled_jobs.py@@ -1,10 +1,10 @@# Generated by Django 1.10.5 on 2017-05-10 05:59from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def delete_old_scheduled_jobs(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Delete any old scheduled jobs, to handle changes in the format ofthat table. Ideally, we'd translate the jobs, but it's not reallyworth the development effort to save a few invitation remindersdiff --git a/zerver/migrations/0081_make_emoji_lowercase.py b/zerver/migrations/0081_make_emoji_lowercase.pyindex 350bbefc0d9..0d5532178ad 100644--- a/zerver/migrations/0081_make_emoji_lowercase.py+++ b/zerver/migrations/0081_make_emoji_lowercase.py@@ -1,7 +1,7 @@# Generated by Django 1.10.5 on 2017-05-02 21:44import django.core.validatorsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps@@ -11,7 +11,7 @@ class Migration(migrations.Migration):("zerver", "0080_realm_description_length"),]- def emoji_to_lowercase(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+ def emoji_to_lowercase(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmEmoji = apps.get_model("zerver", "RealmEmoji")emoji = RealmEmoji.objects.all()for e in emoji:diff --git a/zerver/migrations/0085_fix_bots_with_none_bot_type.py b/zerver/migrations/0085_fix_bots_with_none_bot_type.pyindex 950515804b6..fbc42c31051 100644--- a/zerver/migrations/0085_fix_bots_with_none_bot_type.py+++ b/zerver/migrations/0085_fix_bots_with_none_bot_type.py@@ -1,10 +1,10 @@# Generated by Django 1.11.2 on 2017-06-20 10:31from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def fix_bot_type(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_bot_type(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")bots = UserProfile.objects.filter(is_bot=True, bot_type=None)for bot in bots:diff --git a/zerver/migrations/0087_remove_old_scheduled_jobs.py b/zerver/migrations/0087_remove_old_scheduled_jobs.pyindex c4517de70f9..bf9a27592c8 100644--- a/zerver/migrations/0087_remove_old_scheduled_jobs.py+++ b/zerver/migrations/0087_remove_old_scheduled_jobs.py@@ -1,10 +1,10 @@# Generated by Django 1.10.5 on 2017-05-10 05:59from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def delete_old_scheduled_jobs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def delete_old_scheduled_jobs(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Delete any old scheduled jobs, to handle changes in the format ofsend_email. Ideally, we'd translate the jobs, but it's not reallyworth the development effort to save a few invitation remindersdiff --git a/zerver/migrations/0093_subscription_event_log_backfill.py b/zerver/migrations/0093_subscription_event_log_backfill.pyindex 6c5b058213a..0a9c40236d9 100644--- a/zerver/migrations/0093_subscription_event_log_backfill.py+++ b/zerver/migrations/0093_subscription_event_log_backfill.py@@ -1,11 +1,13 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Maxfrom django.utils.timezone import now as timezone_now-def backfill_subscription_log_events(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_subscription_log_events(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:migration_time = timezone_now()RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")Subscription = apps.get_model("zerver", "Subscription")@@ -46,7 +48,7 @@ def backfill_subscription_log_events(apps: StateApps, schema_editor: DatabaseSchobjects_to_create = []-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.objects.filter(event_type="subscription_created").delete()RealmAuditLog.objects.filter(event_type="subscription_deactivated").delete()diff --git a/zerver/migrations/0097_reactions_emoji_code.py b/zerver/migrations/0097_reactions_emoji_code.pyindex a0d3225dbc7..025e44e8eac 100644--- a/zerver/migrations/0097_reactions_emoji_code.py+++ b/zerver/migrations/0097_reactions_emoji_code.py@@ -3,11 +3,11 @@ import osimport orjsonfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def populate_new_fields(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def populate_new_fields(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:# Open the JSON file which contains the data to be used for migration.MIGRATION_DATA_PATH = os.path.join(os.path.dirname(os.path.dirname(__file__)), "management", "data"diff --git a/zerver/migrations/0102_convert_muted_topic.py b/zerver/migrations/0102_convert_muted_topic.pyindex 75a5d11b428..882ecbf0f0d 100644--- a/zerver/migrations/0102_convert_muted_topic.py+++ b/zerver/migrations/0102_convert_muted_topic.py@@ -1,12 +1,12 @@# Generated by Django 1.11.4 on 2017-08-30 00:26import orjsonfrom django.db import connection, migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom psycopg2.sql import SQL-def convert_muted_topics(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def convert_muted_topics(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:stream_query = SQL("""SELECTdiff --git a/zerver/migrations/0104_fix_unreads.py b/zerver/migrations/0104_fix_unreads.pyindex c74d1658f04..e9258a27ddc 100644--- a/zerver/migrations/0104_fix_unreads.py+++ b/zerver/migrations/0104_fix_unreads.py@@ -1,12 +1,12 @@# Generated by Django 1.11.4 on 2017-08-30 00:26from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom zerver.lib.fix_unreads import fix-def fix_unreads(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_unreads(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")user_profiles = list(UserProfile.objects.filter(is_bot=False))for user_profile in user_profiles:diff --git a/zerver/migrations/0108_fix_default_string_id.py b/zerver/migrations/0108_fix_default_string_id.pyindex 15f92876ac9..cdc7068854f 100644--- a/zerver/migrations/0108_fix_default_string_id.py+++ b/zerver/migrations/0108_fix_default_string_id.py@@ -1,10 +1,10 @@# Generated by Django 1.11.4 on 2017-08-24 02:39from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def fix_realm_string_ids(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_realm_string_ids(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")if Realm.objects.filter(deactivated=False).count() != 2:returndiff --git a/zerver/migrations/0109_mark_tutorial_status_finished.py b/zerver/migrations/0109_mark_tutorial_status_finished.pyindex c4e26b026e0..6dbaf3331d4 100644--- a/zerver/migrations/0109_mark_tutorial_status_finished.py+++ b/zerver/migrations/0109_mark_tutorial_status_finished.py@@ -1,9 +1,11 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def set_tutorial_status_to_finished(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_tutorial_status_to_finished(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.update(tutorial_status="F")diff --git a/zerver/migrations/0110_stream_is_in_zephyr_realm.py b/zerver/migrations/0110_stream_is_in_zephyr_realm.pyindex 20fa71c2ea6..99886b681b3 100644--- a/zerver/migrations/0110_stream_is_in_zephyr_realm.py+++ b/zerver/migrations/0110_stream_is_in_zephyr_realm.py@@ -1,10 +1,10 @@# Generated by Django 1.11.5 on 2017-10-08 18:37from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def populate_is_zephyr(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def populate_is_zephyr(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Stream = apps.get_model("zerver", "Stream")diff --git a/zerver/migrations/0121_realm_signup_notifications_stream.py b/zerver/migrations/0121_realm_signup_notifications_stream.pyindex be5326bc722..1cfa5b54e3e 100644--- a/zerver/migrations/0121_realm_signup_notifications_stream.py+++ b/zerver/migrations/0121_realm_signup_notifications_stream.py@@ -2,12 +2,12 @@import django.db.models.deletionfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef set_initial_value_for_signup_notifications_stream(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:realm_model = apps.get_model("zerver", "Realm")realms = realm_model.objects.exclude(notifications_stream__isnull=True)diff --git a/zerver/migrations/0126_prereg_remove_users_without_realm.py b/zerver/migrations/0126_prereg_remove_users_without_realm.pyindex 1e688c4b04e..f044a0bb2a0 100644--- a/zerver/migrations/0126_prereg_remove_users_without_realm.py+++ b/zerver/migrations/0126_prereg_remove_users_without_realm.py@@ -1,11 +1,13 @@# Generated by Django 1.11.6 on 2017-11-30 04:58from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def remove_prereg_users_without_realm(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def remove_prereg_users_without_realm(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:prereg_model = apps.get_model("zerver", "PreregistrationUser")prereg_model.objects.filter(realm=None, realm_creation=False).delete()diff --git a/zerver/migrations/0128_scheduledemail_realm.py b/zerver/migrations/0128_scheduledemail_realm.pyindex 98dcb702bcc..5ec2df151dc 100644--- a/zerver/migrations/0128_scheduledemail_realm.py+++ b/zerver/migrations/0128_scheduledemail_realm.py@@ -2,12 +2,12 @@import django.db.models.deletionfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef set_realm_for_existing_scheduledemails(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:scheduledemail_model = apps.get_model("zerver", "ScheduledEmail")preregistrationuser_model = apps.get_model("zerver", "PreregistrationUser")diff --git a/zerver/migrations/0130_text_choice_in_emojiset.py b/zerver/migrations/0130_text_choice_in_emojiset.pyindex 3010c2aa76b..d0a85b43f9f 100644--- a/zerver/migrations/0130_text_choice_in_emojiset.py+++ b/zerver/migrations/0130_text_choice_in_emojiset.py@@ -1,17 +1,17 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# change emoji set to text if emoji_alt_code is true.-def change_emojiset(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def change_emojiset(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")for user in UserProfile.objects.filter(emoji_alt_code=True):user.emojiset = "text"user.save(update_fields=["emojiset"])-def reverse_change_emojiset(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_change_emojiset(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")for user in UserProfile.objects.filter(emojiset="text"):# Resetting `emojiset` to "google" (the default) doesn't make andiff --git a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.pyindex 5d0b24fb4f4..2feb0eb2038 100644--- a/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py+++ b/zerver/migrations/0139_fill_last_message_id_in_subscription_logs.py@@ -1,9 +1,9 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def backfill_last_message_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_last_message_id(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:event_type = ["subscription_created", "subscription_deactivated", "subscription_activated"]RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")subscription_logs = RealmAuditLog.objects.filter(diff --git a/zerver/migrations/0143_realm_bot_creation_policy.py b/zerver/migrations/0143_realm_bot_creation_policy.pyindex 0591fe6611a..6c95f448eb6 100644--- a/zerver/migrations/0143_realm_bot_creation_policy.py+++ b/zerver/migrations/0143_realm_bot_creation_policy.py@@ -1,13 +1,13 @@# Generated by Django 1.11.6 on 2018-03-09 18:00from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsBOT_CREATION_EVERYONE = 1def set_initial_value_for_bot_creation_policy(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.BOT_CREATION_EVERYONE = 1@@ -20,7 +20,7 @@ def set_initial_value_for_bot_creation_policy(realm.save(update_fields=["bot_creation_policy"])-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.BOT_CREATION_EVERYONE = 1for realm in Realm.objects.all():diff --git a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.pyindex 785cfcd6813..b7d08f7c26f 100644--- a/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py+++ b/zerver/migrations/0145_reactions_realm_emoji_name_to_id.py@@ -2,11 +2,11 @@ from collections import defaultdictfrom typing import Any, Dictfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def realm_emoji_name_to_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def realm_emoji_name_to_id(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Reaction = apps.get_model("zerver", "Reaction")RealmEmoji = apps.get_model("zerver", "RealmEmoji")realm_emoji_by_realm_id: Dict[int, Dict[str, Any]] = defaultdict(dict)@@ -33,7 +33,7 @@ def realm_emoji_name_to_id(apps: StateApps, schema_editor: DatabaseSchemaEditor)reaction.save()-def reversal(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reversal(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Reaction = apps.get_model("zerver", "Reaction")for reaction in Reaction.objects.filter(reaction_type="realm_emoji"):reaction.emoji_code = reaction.emoji_namediff --git a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.pyindex 6dd8c8b83bb..e312b494892 100644--- a/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py+++ b/zerver/migrations/0149_realm_emoji_drop_unique_constraint.py@@ -4,7 +4,7 @@ import shutilimport boto3from django.conf import settingsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom mypy_boto3_s3.type_defs import CopySourceTypeDef@@ -82,7 +82,9 @@ def get_emoji_file_name(emoji_file_name: str, new_name: str) -> str:return "".join((new_name, image_ext))-def migrate_realm_emoji_image_files(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def migrate_realm_emoji_image_files(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:RealmEmoji = apps.get_model("zerver", "RealmEmoji")uploader = get_uploader()for realm_emoji in RealmEmoji.objects.all():@@ -93,7 +95,7 @@ def migrate_realm_emoji_image_files(apps: StateApps, schema_editor: DatabaseScherealm_emoji.save(update_fields=["file_name"])-def reversal(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reversal(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:# Ensures that migration can be re-run in case of a failure.RealmEmoji = apps.get_model("zerver", "RealmEmoji")for realm_emoji in RealmEmoji.objects.all():diff --git a/zerver/migrations/0154_fix_invalid_bot_owner.py b/zerver/migrations/0154_fix_invalid_bot_owner.pyindex 4368f61d2a9..1657d4df7dd 100644--- a/zerver/migrations/0154_fix_invalid_bot_owner.py+++ b/zerver/migrations/0154_fix_invalid_bot_owner.py@@ -1,12 +1,12 @@# Generated by Django 1.11.6 on 2018-04-03 01:52from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef migrate_fix_invalid_bot_owner_values(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Fixes UserProfile objects that incorrectly had a bot_owner set"""UserProfile = apps.get_model("zerver", "UserProfile")diff --git a/zerver/migrations/0164_stream_history_public_to_subscribers.py b/zerver/migrations/0164_stream_history_public_to_subscribers.pyindex e0895af3618..4f5d31fcc03 100644--- a/zerver/migrations/0164_stream_history_public_to_subscribers.py+++ b/zerver/migrations/0164_stream_history_public_to_subscribers.py@@ -2,12 +2,12 @@from django.conf import settingsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef set_initial_value_for_history_public_to_subscribers(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:stream_model = apps.get_model("zerver", "Stream")streams = stream_model.objects.all()diff --git a/zerver/migrations/0167_custom_profile_fields_sort_order.py b/zerver/migrations/0167_custom_profile_fields_sort_order.pyindex cf04db7ea7b..20f5f101833 100644--- a/zerver/migrations/0167_custom_profile_fields_sort_order.py+++ b/zerver/migrations/0167_custom_profile_fields_sort_order.py@@ -1,12 +1,12 @@# Generated by Django 1.11.11 on 2018-04-08 15:49from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import F-def migrate_set_order_value(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def migrate_set_order_value(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:CustomProfileField = apps.get_model("zerver", "CustomProfileField")CustomProfileField.objects.all().update(order=F("id"))diff --git a/zerver/migrations/0174_userprofile_delivery_email.py b/zerver/migrations/0174_userprofile_delivery_email.pyindex 5c2de4c6c31..970bee6fbf8 100644--- a/zerver/migrations/0174_userprofile_delivery_email.py+++ b/zerver/migrations/0174_userprofile_delivery_email.py@@ -1,12 +1,12 @@# Generated by Django 1.11.13 on 2018-07-05 17:57from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import F-def copy_email_field(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def copy_email_field(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.all().update(delivery_email=F("email"))diff --git a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.pyindex 7c65e8ac8a8..1433f1f91e0 100644--- a/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py+++ b/zerver/migrations/0175_change_realm_audit_log_event_type_tense.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef change_realm_audit_log_event_type_tense(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.objects.filter(event_type="user_change_password").update(diff --git a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.pyindex 354fa034299..6ed6c07bed2 100644--- a/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py+++ b/zerver/migrations/0177_user_message_add_and_index_is_private_flag.py@@ -2,12 +2,12 @@import bitfield.modelsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import F, Q-def reset_is_private_flag(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reset_is_private_flag(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserMessage = apps.get_model("zerver", "UserMessage")UserProfile = apps.get_model("zerver", "UserProfile")user_profile_ids = UserProfile.objects.all().order_by("id").values_list("id", flat=True)diff --git a/zerver/migrations/0181_userprofile_change_emojiset.py b/zerver/migrations/0181_userprofile_change_emojiset.pyindex 9f72b7a6495..04b76188fa9 100644--- a/zerver/migrations/0181_userprofile_change_emojiset.py+++ b/zerver/migrations/0181_userprofile_change_emojiset.py@@ -1,9 +1,9 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def change_emojiset_choice(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.exclude(emojiset__in=["google", "text"]).update(emojiset="google")diff --git a/zerver/migrations/0182_set_initial_value_is_private_flag.py b/zerver/migrations/0182_set_initial_value_is_private_flag.pyindex c3998f56b24..5d5377d1218 100644--- a/zerver/migrations/0182_set_initial_value_is_private_flag.py+++ b/zerver/migrations/0182_set_initial_value_is_private_flag.py@@ -1,11 +1,11 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Fdef set_initial_value_of_is_private_flag(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserMessage = apps.get_model("zerver", "UserMessage")Message = apps.get_model("zerver", "Message")diff --git a/zerver/migrations/0189_userprofile_add_some_emojisets.py b/zerver/migrations/0189_userprofile_add_some_emojisets.pyindex db161787ca8..1180a1aa6e4 100644--- a/zerver/migrations/0189_userprofile_add_some_emojisets.py+++ b/zerver/migrations/0189_userprofile_add_some_emojisets.py@@ -1,11 +1,11 @@# Generated by Django 1.11.14 on 2018-08-28 19:01from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def change_emojiset_choice(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def change_emojiset_choice(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.filter(emojiset="google").update(emojiset="google-blob")diff --git a/zerver/migrations/0198_preregistrationuser_invited_as.py b/zerver/migrations/0198_preregistrationuser_invited_as.pyindex 6e955b70635..80b46d24423 100644--- a/zerver/migrations/0198_preregistrationuser_invited_as.py+++ b/zerver/migrations/0198_preregistrationuser_invited_as.py@@ -1,11 +1,13 @@# Generated by Django 1.11.16 on 2018-12-27 17:09from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def set_initial_value_for_invited_as(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_initial_value_for_invited_as(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:PreregistrationUser = apps.get_model("zerver", "PreregistrationUser")for user in PreregistrationUser.objects.all():if user.invited_as_admin:@@ -15,7 +17,7 @@ def set_initial_value_for_invited_as(apps: StateApps, schema_editor: DatabaseSchuser.save(update_fields=["invited_as"])-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:PreregistrationUser = apps.get_model("zerver", "PreregistrationUser")for user in PreregistrationUser.objects.all():if user.invited_as == 2: # PreregistrationUser.INVITE_AS['REALM_ADMIN']diff --git a/zerver/migrations/0206_stream_rendered_description.py b/zerver/migrations/0206_stream_rendered_description.pyindex 38f58e43b63..b69b5d54696 100644--- a/zerver/migrations/0206_stream_rendered_description.py+++ b/zerver/migrations/0206_stream_rendered_description.py@@ -1,9 +1,11 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def render_all_stream_descriptions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def render_all_stream_descriptions(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:# FIXME: Application code should not be imported from migrations.from zerver.lib.streams import render_stream_descriptiondiff --git a/zerver/migrations/0209_user_profile_no_empty_password.py b/zerver/migrations/0209_user_profile_no_empty_password.pyindex 40d98b22c5e..053ad36025f 100644--- a/zerver/migrations/0209_user_profile_no_empty_password.py+++ b/zerver/migrations/0209_user_profile_no_empty_password.py@@ -6,7 +6,7 @@ import orjsonfrom django.conf import settingsfrom django.contrib.auth.hashers import check_password, make_passwordfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.utils.timezone import now as timezone_now@@ -15,7 +15,7 @@ from zerver.lib.queue import queue_json_publishfrom zerver.lib.utils import generate_api_key-def ensure_no_empty_passwords(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def ensure_no_empty_passwords(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""With CVE-2019-18933, it was possible for certain users createdusing social login (e.g. Google/GitHub auth) to have the emptystring as their password in the Zulip database, rather thandiff --git a/zerver/migrations/0210_stream_first_message_id.py b/zerver/migrations/0210_stream_first_message_id.pyindex f1989bb5fdc..61ec59b8eca 100644--- a/zerver/migrations/0210_stream_first_message_id.py+++ b/zerver/migrations/0210_stream_first_message_id.py@@ -1,11 +1,11 @@# Generated by Django 1.11.18 on 2019-02-25 12:42from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def backfill_first_message_id(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_first_message_id(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Stream = apps.get_model("zerver", "Stream")Message = apps.get_model("zerver", "Message")for stream in Stream.objects.all():diff --git a/zerver/migrations/0211_add_users_field_to_scheduled_email.py b/zerver/migrations/0211_add_users_field_to_scheduled_email.pyindex b57b194ee04..8b390eddbbd 100644--- a/zerver/migrations/0211_add_users_field_to_scheduled_email.py+++ b/zerver/migrations/0211_add_users_field_to_scheduled_email.py@@ -2,12 +2,12 @@from django.conf import settingsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef set_users_for_existing_scheduledemails(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:ScheduledEmail = apps.get_model("zerver", "ScheduledEmail")for email in ScheduledEmail.objects.all():diff --git a/zerver/migrations/0214_realm_invite_to_stream_policy.py b/zerver/migrations/0214_realm_invite_to_stream_policy.pyindex fb472f8a552..463233a4c4a 100644--- a/zerver/migrations/0214_realm_invite_to_stream_policy.py+++ b/zerver/migrations/0214_realm_invite_to_stream_policy.py@@ -1,12 +1,12 @@# Generated by Django 1.11.20 on 2019-04-29 05:29from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsINVITE_TO_STREAM_POLICY_MEMBERS = 1-def handle_waiting_period(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def handle_waiting_period(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.INVITE_TO_STREAM_POLICY_WAITING_PERIOD = 3Realm.objects.filter(waiting_period_threshold__gt=0).update(diff --git a/zerver/migrations/0217_migrate_create_stream_policy.py b/zerver/migrations/0217_migrate_create_stream_policy.pyindex 36a99710c5d..56738b43f37 100644--- a/zerver/migrations/0217_migrate_create_stream_policy.py+++ b/zerver/migrations/0217_migrate_create_stream_policy.py@@ -1,11 +1,11 @@# Generated by Django 1.11.20 on 2019-05-06 13:15from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def upgrade_create_stream_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def upgrade_create_stream_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.CREATE_STREAM_POLICY_MEMBERS = 1Realm.CREATE_STREAM_POLICY_ADMINS = 2diff --git a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.pyindex a3af8850d84..ee426cf0e0a 100644--- a/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py+++ b/zerver/migrations/0219_toggle_realm_digest_emails_enabled_default.py@@ -1,12 +1,12 @@# Generated by Django 1.11.20 on 2019-05-08 05:42from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef disable_realm_digest_emails_enabled(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")realms = Realm.objects.filter(digest_emails_enabled=True)diff --git a/zerver/migrations/0221_subscription_notifications_data_migration.py b/zerver/migrations/0221_subscription_notifications_data_migration.pyindex 7c9acbcd5f5..dafc5290fca 100644--- a/zerver/migrations/0221_subscription_notifications_data_migration.py+++ b/zerver/migrations/0221_subscription_notifications_data_migration.py@@ -1,7 +1,7 @@# Generated by Django 1.11.18 on 2019-02-13 20:13from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsRECIPIENT_STREAM = 2@@ -13,7 +13,7 @@ SETTINGS_MAP = {}-def update_notification_settings(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def update_notification_settings(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Subscription = apps.get_model("zerver", "Subscription")UserProfile = apps.get_model("zerver", "UserProfile")@@ -29,7 +29,7 @@ def update_notification_settings(apps: StateApps, schema_editor: DatabaseSchemaE).update(**update_kwargs)-def reverse_notification_settings(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_notification_settings(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Subscription = apps.get_model("zerver", "Subscription")UserProfile = apps.get_model("zerver", "UserProfile")diff --git a/zerver/migrations/0223_rename_to_is_muted.py b/zerver/migrations/0223_rename_to_is_muted.pyindex bb6de131fe6..637df64ed74 100644--- a/zerver/migrations/0223_rename_to_is_muted.py+++ b/zerver/migrations/0223_rename_to_is_muted.py@@ -1,12 +1,14 @@# Generated by Django 1.11.14 on 2018-08-10 16:04from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Case, Value, When-def set_initial_value_for_is_muted(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_initial_value_for_is_muted(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:Subscription = apps.get_model("zerver", "Subscription")Subscription.objects.update(is_muted=Case(@@ -16,7 +18,7 @@ def set_initial_value_for_is_muted(apps: StateApps, schema_editor: DatabaseSchem)-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Subscription = apps.get_model("zerver", "Subscription")Subscription.objects.update(in_home_view=Case(diff --git a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py b/zerver/migrations/0224_alter_field_realm_video_chat_provider.pyindex 68dca250468..9d168e49a87 100644--- a/zerver/migrations/0224_alter_field_realm_video_chat_provider.py+++ b/zerver/migrations/0224_alter_field_realm_video_chat_provider.py@@ -3,7 +3,7 @@from typing import Any, Dict, Optionalfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# We include a copy of this structure as it was at the time this@@ -38,7 +38,7 @@ def get_video_chat_provider_detail(def update_existing_video_chat_provider_values(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")@@ -49,7 +49,7 @@ def update_existing_video_chat_provider_values(realm.save(update_fields=["video_chat_provider"])-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")for realm in Realm.objects.all():diff --git a/zerver/migrations/0227_inline_url_embed_preview_default_off.py b/zerver/migrations/0227_inline_url_embed_preview_default_off.pyindex 16900e09fef..67dcccef290 100644--- a/zerver/migrations/0227_inline_url_embed_preview_default_off.py+++ b/zerver/migrations/0227_inline_url_embed_preview_default_off.py@@ -1,12 +1,12 @@# Generated by Django 1.11.20 on 2019-05-31 02:33from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef disable_realm_inline_url_embed_preview(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")realms = Realm.objects.filter(inline_url_embed_preview=True)diff --git a/zerver/migrations/0236_remove_illegal_characters_email_full.py b/zerver/migrations/0236_remove_illegal_characters_email_full.pyindex 359660be31a..2723563a685 100644--- a/zerver/migrations/0236_remove_illegal_characters_email_full.py+++ b/zerver/migrations/0236_remove_illegal_characters_email_full.py@@ -3,13 +3,13 @@from unicodedata import categoryfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsNAME_INVALID_CHARS = ["*", "`", "\\", ">", '"', "@"]-def remove_name_illegal_chars(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def remove_name_illegal_chars(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")for user in UserProfile.objects.all():stripped = []diff --git a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.pyindex 6844ca02205..0af56b73269 100644--- a/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py+++ b/zerver/migrations/0237_rename_zulip_realm_to_zulipinternal.py@@ -1,11 +1,11 @@from django.conf import settingsfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef rename_zulip_realm_to_zulipinternal(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:if not settings.PRODUCTION:returndiff --git a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.pyindex 29405c4670c..0cf4045c916 100644--- a/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py+++ b/zerver/migrations/0239_usermessage_copy_id_to_bigint_id.py@@ -3,7 +3,7 @@import timefrom django.db import connection, migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Minfrom psycopg2.sql import SQL@@ -29,7 +29,7 @@ def sql_copy_id_to_bigint_id(id_range_lower_bound: int, id_range_upper_bound: in)-def copy_id_to_bigid(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def copy_id_to_bigid(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserMessage = apps.get_model("zerver", "UserMessage")if not UserMessage.objects.exists():# Nothing to dodiff --git a/zerver/migrations/0242_fix_bot_email_property.py b/zerver/migrations/0242_fix_bot_email_property.pyindex 54713720630..9262df4c404 100644--- a/zerver/migrations/0242_fix_bot_email_property.py+++ b/zerver/migrations/0242_fix_bot_email_property.py@@ -1,11 +1,11 @@# Generated by Django 1.11.24 on 2019-09-23 20:39from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def fix_bot_email_property(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_bot_email_property(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")for user_profile in UserProfile.objects.filter(is_bot=True):if user_profile.email != user_profile.delivery_email:diff --git a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.pyindex 2d97f068db0..59f855eab70 100644--- a/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py+++ b/zerver/migrations/0244_message_copy_pub_date_to_date_sent.py@@ -2,7 +2,7 @@ import timefrom django.contrib.postgres.operations import AddIndexConcurrentlyfrom django.db import connection, migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Minfrom psycopg2.sql import SQL@@ -28,7 +28,7 @@ def sql_copy_pub_date_to_date_sent(id_range_lower_bound: int, id_range_upper_bou)-def copy_pub_date_to_date_sent(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def copy_pub_date_to_date_sent(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Message = apps.get_model("zerver", "Message")if not Message.objects.exists():# Nothing to dodiff --git a/zerver/migrations/0247_realmauditlog_event_type_to_int.py b/zerver/migrations/0247_realmauditlog_event_type_to_int.pyindex dcbe892b603..7bd6bca3744 100644--- a/zerver/migrations/0247_realmauditlog_event_type_to_int.py+++ b/zerver/migrations/0247_realmauditlog_event_type_to_int.py@@ -1,7 +1,7 @@# Generated by Django 1.11.24 on 2019-10-02 16:48from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsINT_VALUE = {@@ -67,14 +67,16 @@ STR_VALUE = {}-def update_existing_event_type_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def update_existing_event_type_values(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")for log_entry in RealmAuditLog.objects.all():log_entry.event_type_int = INT_VALUE[log_entry.event_type]log_entry.save(update_fields=["event_type_int"])-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")for log_entry in RealmAuditLog.objects.all():log_entry.event_type = STR_VALUE[log_entry.event_type_int]diff --git a/zerver/migrations/0248_userprofile_role_start.py b/zerver/migrations/0248_userprofile_role_start.pyindex 680da5acaa6..996d3690a69 100644--- a/zerver/migrations/0248_userprofile_role_start.py+++ b/zerver/migrations/0248_userprofile_role_start.py@@ -1,10 +1,10 @@# Generated by Django 1.11.24 on 2019-10-03 22:27from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def update_role(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def update_role(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")# The values at the time of this migrationUserProfile.ROLE_REALM_ADMINISTRATOR = 200@@ -20,7 +20,7 @@ def update_role(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:user.save(update_fields=["role"])-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.ROLE_REALM_ADMINISTRATOR = 200UserProfile.ROLE_GUEST = 600diff --git a/zerver/migrations/0257_fix_has_link_attribute.py b/zerver/migrations/0257_fix_has_link_attribute.pyindex fd7fdca067d..253282e742e 100644--- a/zerver/migrations/0257_fix_has_link_attribute.py+++ b/zerver/migrations/0257_fix_has_link_attribute.py@@ -5,7 +5,7 @@ from typing import castimport lxmlfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsBATCH_SIZE = 1000@@ -55,7 +55,7 @@ def process_batch(apps: StateApps, id_start: int, id_end: int, last_id: int) ->message.save(update_fields=["has_link", "has_attachment", "has_image"])-def fix_has_link(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_has_link(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Message = apps.get_model("zerver", "Message")if not Message.objects.exists():# Nothing to do, and Message.objects.latest() will crash.diff --git a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.pyindex 12b5fc88eb5..ba5bebb1666 100644--- a/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py+++ b/zerver/migrations/0260_missed_message_addresses_from_redis_to_db.py@@ -2,7 +2,7 @@ import secretsfrom django.core.exceptions import ObjectDoesNotExistfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# Imported to avoid needing to duplicate Redis-related code.@@ -14,7 +14,7 @@ def generate_missed_message_token() -> str:def move_missed_message_addresses_to_database(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:redis_client = get_redis_client()MissedMessageEmailAddress = apps.get_model("zerver", "MissedMessageEmailAddress")diff --git a/zerver/migrations/0261_pregistrationuser_clear_invited_as_admin.py b/zerver/migrations/0261_pregistrationuser_clear_invited_as_admin.pyindex feba0db5113..4fd97107ed0 100644--- a/zerver/migrations/0261_pregistrationuser_clear_invited_as_admin.py+++ b/zerver/migrations/0261_pregistrationuser_clear_invited_as_admin.py@@ -1,12 +1,12 @@# Generated by Django 1.11.26 on 2020-06-16 22:26from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef clear_preregistrationuser_invited_as_admin(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""This migration fixes any PreregistrationUser objects that mighthave been already corrupted to have the administrator role by thediff --git a/zerver/migrations/0264_migrate_is_announcement_only.py b/zerver/migrations/0264_migrate_is_announcement_only.pyindex 073eb22a236..02d3485d3c4 100644--- a/zerver/migrations/0264_migrate_is_announcement_only.py+++ b/zerver/migrations/0264_migrate_is_announcement_only.py@@ -1,11 +1,11 @@# Generated by Django 1.11.26 on 2020-01-25 23:47from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def upgrade_stream_post_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def upgrade_stream_post_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Stream = apps.get_model("zerver", "Stream")Stream.STREAM_POST_POLICY_EVERYONE = 1Stream.STREAM_POST_POLICY_ADMINS = 2diff --git a/zerver/migrations/0273_migrate_old_bot_messages.py b/zerver/migrations/0273_migrate_old_bot_messages.pyindex e16287b2726..b148d519288 100644--- a/zerver/migrations/0273_migrate_old_bot_messages.py+++ b/zerver/migrations/0273_migrate_old_bot_messages.py@@ -2,11 +2,11 @@ from typing import Anyfrom django.conf import settingsfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def fix_messages(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_messages(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Conceptually, this migration cleans up the old NEW_USER_BOT and FEEDBACK_BOTUserProfile objects (their implementations were removed long ago).diff --git a/zerver/migrations/0277_migrate_alert_word.py b/zerver/migrations/0277_migrate_alert_word.pyindex f12a14a799e..19ddc10753f 100644--- a/zerver/migrations/0277_migrate_alert_word.py+++ b/zerver/migrations/0277_migrate_alert_word.py@@ -2,11 +2,11 @@ from typing import Dict, Listimport orjsonfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def move_to_seperate_table(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def move_to_seperate_table(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")AlertWord = apps.get_model("zerver", "AlertWord")@@ -24,7 +24,7 @@ def move_to_seperate_table(apps: StateApps, schema_editor: DatabaseSchemaEditor))-def move_back_to_user_profile(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def move_back_to_user_profile(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:AlertWord = apps.get_model("zerver", "AlertWord")UserProfile = apps.get_model("zerver", "UserProfile")diff --git a/zerver/migrations/0284_convert_realm_admins_to_realm_owners.py b/zerver/migrations/0284_convert_realm_admins_to_realm_owners.pyindex 5b70e6cabf7..92388e8d85f 100644--- a/zerver/migrations/0284_convert_realm_admins_to_realm_owners.py+++ b/zerver/migrations/0284_convert_realm_admins_to_realm_owners.py@@ -3,13 +3,15 @@ from typing import Any, Dictimport orjsonfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Countfrom django.utils.timezone import now as timezone_now-def set_realm_admins_as_realm_owners(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_realm_admins_as_realm_owners(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:UserProfile = apps.get_model("zerver", "UserProfile")RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")diff --git a/zerver/migrations/0285_remove_realm_google_hangouts_domain.py b/zerver/migrations/0285_remove_realm_google_hangouts_domain.pyindex 481de898021..18b24d6c98b 100644--- a/zerver/migrations/0285_remove_realm_google_hangouts_domain.py+++ b/zerver/migrations/0285_remove_realm_google_hangouts_domain.py@@ -1,7 +1,7 @@# Generated by Django 2.2.13 on 2020-06-14 01:58from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsVIDEO_CHAT_PROVIDERS = {@@ -16,7 +16,9 @@ VIDEO_CHAT_PROVIDERS = {}-def remove_google_hangouts_provider(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def remove_google_hangouts_provider(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:# We are removing the Google Hangout integration because Google has# removed the Hangouts brand. All the realms that used Hangouts as# their video chat provided are now set to the default, Jitsi.diff --git a/zerver/migrations/0287_clear_duplicate_reactions.py b/zerver/migrations/0287_clear_duplicate_reactions.pyindex 7ea82552dc4..e99e46207b1 100644--- a/zerver/migrations/0287_clear_duplicate_reactions.py+++ b/zerver/migrations/0287_clear_duplicate_reactions.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Count-def clear_duplicate_reactions(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def clear_duplicate_reactions(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""Zulip's data model for reactions has enforced via code,nontransactionally, that they can only react with one emoji_codefor a given reaction_type. This fixes any that were stored in thediff --git a/zerver/migrations/0290_remove_night_mode_add_color_scheme.py b/zerver/migrations/0290_remove_night_mode_add_color_scheme.pyindex 7723b3c0173..2acb55650b2 100644--- a/zerver/migrations/0290_remove_night_mode_add_color_scheme.py+++ b/zerver/migrations/0290_remove_night_mode_add_color_scheme.py@@ -1,14 +1,16 @@# Generated by Django 2.2.13 on 2020-06-20 15:22from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsCOLOR_SCHEME_AUTOMATIC = 1COLOR_SCHEME_NIGHT = 2# Set color_scheme to night mode, if night_mode is True.-def set_color_scheme_to_night_mode(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_color_scheme_to_night_mode(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.filter(night_mode=True).update(color_scheme=COLOR_SCHEME_NIGHT)diff --git a/zerver/migrations/0293_update_invite_as_dict_values.py b/zerver/migrations/0293_update_invite_as_dict_values.pyindex 1d635d5d7ae..d7e05a3bb6e 100644--- a/zerver/migrations/0293_update_invite_as_dict_values.py+++ b/zerver/migrations/0293_update_invite_as_dict_values.py@@ -1,11 +1,11 @@# Generated by Django 2.2.13 on 2020-06-21 21:13from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def update_invite_as_dict_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def update_invite_as_dict_values(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:PreregistrationUser = apps.get_model("zerver", "PreregistrationUser")MultiuseInvite = apps.get_model("zerver", "MultiuseInvite")diff --git a/zerver/migrations/0298_fix_realmauditlog_format.py b/zerver/migrations/0298_fix_realmauditlog_format.pyindex f0afa96f016..a9ab0a9d790 100644--- a/zerver/migrations/0298_fix_realmauditlog_format.py+++ b/zerver/migrations/0298_fix_realmauditlog_format.py@@ -3,11 +3,11 @@import jsonfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def update_realmauditlog_values(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def update_realmauditlog_values(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""This migration fixes two issues with the RealmAuditLog format for certain event types:* The notifications_stream and signup_notifications_stream fields had thediff --git a/zerver/migrations/0304_remove_default_status_of_default_private_streams.py b/zerver/migrations/0304_remove_default_status_of_default_private_streams.pyindex 3519f231093..b31e23de13d 100644--- a/zerver/migrations/0304_remove_default_status_of_default_private_streams.py+++ b/zerver/migrations/0304_remove_default_status_of_default_private_streams.py@@ -1,12 +1,12 @@# Generated by Django 2.2.14 on 2020-08-10 20:21from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef remove_default_status_of_default_private_streams(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:DefaultStream = apps.get_model("zerver", "DefaultStream")DefaultStream.objects.filter(stream__invite_only=True).delete()diff --git a/zerver/migrations/0313_finish_is_user_active_migration.py b/zerver/migrations/0313_finish_is_user_active_migration.pyindex 4f78dd41ea3..1024e4701e5 100644--- a/zerver/migrations/0313_finish_is_user_active_migration.py+++ b/zerver/migrations/0313_finish_is_user_active_migration.py@@ -2,11 +2,11 @@from django.contrib.postgres.operations import AddIndexConcurrentlyfrom django.db import connection, migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def backfill_is_user_active(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_is_user_active(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Subscription = apps.get_model("zerver", "Subscription")BATCH_SIZE = 1000lower_id_bound = 0diff --git a/zerver/migrations/0317_migrate_to_invite_to_realm_policy.py b/zerver/migrations/0317_migrate_to_invite_to_realm_policy.pyindex 438cbd3fae4..30a8f09e016 100644--- a/zerver/migrations/0317_migrate_to_invite_to_realm_policy.py+++ b/zerver/migrations/0317_migrate_to_invite_to_realm_policy.py@@ -1,11 +1,13 @@# Generated by Django 3.1.7 on 2021-04-01 19:27from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def migrate_to_invite_to_realm_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def migrate_to_invite_to_realm_policy(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:Realm = apps.get_model("zerver", "Realm")Realm.INVITE_TO_REALM_POLICY_MEMBERS_ONLY = 1Realm.INVITE_TO_REALM_POLICY_ADMINS_ONLY = 2diff --git a/zerver/migrations/0322_realm_create_audit_log_backfill.py b/zerver/migrations/0322_realm_create_audit_log_backfill.pyindex 6f703bdf7c9..2f49a3369b1 100644--- a/zerver/migrations/0322_realm_create_audit_log_backfill.py+++ b/zerver/migrations/0322_realm_create_audit_log_backfill.py@@ -1,12 +1,12 @@# Generated by Django 3.1.8 on 2021-04-20 10:09from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef backfill_realm_creation_log_events(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.REALM_CREATED = 215@@ -25,7 +25,7 @@ def backfill_realm_creation_log_events(RealmAuditLog.objects.bulk_create(objects_to_create)-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.REALM_CREATED = 215RealmAuditLog.objects.filter(event_type=RealmAuditLog.REALM_CREATED, backfilled=True).delete()diff --git a/zerver/migrations/0323_show_starred_message_counts.py b/zerver/migrations/0323_show_starred_message_counts.pyindex b5788cad6a4..8eb5949f430 100644--- a/zerver/migrations/0323_show_starred_message_counts.py+++ b/zerver/migrations/0323_show_starred_message_counts.py@@ -1,12 +1,14 @@# Generated by Django 3.1.8 on 2021-05-01 12:34from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# Set starred_message_count for already existing users to True.-def set_starred_message_count_to_true(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_starred_message_count_to_true(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:UserProfile = apps.get_model("zerver", "UserProfile")UserProfile.objects.filter(starred_message_counts=False).update(starred_message_counts=True)diff --git a/zerver/migrations/0328_migrate_to_edit_topic_policy.py b/zerver/migrations/0328_migrate_to_edit_topic_policy.pyindex 8ed74de7694..cf4b485d2f8 100644--- a/zerver/migrations/0328_migrate_to_edit_topic_policy.py+++ b/zerver/migrations/0328_migrate_to_edit_topic_policy.py@@ -1,11 +1,11 @@# Generated by Django 3.2.2 on 2021-05-26 09:43from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def migrate_to_edit_topic_policy(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def migrate_to_edit_topic_policy(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.POLICY_EVERYONE = 5Realm.POLICY_ADMINS_ONLY = 2@@ -18,7 +18,7 @@ def migrate_to_edit_topic_policy(apps: StateApps, schema_editor: DatabaseSchemaEdef reverse_migrate_to_edit_topic_policy(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.POLICY_EVERYONE = 5diff --git a/zerver/migrations/0333_alter_realm_org_type.py b/zerver/migrations/0333_alter_realm_org_type.pyindex f14e3e15137..df6f29e692f 100644--- a/zerver/migrations/0333_alter_realm_org_type.py+++ b/zerver/migrations/0333_alter_realm_org_type.py@@ -1,11 +1,11 @@# Generated by Django 3.2.4 on 2021-07-06 20:34from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def reset_realm_org_type(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reset_realm_org_type(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UNSPECIFIED = 0Realm = apps.get_model("zerver", "Realm")Realm.objects.all().update(org_type=UNSPECIFIED)diff --git a/zerver/migrations/0338_migrate_to_add_custom_emoji_policy.py b/zerver/migrations/0338_migrate_to_add_custom_emoji_policy.pyindex 1ebf4b557c2..43a6b36017a 100644--- a/zerver/migrations/0338_migrate_to_add_custom_emoji_policy.py+++ b/zerver/migrations/0338_migrate_to_add_custom_emoji_policy.py@@ -1,12 +1,12 @@# Generated by Django 3.2.2 on 2021-05-15 18:01from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef migrate_to_add_custom_emoji_policy(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.ADD_CUSTOM_EMOJI_MEMBERS_ONLY = 1@@ -20,7 +20,7 @@ def migrate_to_add_custom_emoji_policy(def reverse_migrate_to_add_custom_emoji_policy(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.ADD_CUSTOM_EMOJI_MEMBERS_ONLY = 1diff --git a/zerver/migrations/0345_alter_realm_name.py b/zerver/migrations/0345_alter_realm_name.pyindex 541804c0c12..a6c8f52b906 100644--- a/zerver/migrations/0345_alter_realm_name.py+++ b/zerver/migrations/0345_alter_realm_name.py@@ -2,11 +2,11 @@from django.conf import settingsfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def rename_system_bot_realm(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def rename_system_bot_realm(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:# Prior to this migration, the system bot realm had name incorrectly set to null.Realm = apps.get_model("zerver", "Realm")Realm.objects.filter(name=None, string_id=settings.SYSTEM_BOT_REALM).update(diff --git a/zerver/migrations/0346_create_realm_user_default_table.py b/zerver/migrations/0346_create_realm_user_default_table.pyindex 12f245ae989..5f41a819c98 100644--- a/zerver/migrations/0346_create_realm_user_default_table.py+++ b/zerver/migrations/0346_create_realm_user_default_table.py@@ -1,11 +1,13 @@# Generated by Django 3.2.2 on 2021-06-01 16:19from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def create_realm_user_default_table(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def create_realm_user_default_table(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:Realm = apps.get_model("zerver", "Realm")RealmUserDefault = apps.get_model("zerver", "RealmUserDefault")realms = Realm.objects.all()diff --git a/zerver/migrations/0352_migrate_twenty_four_hour_time_to_realmuserdefault.py b/zerver/migrations/0352_migrate_twenty_four_hour_time_to_realmuserdefault.pyindex d77ca078797..f50c543462c 100644--- a/zerver/migrations/0352_migrate_twenty_four_hour_time_to_realmuserdefault.py+++ b/zerver/migrations/0352_migrate_twenty_four_hour_time_to_realmuserdefault.py@@ -1,13 +1,13 @@# Generated by Django 3.2.6 on 2021-09-17 17:08from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Fdef migrate_twenty_four_hour_time_to_realmuserdefault(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmUserDefault = apps.get_model("zerver", "RealmUserDefault")realm_user_default_objects = RealmUserDefault.objects.exclude(@@ -20,7 +20,7 @@ def migrate_twenty_four_hour_time_to_realmuserdefault(def reverse_migrate_twenty_four_hour_time_to_realmuserdefault(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmUserDefault = apps.get_model("zerver", "RealmUserDefault")realm_user_default_objects = RealmUserDefault.objects.exclude(diff --git a/zerver/migrations/0354_alter_realm_message_content_delete_limit_seconds.py b/zerver/migrations/0354_alter_realm_message_content_delete_limit_seconds.pyindex 1f50b286eaf..17aaaad4028 100644--- a/zerver/migrations/0354_alter_realm_message_content_delete_limit_seconds.py+++ b/zerver/migrations/0354_alter_realm_message_content_delete_limit_seconds.py@@ -1,12 +1,12 @@# Generated by Django 3.2.4 on 2021-06-14 12:12from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef make_zero_invalid_for_message_delete_limit(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.DEFAULT_MESSAGE_CONTENT_DELETE_LIMIT_SECONDS = 600@@ -23,7 +23,7 @@ def make_zero_invalid_for_message_delete_limit(def reverse_make_zero_invalid_for_message_delete_limit(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.DEFAULT_MESSAGE_CONTENT_DELETE_LIMIT_SECONDS = 600diff --git a/zerver/migrations/0356_migrate_to_delete_own_message_policy.py b/zerver/migrations/0356_migrate_to_delete_own_message_policy.pyindex 653bb6cbbe8..ce8aa8614ba 100644--- a/zerver/migrations/0356_migrate_to_delete_own_message_policy.py+++ b/zerver/migrations/0356_migrate_to_delete_own_message_policy.py@@ -1,12 +1,12 @@# Generated by Django 3.2.4 on 2021-06-09 10:02from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef migrate_to_delete_own_message_policy(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.POLICY_EVERYONE = 5diff --git a/zerver/migrations/0358_split_create_stream_policy.py b/zerver/migrations/0358_split_create_stream_policy.pyindex c420a7f8751..506b9b6e71e 100644--- a/zerver/migrations/0358_split_create_stream_policy.py+++ b/zerver/migrations/0358_split_create_stream_policy.py@@ -1,10 +1,10 @@from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import F-def copy_stream_policy_field(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def copy_stream_policy_field(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.objects.all().update(create_public_stream_policy=F("create_stream_policy"))Realm.objects.all().update(create_private_stream_policy=F("create_stream_policy"))@@ -15,7 +15,7 @@ def copy_stream_policy_field(apps: StateApps, schema_editor: DatabaseSchemaEdito# but in most cases downgrades that would reverse migrations happen# before any real usage, so it's very likely that both values are# identical.-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Realm.objects.all().update(create_stream_policy=F("create_public_stream_policy"))diff --git a/zerver/migrations/0359_re2_linkifiers.py b/zerver/migrations/0359_re2_linkifiers.pyindex 7c7449dae5b..775856f82fd 100644--- a/zerver/migrations/0359_re2_linkifiers.py+++ b/zerver/migrations/0359_re2_linkifiers.py@@ -1,10 +1,10 @@import re2from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def delete_re2_invalid(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def delete_re2_invalid(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:options = re2.Options()options.log_errors = Falsediff --git a/zerver/migrations/0371_invalid_characters_in_topics.py b/zerver/migrations/0371_invalid_characters_in_topics.pyindex ed27b8a4daf..590b1f56c24 100644--- a/zerver/migrations/0371_invalid_characters_in_topics.py+++ b/zerver/migrations/0371_invalid_characters_in_topics.py@@ -1,7 +1,7 @@import unicodedatafrom django.db import connection, migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# There are 66 Unicode non-characters; see@@ -18,7 +18,7 @@ def character_is_printable(character: str) -> bool:return not (unicodedata.category(character) in ["Cc", "Cs"] or character in unicode_non_chars)-def fix_topics(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_topics(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Message = apps.get_model("zerver", "Message")BATCH_SIZE = 10000messages_updated = 0diff --git a/zerver/migrations/0373_fix_deleteduser_dummies.py b/zerver/migrations/0373_fix_deleteduser_dummies.pyindex 7d214fb0108..18f062d856a 100644--- a/zerver/migrations/0373_fix_deleteduser_dummies.py+++ b/zerver/migrations/0373_fix_deleteduser_dummies.py@@ -4,7 +4,7 @@ from django.conf import settingsfrom django.core.exceptions import ValidationErrorfrom django.core.validators import validate_emailfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps@@ -40,7 +40,7 @@ def get_fake_email_domain(realm: Any) -> str:return settings.FAKE_EMAIL_DOMAIN-def fix_dummy_users(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_dummy_users(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""do_delete_users had two bugs:1. Creating the replacement dummy users with active=Truediff --git a/zerver/migrations/0374_backfill_user_delete_realmauditlog.py b/zerver/migrations/0374_backfill_user_delete_realmauditlog.pyindex 3235c920db7..0e3e3e83c34 100644--- a/zerver/migrations/0374_backfill_user_delete_realmauditlog.py+++ b/zerver/migrations/0374_backfill_user_delete_realmauditlog.py@@ -1,9 +1,9 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def backfill_user_deleted_logs(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_user_deleted_logs(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.USER_DELETED = 106@@ -26,7 +26,7 @@ def backfill_user_deleted_logs(apps: StateApps, schema_editor: DatabaseSchemaEdiRealmAuditLog.objects.bulk_create(objects_to_create)-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RealmAuditLog = apps.get_model("zerver", "RealmAuditLog")RealmAuditLog.USER_DELETED = 106diff --git a/zerver/migrations/0375_invalid_characters_in_stream_names.py b/zerver/migrations/0375_invalid_characters_in_stream_names.pyindex 3d2803eec11..c440b1167cd 100644--- a/zerver/migrations/0375_invalid_characters_in_stream_names.py+++ b/zerver/migrations/0375_invalid_characters_in_stream_names.py@@ -1,7 +1,7 @@import unicodedatafrom django.db import connection, migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps# There are 66 Unicode non-characters; see@@ -18,7 +18,7 @@ def character_is_printable(character: str) -> bool:return not (unicodedata.category(character) in ["Cc", "Cs"] or character in unicode_non_chars)-def fix_stream_names(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_stream_names(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Stream = apps.get_model("zerver", "Stream")Realm = apps.get_model("zerver", "Realm")diff --git a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.pyindex 63f86a70d55..c3961242e5f 100644--- a/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py+++ b/zerver/migrations/0376_set_realmemoji_author_and_reupload_realmemoji.py@@ -1,9 +1,9 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def set_emoji_author(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def set_emoji_author(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""This migration establishes the invariant that all RealmEmoji objects have .author setand queues events for reuploading all RealmEmoji.diff --git a/zerver/migrations/0377_message_edit_history_format.py b/zerver/migrations/0377_message_edit_history_format.pyindex 223c4e325b5..8cc8c0aa252 100644--- a/zerver/migrations/0377_message_edit_history_format.py+++ b/zerver/migrations/0377_message_edit_history_format.py@@ -3,7 +3,7 @@ from typing import List, Optional, TypedDictimport orjsonfrom django.db import migrations, transaction-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Min, Model@@ -116,7 +116,7 @@ def backfill_message_edit_history_chunk(first_id: int, last_id: int, message_moddef copy_and_update_message_edit_history(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Message = apps.get_model("zerver", "Message")ArchivedMessage = apps.get_model("zerver", "ArchivedMessage")diff --git a/zerver/migrations/0380_userprofile_uuid_backfill.py b/zerver/migrations/0380_userprofile_uuid_backfill.pyindex a3d8df0e775..3f4c7a7df7c 100644--- a/zerver/migrations/0380_userprofile_uuid_backfill.py+++ b/zerver/migrations/0380_userprofile_uuid_backfill.py@@ -1,11 +1,11 @@import uuidfrom django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateApps-def backfill_user_profile_uuid(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def backfill_user_profile_uuid(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:UserProfile = apps.get_model("zerver", "UserProfile")max_id = UserProfile.objects.aggregate(models.Max("id"))["id__max"]diff --git a/zerver/migrations/0382_create_role_based_system_groups.py b/zerver/migrations/0382_create_role_based_system_groups.pyindex 1120bb7c1c6..a0a4f67639a 100644--- a/zerver/migrations/0382_create_role_based_system_groups.py+++ b/zerver/migrations/0382_create_role_based_system_groups.py@@ -1,12 +1,14 @@# Generated by Django 3.2.7 on 2021-10-16 12:41from django.db import migrations, transaction-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.utils.timezone import now as timezone_now-def create_role_based_system_groups(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def create_role_based_system_groups(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:Realm = apps.get_model("zerver", "Realm")UserProfile = apps.get_model("zerver", "UserProfile")UserGroup = apps.get_model("zerver", "UserGroup")@@ -118,7 +120,9 @@ def create_role_based_system_groups(apps: StateApps, schema_editor: DatabaseScheUserGroupMembership.objects.bulk_create(group_membership_objects)-def delete_role_based_system_groups(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def delete_role_based_system_groups(+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor+) -> None:UserGroup = apps.get_model("zerver", "UserGroup")GroupGroupMembership = apps.get_model("zerver", "GroupGroupMembership")UserGroupMembership = apps.get_model("zerver", "UserGroupMembership")diff --git a/zerver/migrations/0383_revoke_invitations_from_deactivated_users.py b/zerver/migrations/0383_revoke_invitations_from_deactivated_users.pyindex 736c98524f1..6461d254a2b 100644--- a/zerver/migrations/0383_revoke_invitations_from_deactivated_users.py+++ b/zerver/migrations/0383_revoke_invitations_from_deactivated_users.py@@ -1,12 +1,12 @@from typing import Listfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.utils.timezone import now as timezone_now-def revoke_invitations(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def revoke_invitations(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Realm = apps.get_model("zerver", "Realm")Confirmation = apps.get_model("confirmation", "Confirmation")Confirmation.INVITATION = 2diff --git a/zerver/migrations/0386_fix_attachment_caches.py b/zerver/migrations/0386_fix_attachment_caches.pyindex 1ffe92f9856..27c9af78e10 100644--- a/zerver/migrations/0386_fix_attachment_caches.py+++ b/zerver/migrations/0386_fix_attachment_caches.py@@ -1,12 +1,12 @@# Generated by Django 3.2.12 on 2022-03-23 04:32from django.db import migrations, models-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom django.db.models import Exists, Model, OuterRef-def fix_attachment_caches(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def fix_attachment_caches(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Attachment = apps.get_model("zerver", "Attachment")ArchivedAttachment = apps.get_model("zerver", "ArchivedAttachment")Message = apps.get_model("zerver", "Message")diff --git a/zerver/migrations/0387_reupload_realmemoji_again.py b/zerver/migrations/0387_reupload_realmemoji_again.pyindex afd830a5ffe..28c9e7e8c6a 100644--- a/zerver/migrations/0387_reupload_realmemoji_again.py+++ b/zerver/migrations/0387_reupload_realmemoji_again.py@@ -1,12 +1,12 @@from django.conf import settingsfrom django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsfrom zerver.lib.queue import queue_json_publish-def reupload_realm_emoji(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reupload_realm_emoji(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:"""As detailed in https://github.com/zulip/zulip/issues/21608, it ispossible for the deferred_work queue from Zulip 4.x to have beenstarted up by puppet during the deployment before migrations werediff --git a/zerver/migrations/0390_fix_stream_history_public_to_subscribers.py b/zerver/migrations/0390_fix_stream_history_public_to_subscribers.pyindex b22ca5edd96..e1250ae93ef 100644--- a/zerver/migrations/0390_fix_stream_history_public_to_subscribers.py+++ b/zerver/migrations/0390_fix_stream_history_public_to_subscribers.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef fix_stream_history_public_to_subscribers(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:Stream = apps.get_model("zerver", "Stream")Stream.objects.filter(diff --git a/zilencer/migrations/0022_remotezulipserver_create_audit_log_backfill.py b/zilencer/migrations/0022_remotezulipserver_create_audit_log_backfill.pyindex f6ec6bddd04..8c58511d756 100644--- a/zilencer/migrations/0022_remotezulipserver_create_audit_log_backfill.py+++ b/zilencer/migrations/0022_remotezulipserver_create_audit_log_backfill.py@@ -1,10 +1,10 @@from django.db import migrations-from django.db.backends.postgresql.schema import DatabaseSchemaEditor+from django.db.backends.postgresql.schema import BaseDatabaseSchemaEditorfrom django.db.migrations.state import StateAppsdef backfill_remote_zulip_server_creation_log_events(- apps: StateApps, schema_editor: DatabaseSchemaEditor+ apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RemoteZulipServer = apps.get_model("zilencer", "RemoteZulipServer")RemoteZulipServerAuditLog = apps.get_model("zilencer", "RemoteZulipServerAuditLog")@@ -22,7 +22,7 @@ def backfill_remote_zulip_server_creation_log_events(RemoteZulipServerAuditLog.objects.bulk_create(objects_to_create)-def reverse_code(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None:+def reverse_code(apps: StateApps, schema_editor: BaseDatabaseSchemaEditor) -> None:RemoteZulipServerAuditLog = apps.get_model("zilencer", "RemoteZulipServerAuditLog")RemoteZulipServerAuditLog.REMOTE_SERVER_CREATED = 10215RemoteZulipServerAuditLog.objects.filter(