zulip/zerver/migrations/0001_squashed_0569.py

3409 lines
147 KiB
Python

# Generated by Django 5.0.7 on 2024-08-17 01:15
import datetime
import uuid
import bitfield.models
import django.contrib.auth.models
import django.contrib.postgres.indexes
import django.contrib.postgres.search
import django.core.serializers.json
import django.core.validators
import django.db.models.deletion
import django.db.models.functions.text
import django.utils.timezone
from django.conf import settings
from django.db import migrations, models
import zerver.lib.utils
import zerver.models.linkifiers
import zerver.models.realms
import zerver.models.streams
def get_fts_sql() -> str:
if settings.POSTGRESQL_MISSING_DICTIONARIES:
fts_sql = """
CREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english);
"""
else:
fts_sql = """
CREATE TEXT SEARCH DICTIONARY english_us_hunspell
(template = ispell, DictFile = en_us, AffFile = en_us, StopWords = zulip_english);
CREATE TEXT SEARCH CONFIGURATION zulip.english_us_search (COPY=pg_catalog.english);
ALTER TEXT SEARCH CONFIGURATION zulip.english_us_search
ALTER MAPPING FOR asciiword, asciihword, hword_asciipart, word, hword, hword_part
WITH english_us_hunspell, english_stem;
"""
fts_sql += """
CREATE FUNCTION escape_html(text) RETURNS text IMMUTABLE LANGUAGE 'sql' AS $$
SELECT replace(replace(replace(replace(replace($1, '&', '&amp;'), '<', '&lt;'),
'>', '&gt;'), '"', '&quot;'), '''', '&#39;');
$$ ;
CREATE TABLE fts_update_log (id BIGSERIAL PRIMARY KEY, message_id INTEGER NOT NULL);
CREATE FUNCTION do_notify_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS
$$ BEGIN NOTIFY fts_update_log; RETURN NEW; END $$;
CREATE TRIGGER fts_update_log_notify AFTER INSERT ON fts_update_log
FOR EACH STATEMENT EXECUTE PROCEDURE do_notify_fts_update_log();
CREATE FUNCTION append_to_fts_update_log() RETURNS trigger LANGUAGE plpgsql AS
$$ BEGIN INSERT INTO fts_update_log (message_id) VALUES (NEW.id); RETURN NEW; END $$;
CREATE TRIGGER zerver_message_update_search_tsvector_async
BEFORE INSERT OR UPDATE OF subject, rendered_content ON zerver_message
FOR EACH ROW EXECUTE PROCEDURE append_to_fts_update_log();
"""
return fts_sql
class Migration(migrations.Migration):
initial = True
replaces = [
("zerver", "0001_initial"),
("zerver", "0029_realm_subdomain"),
("zerver", "0030_realm_org_type"),
("zerver", "0031_remove_system_avatar_source"),
("zerver", "0032_verify_all_medium_avatar_images"),
("zerver", "0033_migrate_domain_to_realmalias"),
("zerver", "0034_userprofile_enable_online_push_notifications"),
("zerver", "0035_realm_message_retention_period_days"),
("zerver", "0036_rename_subdomain_to_string_id"),
("zerver", "0037_disallow_null_string_id"),
("zerver", "0038_realm_change_to_community_defaults"),
("zerver", "0039_realmalias_drop_uniqueness"),
("zerver", "0040_realm_authentication_methods"),
("zerver", "0041_create_attachments_for_old_messages"),
("zerver", "0042_attachment_file_name_length"),
("zerver", "0043_realm_filter_validators"),
("zerver", "0044_reaction"),
("zerver", "0045_realm_waiting_period_threshold"),
("zerver", "0046_realmemoji_author"),
("zerver", "0047_realm_add_emoji_by_admins_only"),
("zerver", "0048_enter_sends_default_to_false"),
("zerver", "0049_userprofile_pm_content_in_desktop_notifications"),
("zerver", "0050_userprofile_avatar_version"),
("zerver", "0051_realmalias_add_allow_subdomains"),
("zerver", "0052_auto_fix_realmalias_realm_nullable"),
("zerver", "0053_emailchangestatus"),
("zerver", "0054_realm_icon"),
("zerver", "0055_attachment_size"),
("zerver", "0056_userprofile_emoji_alt_code"),
("zerver", "0057_realmauditlog"),
("zerver", "0058_realm_email_changes_disabled"),
("zerver", "0059_userprofile_quota"),
("zerver", "0060_move_avatars_to_be_uid_based"),
("zerver", "0061_userprofile_timezone"),
("zerver", "0062_default_timezone"),
("zerver", "0063_realm_description"),
("zerver", "0064_sync_uploads_filesize_with_db"),
("zerver", "0065_realm_inline_image_preview"),
("zerver", "0066_realm_inline_url_embed_preview"),
("zerver", "0067_archived_models"),
("zerver", "0068_remove_realm_domain"),
("zerver", "0069_realmauditlog_extra_data"),
("zerver", "0070_userhotspot"),
("zerver", "0071_rename_realmalias_to_realmdomain"),
("zerver", "0072_realmauditlog_add_index_event_time"),
("zerver", "0073_custom_profile_fields"),
("zerver", "0074_fix_duplicate_attachments"),
("zerver", "0075_attachment_path_id_unique"),
("zerver", "0076_userprofile_emojiset"),
("zerver", "0077_add_file_name_field_to_realm_emoji"),
("zerver", "0078_service"),
("zerver", "0079_remove_old_scheduled_jobs"),
("zerver", "0080_realm_description_length"),
("zerver", "0081_make_emoji_lowercase"),
("zerver", "0082_index_starred_user_messages"),
("zerver", "0083_index_mentioned_user_messages"),
("zerver", "0084_realmemoji_deactivated"),
("zerver", "0085_fix_bots_with_none_bot_type"),
("zerver", "0086_realm_alter_default_org_type"),
("zerver", "0087_remove_old_scheduled_jobs"),
("zerver", "0088_remove_referral_and_invites"),
("zerver", "0089_auto_20170710_1353"),
("zerver", "0090_userprofile_high_contrast_mode"),
("zerver", "0091_realm_allow_edit_history"),
("zerver", "0092_create_scheduledemail"),
("zerver", "0093_subscription_event_log_backfill"),
("zerver", "0094_realm_filter_url_validator"),
("zerver", "0095_index_unread_user_messages"),
("zerver", "0096_add_password_required"),
("zerver", "0097_reactions_emoji_code"),
("zerver", "0098_index_has_alert_word_user_messages"),
("zerver", "0099_index_wildcard_mentioned_user_messages"),
("zerver", "0100_usermessage_remove_is_me_message"),
("zerver", "0101_muted_topic"),
("zerver", "0102_convert_muted_topic"),
("zerver", "0103_remove_userprofile_muted_topics"),
("zerver", "0104_fix_unreads"),
("zerver", "0105_userprofile_enable_stream_push_notifications"),
("zerver", "0106_subscription_push_notifications"),
("zerver", "0107_multiuseinvite"),
("zerver", "0108_fix_default_string_id"),
("zerver", "0109_mark_tutorial_status_finished"),
("zerver", "0110_stream_is_in_zephyr_realm"),
("zerver", "0111_botuserstatedata"),
("zerver", "0112_index_muted_topics"),
("zerver", "0113_default_stream_group"),
("zerver", "0114_preregistrationuser_invited_as_admin"),
("zerver", "0115_user_groups"),
("zerver", "0116_realm_allow_message_deleting"),
("zerver", "0117_add_desc_to_user_group"),
("zerver", "0118_defaultstreamgroup_description"),
("zerver", "0119_userprofile_night_mode"),
("zerver", "0120_botuserconfigdata"),
("zerver", "0121_realm_signup_notifications_stream"),
("zerver", "0122_rename_botuserstatedata_botstoragedata"),
("zerver", "0123_userprofile_make_realm_email_pair_unique"),
("zerver", "0124_stream_enable_notifications"),
("zerver", "0125_realm_max_invites"),
("zerver", "0126_prereg_remove_users_without_realm"),
("zerver", "0127_disallow_chars_in_stream_and_user_name"),
("zerver", "0128_scheduledemail_realm"),
("zerver", "0129_remove_userprofile_autoscroll_forever"),
("zerver", "0130_text_choice_in_emojiset"),
("zerver", "0131_realm_create_generic_bot_by_admins_only"),
("zerver", "0132_realm_message_visibility_limit"),
("zerver", "0133_rename_botuserconfigdata_botconfigdata"),
("zerver", "0134_scheduledmessage"),
("zerver", "0135_scheduledmessage_delivery_type"),
("zerver", "0136_remove_userprofile_quota"),
("zerver", "0137_realm_upload_quota_gb"),
("zerver", "0138_userprofile_realm_name_in_notifications"),
("zerver", "0139_fill_last_message_id_in_subscription_logs"),
("zerver", "0140_realm_send_welcome_emails"),
("zerver", "0141_change_usergroup_description_to_textfield"),
("zerver", "0142_userprofile_translate_emoticons"),
("zerver", "0143_realm_bot_creation_policy"),
("zerver", "0144_remove_realm_create_generic_bot_by_admins_only"),
("zerver", "0145_reactions_realm_emoji_name_to_id"),
("zerver", "0146_userprofile_message_content_in_email_notifications"),
("zerver", "0147_realm_disallow_disposable_email_addresses"),
("zerver", "0148_max_invites_forget_default"),
("zerver", "0149_realm_emoji_drop_unique_constraint"),
("zerver", "0150_realm_allow_community_topic_editing"),
("zerver", "0151_last_reminder_default_none"),
("zerver", "0152_realm_default_twenty_four_hour_time"),
("zerver", "0153_remove_int_float_custom_fields"),
("zerver", "0154_fix_invalid_bot_owner"),
("zerver", "0155_change_default_realm_description"),
("zerver", "0156_add_hint_to_profile_field"),
("zerver", "0157_userprofile_is_guest"),
("zerver", "0158_realm_video_chat_provider"),
("zerver", "0159_realm_google_hangouts_domain"),
("zerver", "0160_add_choice_field"),
("zerver", "0161_realm_message_content_delete_limit_seconds"),
("zerver", "0162_change_default_community_topic_editing"),
("zerver", "0163_remove_userprofile_default_desktop_notifications"),
("zerver", "0164_stream_history_public_to_subscribers"),
("zerver", "0165_add_date_to_profile_field"),
("zerver", "0166_add_url_to_profile_field"),
("zerver", "0167_custom_profile_fields_sort_order"),
("zerver", "0168_stream_is_web_public"),
("zerver", "0169_stream_is_announcement_only"),
("zerver", "0170_submessage"),
("zerver", "0171_userprofile_dense_mode"),
("zerver", "0172_add_user_type_of_custom_profile_field"),
("zerver", "0173_support_seat_based_plans"),
("zerver", "0174_userprofile_delivery_email"),
("zerver", "0175_change_realm_audit_log_event_type_tense"),
("zerver", "0176_remove_subscription_notifications"),
("zerver", "0177_user_message_add_and_index_is_private_flag"),
("zerver", "0178_rename_to_emails_restricted_to_domains"),
("zerver", "0179_rename_to_digest_emails_enabled"),
("zerver", "0180_usermessage_add_active_mobile_push_notification"),
("zerver", "0181_userprofile_change_emojiset"),
("zerver", "0182_set_initial_value_is_private_flag"),
("zerver", "0183_change_custom_field_name_max_length"),
("zerver", "0184_rename_custom_field_types"),
("zerver", "0185_realm_plan_type"),
("zerver", "0186_userprofile_starred_message_counts"),
("zerver", "0187_userprofile_is_billing_admin"),
("zerver", "0188_userprofile_enable_login_emails"),
("zerver", "0189_userprofile_add_some_emojisets"),
("zerver", "0190_cleanup_pushdevicetoken"),
("zerver", "0191_realm_seat_limit"),
("zerver", "0192_customprofilefieldvalue_rendered_value"),
("zerver", "0193_realm_email_address_visibility"),
("zerver", "0194_userprofile_notification_sound"),
("zerver", "0195_realm_first_visible_message_id"),
("zerver", "0196_add_realm_logo_fields"),
("zerver", "0197_azure_active_directory_auth"),
("zerver", "0198_preregistrationuser_invited_as"),
("zerver", "0199_userstatus"),
("zerver", "0200_remove_preregistrationuser_invited_as_admin"),
("zerver", "0201_zoom_video_chat"),
("zerver", "0202_add_user_status_info"),
("zerver", "0203_realm_message_content_allowed_in_email_notifications"),
("zerver", "0204_remove_realm_billing_fields"),
("zerver", "0205_remove_realmauditlog_requires_billing_update"),
("zerver", "0206_stream_rendered_description"),
("zerver", "0207_multiuseinvite_invited_as"),
("zerver", "0208_add_realm_night_logo_fields"),
("zerver", "0209_stream_first_message_id"),
("zerver", "0210_stream_first_message_id"),
("zerver", "0211_add_users_field_to_scheduled_email"),
("zerver", "0212_make_stream_email_token_unique"),
("zerver", "0213_realm_digest_weekday"),
("zerver", "0214_realm_invite_to_stream_policy"),
("zerver", "0215_realm_avatar_changes_disabled"),
("zerver", "0216_add_create_stream_policy"),
("zerver", "0217_migrate_create_stream_policy"),
("zerver", "0218_remove_create_stream_by_admins_only"),
("zerver", "0219_toggle_realm_digest_emails_enabled_default"),
("zerver", "0220_subscription_notification_settings"),
("zerver", "0221_subscription_notifications_data_migration"),
("zerver", "0222_userprofile_fluid_layout_width"),
("zerver", "0223_rename_to_is_muted"),
("zerver", "0224_alter_field_realm_video_chat_provider"),
("zerver", "0225_archived_reaction_model"),
("zerver", "0226_archived_submessage_model"),
("zerver", "0227_inline_url_embed_preview_default_off"),
("zerver", "0228_userprofile_demote_inactive_streams"),
("zerver", "0229_stream_message_retention_days"),
("zerver", "0230_rename_to_enable_stream_audible_notifications"),
("zerver", "0231_add_archive_transaction_model"),
("zerver", "0232_make_archive_transaction_field_not_nullable"),
("zerver", "0233_userprofile_avatar_hash"),
("zerver", "0234_add_external_account_custom_profile_field"),
("zerver", "0235_userprofile_desktop_icon_count_display"),
("zerver", "0236_remove_illegal_characters_email_full"),
("zerver", "0237_rename_zulip_realm_to_zulipinternal"),
("zerver", "0238_usermessage_bigint_id"),
("zerver", "0239_usermessage_copy_id_to_bigint_id"),
("zerver", "0240_usermessage_migrate_bigint_id_into_id"),
("zerver", "0241_usermessage_bigint_id_migration_finalize"),
("zerver", "0242_fix_bot_email_property"),
("zerver", "0243_message_add_date_sent_column"),
("zerver", "0244_message_copy_pub_date_to_date_sent"),
("zerver", "0245_message_date_sent_finalize_part1"),
("zerver", "0246_message_date_sent_finalize_part2"),
("zerver", "0247_realmauditlog_event_type_to_int"),
("zerver", "0248_userprofile_role_start"),
("zerver", "0249_userprofile_role_finish"),
("zerver", "0250_saml_auth"),
("zerver", "0251_prereg_user_add_full_name"),
("zerver", "0252_realm_user_group_edit_policy"),
("zerver", "0253_userprofile_wildcard_mentions_notify"),
("zerver", "0209_user_profile_no_empty_password"),
("zerver", "0254_merge_0209_0253"),
("zerver", "0255_userprofile_stream_add_recipient_column"),
("zerver", "0256_userprofile_stream_set_recipient_column_values"),
("zerver", "0257_fix_has_link_attribute"),
("zerver", "0258_enable_online_push_notifications_default"),
("zerver", "0259_missedmessageemailaddress"),
("zerver", "0260_missed_message_addresses_from_redis_to_db"),
("zerver", "0261_realm_private_message_policy"),
("zerver", "0262_mutedtopic_date_muted"),
("zerver", "0263_stream_stream_post_policy"),
("zerver", "0264_migrate_is_announcement_only"),
("zerver", "0265_remove_stream_is_announcement_only"),
("zerver", "0266_userpresence_realm"),
("zerver", "0267_backfill_userpresence_realm_id"),
("zerver", "0268_add_userpresence_realm_timestamp_index"),
("zerver", "0269_gitlab_auth"),
("zerver", "0270_huddle_recipient"),
("zerver", "0271_huddle_set_recipient_column_values"),
("zerver", "0272_realm_default_code_block_language"),
("zerver", "0273_migrate_old_bot_messages"),
("zerver", "0274_nullbooleanfield_to_booleanfield"),
("zerver", "0275_remove_userprofile_last_pointer_updater"),
("zerver", "0276_alertword"),
("zerver", "0277_migrate_alert_word"),
("zerver", "0278_remove_userprofile_alert_words"),
("zerver", "0279_message_recipient_subject_indexes"),
("zerver", "0280_userprofile_presence_enabled"),
("zerver", "0281_zoom_oauth"),
("zerver", "0282_remove_zoom_video_chat"),
("zerver", "0283_apple_auth"),
("zerver", "0284_convert_realm_admins_to_realm_owners"),
("zerver", "0285_remove_realm_google_hangouts_domain"),
("zerver", "0261_pregistrationuser_clear_invited_as_admin"),
("zerver", "0286_merge_0260_0285"),
("zerver", "0287_clear_duplicate_reactions"),
("zerver", "0288_reaction_unique_on_emoji_code"),
("zerver", "0289_tighten_attachment_size"),
("zerver", "0290_remove_night_mode_add_color_scheme"),
("zerver", "0291_realm_retention_days_not_null"),
("zerver", "0292_update_default_value_of_invited_as"),
("zerver", "0293_update_invite_as_dict_values"),
("zerver", "0294_remove_userprofile_pointer"),
("zerver", "0295_case_insensitive_email_indexes"),
("zerver", "0296_remove_userprofile_short_name"),
("zerver", "0297_draft"),
("zerver", "0298_fix_realmauditlog_format"),
("zerver", "0299_subscription_role"),
("zerver", "0300_add_attachment_is_web_public"),
("zerver", "0301_fix_unread_messages_in_deactivated_streams"),
("zerver", "0302_case_insensitive_stream_name_index"),
("zerver", "0303_realm_wildcard_mention_policy"),
("zerver", "0304_remove_default_status_of_default_private_streams"),
("zerver", "0305_realm_deactivated_redirect"),
("zerver", "0306_custom_profile_field_date_format"),
("zerver", "0307_rename_api_super_user_to_can_forge_sender"),
("zerver", "0308_remove_reduntant_realm_meta_permissions"),
("zerver", "0309_userprofile_can_create_users"),
("zerver", "0310_jsonfield"),
("zerver", "0311_userprofile_default_view"),
("zerver", "0312_subscription_is_user_active"),
("zerver", "0313_finish_is_user_active_migration"),
("zerver", "0314_muted_user"),
("zerver", "0315_realmplayground"),
("zerver", "0316_realm_invite_to_realm_policy"),
("zerver", "0317_migrate_to_invite_to_realm_policy"),
("zerver", "0318_remove_realm_invite_by_admins_only"),
("zerver", "0319_realm_giphy_rating"),
("zerver", "0320_realm_move_messages_between_streams_policy"),
("zerver", "0321_userprofile_enable_marketing_emails"),
("zerver", "0322_realm_create_audit_log_backfill"),
("zerver", "0323_show_starred_message_counts"),
("zerver", "0324_fix_deletion_cascade_behavior"),
("zerver", "0325_alter_realmplayground_unique_together"),
("zerver", "0359_re2_linkifiers"),
("zerver", "0326_alter_realm_authentication_methods"),
("zerver", "0327_realm_edit_topic_policy"),
("zerver", "0328_migrate_to_edit_topic_policy"),
("zerver", "0329_remove_realm_allow_community_topic_editing"),
("zerver", "0330_linkifier_pattern_validator"),
("zerver", "0331_scheduledmessagenotificationemail"),
("zerver", "0332_realmuserdefault"),
("zerver", "0333_alter_realm_org_type"),
("zerver", "0334_email_notifications_batching_period"),
("zerver", "0335_add_draft_sync_field"),
("zerver", "0336_userstatus_status_emoji"),
("zerver", "0337_realm_add_custom_emoji_policy"),
("zerver", "0338_migrate_to_add_custom_emoji_policy"),
("zerver", "0339_remove_realm_add_emoji_by_admins_only"),
("zerver", "0340_rename_mutedtopic_to_usertopic"),
("zerver", "0341_usergroup_is_system_group"),
("zerver", "0342_realm_demo_organization_scheduled_deletion_date"),
("zerver", "0343_alter_useractivityinterval_index_together"),
("zerver", "0344_alter_emojiset_default_value"),
("zerver", "0345_alter_realm_name"),
("zerver", "0346_create_realm_user_default_table"),
("zerver", "0347_realm_emoji_animated"),
("zerver", "0348_rename_date_muted_usertopic_last_updated"),
("zerver", "0349_alter_usertopic_table"),
("zerver", "0350_usertopic_visibility_policy"),
("zerver", "0351_user_topic_visibility_indexes"),
("zerver", "0352_migrate_twenty_four_hour_time_to_realmuserdefault"),
("zerver", "0353_remove_realm_default_twenty_four_hour_time"),
("zerver", "0354_alter_realm_message_content_delete_limit_seconds"),
("zerver", "0355_realm_delete_own_message_policy"),
("zerver", "0356_migrate_to_delete_own_message_policy"),
("zerver", "0357_remove_realm_allow_message_deleting"),
("zerver", "0358_split_create_stream_policy"),
("zerver", "0360_merge_0358_0359"),
("zerver", "0361_realm_create_web_public_stream_policy"),
("zerver", "0362_send_typing_notifications_user_setting"),
("zerver", "0363_send_read_receipts_user_setting"),
("zerver", "0364_rename_members_usergroup_direct_members"),
("zerver", "0365_alter_user_group_related_fields"),
("zerver", "0366_group_group_membership"),
("zerver", "0367_scimclient"),
("zerver", "0368_alter_realmfilter_url_format_string"),
("zerver", "0369_add_escnav_default_display_user_setting"),
("zerver", "0370_realm_enable_spectator_access"),
("zerver", "0371_invalid_characters_in_topics"),
("zerver", "0372_realmemoji_unique_realm_emoji_when_false_deactivated"),
("zerver", "0373_fix_deleteduser_dummies"),
("zerver", "0374_backfill_user_delete_realmauditlog"),
("zerver", "0375_invalid_characters_in_stream_names"),
("zerver", "0376_set_realmemoji_author_and_reupload_realmemoji"),
("zerver", "0377_message_edit_history_format"),
("zerver", "0378_alter_realmuserdefault_realm"),
("zerver", "0379_userprofile_uuid"),
("zerver", "0380_userprofile_uuid_backfill"),
("zerver", "0381_alter_userprofile_uuid"),
("zerver", "0382_create_role_based_system_groups"),
("zerver", "0383_revoke_invitations_from_deactivated_users"),
("zerver", "0384_alter_realm_not_null"),
("zerver", "0385_attachment_flags_cache"),
("zerver", "0386_fix_attachment_caches"),
("zerver", "0387_reupload_realmemoji_again"),
("zerver", "0388_preregistrationuser_created_user"),
("zerver", "0389_userprofile_display_emoji_reaction_users"),
("zerver", "0390_fix_stream_history_public_to_subscribers"),
("zerver", "0391_alter_stream_history_public_to_subscribers"),
("zerver", "0392_non_nullable_fields"),
("zerver", "0393_realm_want_advertise_in_communities_directory"),
("zerver", "0394_alter_realm_want_advertise_in_communities_directory"),
("zerver", "0395_alter_realm_wildcard_mention_policy"),
("zerver", "0396_remove_subscription_role"),
("zerver", "0397_remove_custom_field_values_for_deleted_options"),
("zerver", "0398_tsvector_statistics"),
("zerver", "0399_preregistrationuser_multiuse_invite"),
("zerver", "0400_realmreactivationstatus"),
("zerver", "0401_migrate_old_realm_reactivation_links"),
("zerver", "0402_alter_usertopic_visibility_policy"),
("zerver", "0403_create_role_based_groups_for_internal_realms"),
("zerver", "0404_realm_enable_read_receipts"),
("zerver", "0405_set_default_for_enable_read_receipts"),
("zerver", "0406_alter_realm_message_content_edit_limit_seconds"),
("zerver", "0407_userprofile_user_list_style"),
("zerver", "0408_stream_can_remove_subscribers_group"),
("zerver", "0409_set_default_for_can_remove_subscribers_group"),
("zerver", "0410_alter_stream_can_remove_subscribers_group"),
("zerver", "0411_alter_muteduser_muted_user_and_more"),
("zerver", "0412_customprofilefield_display_in_profile_summary"),
("zerver", "0413_set_presence_enabled_false_for_user_status_away"),
("zerver", "0414_remove_userstatus_status"),
("zerver", "0415_delete_scimclient"),
("zerver", "0416_set_default_emoji_style"),
("zerver", "0417_alter_customprofilefield_field_type"),
("zerver", "0418_archivedmessage_realm_message_realm"),
("zerver", "0419_backfill_message_realm"),
("zerver", "0420_alter_archivedmessage_realm_alter_message_realm"),
("zerver", "0421_migrate_pronouns_custom_profile_fields"),
("zerver", "0422_multiuseinvite_status"),
("zerver", "0423_fix_email_gateway_attachment_owner"),
("zerver", "0424_realm_move_messages_within_stream_limit_seconds"),
("zerver", "0425_realm_move_messages_between_streams_limit_seconds"),
("zerver", "0426_add_email_address_visibility_setting"),
("zerver", "0427_migrate_to_user_level_email_address_visibility_setting"),
("zerver", "0428_remove_realm_email_address_visibility"),
("zerver", "0429_user_topic_case_insensitive_unique_toghether"),
("zerver", "0430_fix_audit_log_objects_for_group_based_stream_settings"),
("zerver", "0431_alter_archivedreaction_unique_together_and_more"),
("zerver", "0432_alter_and_migrate_realm_name_in_notifications"),
("zerver", "0433_preregistrationrealm"),
("zerver", "0434_create_nobody_system_group"),
("zerver", "0435_scheduledmessage_rendered_content"),
("zerver", "0436_realmauthenticationmethods"),
("zerver", "0437_remove_realm_authentication_methods"),
("zerver", "0438_add_web_mark_read_on_scroll_policy_setting"),
("zerver", "0439_fix_deleteduser_email"),
("zerver", "0440_realmfilter_url_template"),
("zerver", "0441_backfill_realmfilter_url_template"),
("zerver", "0442_remove_realmfilter_url_format_string"),
("zerver", "0443_userpresence_new_table_schema"),
("zerver", "0444_userpresence_fill_data"),
("zerver", "0445_drop_userpresenceold"),
("zerver", "0446_realmauditlog_zerver_realmauditlog_user_subscriptions_idx"),
("zerver", "0447_attachment_scheduled_messages_and_more"),
("zerver", "0448_scheduledmessage_new_fields"),
("zerver", "0449_scheduledmessage_zerver_unsent_scheduled_messages_indexes"),
("zerver", "0450_backfill_subscription_auditlogs"),
("zerver", "0451_add_userprofile_api_key_index"),
("zerver", "0452_realmauditlog_extra_data_json"),
("zerver", "0453_followed_topic_notifications"),
("zerver", "0454_usergroup_can_mention_group"),
("zerver", "0455_set_default_for_can_mention_group"),
("zerver", "0456_alter_usergroup_can_mention_group"),
("zerver", "0457_backfill_scheduledmessagenotificationemail_trigger"),
("zerver", "0458_realmauditlog_modified_user_group"),
("zerver", "0459_remove_invalid_characters_from_user_group_name"),
("zerver", "0460_backfill_realmauditlog_extradata_to_json_field"),
("zerver", "0461_alter_realm_default_code_block_language"),
("zerver", "0462_realmplayground_url_template"),
("zerver", "0463_backfill_realmplayground_url_template"),
("zerver", "0464_remove_realmplayground_url_prefix"),
("zerver", "0465_backfill_scheduledmessagenotificationemail_trigger"),
("zerver", "0466_realmfilter_order"),
("zerver", "0467_rename_extradata_realmauditlog_extra_data_json"),
("zerver", "0468_rename_followup_day_email_templates"),
("zerver", "0469_realm_create_multiuse_invite_group"),
("zerver", "0470_set_default_value_for_create_multiuse_invite_group"),
("zerver", "0471_alter_realm_create_multiuse_invite_group"),
("zerver", "0472_add_message_realm_id_indexes"),
("zerver", "0473_remove_message_non_realm_id_indexes"),
("zerver", "0474_realmuserdefault_web_stream_unreads_count_display_policy_and_more"),
("zerver", "0475_realm_jitsi_server_url"),
("zerver", "0476_realmuserdefault_automatically_follow_topics_policy_and_more"),
("zerver", "0477_alter_realmuserdefault_automatically_follow_topics_policy_and_more"),
("zerver", "0478_realm_enable_guest_user_indicator"),
("zerver", "0479_realm_uuid_realm_uuid_owner_secret"),
("zerver", "0480_realm_backfill_uuid_and_secret"),
("zerver", "0481_alter_realm_uuid_alter_realm_uuid_owner_secret"),
("zerver", "0482_automatically_follow_unmute_topics_policy_defaults"),
(
"zerver",
"0483_rename_escape_navigates_to_default_view_realmuserdefault_web_escape_navigates_to_home_view_and_more",
),
("zerver", "0484_preregistrationrealm_default_language"),
("zerver", "0485_alter_usermessage_flags_and_add_index"),
("zerver", "0486_clear_old_data_for_unused_usermessage_flags"),
("zerver", "0487_realm_can_access_all_users_group"),
("zerver", "0488_set_default_value_for_can_access_all_users_group"),
("zerver", "0489_alter_realm_can_access_all_users_group"),
("zerver", "0490_renumber_options_desktop_icon_count_display"),
("zerver", "0491_alter_realmuserdefault_web_home_view_and_more"),
("zerver", "0492_realm_push_notifications_enabled_and_more"),
("zerver", "0493_rename_userhotspot_to_onboardingstep"),
("zerver", "0494_realmuserdefault_automatically_follow_topics_where_mentioned_and_more"),
("zerver", "0495_scheduledmessage_read_by_sender"),
("zerver", "0496_alter_scheduledmessage_read_by_sender"),
("zerver", "0501_delete_dangling_usermessages"),
("zerver", "0517_resort_edit_history"),
("zerver", "0497_resort_edit_history"),
("zerver", "0498_rename_notifications_stream_realm_new_stream_announcements_stream"),
("zerver", "0499_rename_signup_notifications_stream_realm_signup_announcements_stream"),
("zerver", "0500_realm_zulip_update_announcements_stream"),
("zerver", "0501_mark_introduce_zulip_view_modals_as_read"),
("zerver", "0502_merge_20240319_2236"),
("zerver", "0503_realm_zulip_update_announcements_level"),
("zerver", "0504_customprofilefield_required"),
("zerver", "0505_realmuserdefault_web_font_size_px_and_more"),
("zerver", "0506_realm_require_unique_names"),
("zerver", "0507_rework_realm_upload_quota_gb"),
("zerver", "0508_realmuserdefault_receives_typing_notifications_and_more"),
("zerver", "0509_fix_emoji_metadata"),
("zerver", "0510_add_realmauditlog_realm_event_type_index"),
("zerver", "0511_stream_creator"),
("zerver", "0512_namedusergroup"),
("zerver", "0513_copy_groups_data_to_named_user_group"),
("zerver", "0514_update_usergroup_foreign_keys_to_namedusergroup"),
(
"zerver",
"0515_rename_named_group_can_mention_group_namedusergroup_can_mention_group_and_more",
),
("zerver", "0516_fix_confirmation_preregistrationusers"),
("zerver", "0518_merge"),
("zerver", "0519_archivetransaction_restored_timestamp"),
("zerver", "0520_attachment_zerver_attachment_realm_create_time"),
("zerver", "0521_multiuseinvite_include_realm_default_subscriptions_and_more"),
("zerver", "0522_set_include_realm_default_subscriptions_for_existing_objects"),
("zerver", "0523_alter_multiuseinvite_subscribe_to_default_streams_and_more"),
("zerver", "0524_remove_userprofile_onboarding_steps"),
("zerver", "0525_userpresence_last_update_id"),
("zerver", "0526_user_presence_backfill_last_update_id_to_0"),
("zerver", "0527_presencesequence"),
("zerver", "0528_realmauditlog_zerver_realmauditlog_user_activations_idx"),
("zerver", "0529_fts_bigint_id"),
("zerver", "0530_alter_useractivity_id_alter_useractivityinterval_id"),
("zerver", "0531_convert_most_ids_to_bigints"),
("zerver", "0532_realm_can_create_public_channel_group"),
("zerver", "0533_set_can_create_public_channel_group"),
("zerver", "0534_alter_realm_can_create_public_channel_group"),
("zerver", "0535_remove_realm_create_public_stream_policy"),
("zerver", "0536_add_message_type"),
("zerver", "0537_realm_can_create_private_channel_group"),
("zerver", "0538_set_can_create_private_channel_group"),
("zerver", "0539_alter_realm_can_create_private_channel_group"),
("zerver", "0540_remove_realm_create_private_stream_policy"),
("zerver", "0541_alter_realmauditlog_options"),
("zerver", "0542_onboardingusermessage"),
("zerver", "0543_preregistrationuser_notify_referrer_on_join"),
("zerver", "0544_copy_avatar_images"),
("zerver", "0545_attachment_content_type"),
("zerver", "0546_rename_huddle_directmessagegroup_and_more"),
("zerver", "0547_realmuserdefault_web_navigate_to_sent_message_and_more"),
("zerver", "0548_realmuserdefault_web_channel_default_view_and_more"),
("zerver", "0549_realm_direct_message_initiator_group_and_more"),
("zerver", "0550_set_default_value_for_realm_direct_message_initiator_group_and_more"),
("zerver", "0551_alter_realm_direct_message_initiator_group_and_more"),
("zerver", "0552_remove_realm_private_message_policy"),
("zerver", "0553_copy_emoji_images"),
("zerver", "0554_imageattachment"),
("zerver", "0555_alter_onboardingstep_onboarding_step"),
("zerver", "0556_alter_realmuserdefault_dense_mode_and_more"),
("zerver", "0557_change_information_density_defaults"),
("zerver", "0558_realmuserdefault_web_animate_image_previews_and_more"),
("zerver", "0559_realm_can_create_web_public_channel_group"),
("zerver", "0560_set_can_create_web_public_channel_group"),
("zerver", "0561_alter_realm_can_create_web_public_channel_group"),
("zerver", "0562_remove_realm_create_web_public_stream_policy"),
("zerver", "0563_zulipinternal_can_delete"),
("zerver", "0564_purge_nagios_messages"),
("zerver", "0565_realm_can_delete_any_message_group"),
("zerver", "0566_set_default_for_can_delete_any_message_group"),
("zerver", "0567_alter_realm_can_delete_any_message_group"),
("zerver", "0568_mark_narrow_to_dm_with_welcome_bot_new_user_as_read"),
("zerver", "0569_remove_userprofile_tutorial_status"),
]
dependencies = [
("auth", "0001_initial"),
]
operations = [
migrations.CreateModel(
name="ArchiveTransaction",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"timestamp",
models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
("restored", models.BooleanField(db_index=True, default=False)),
("restored_timestamp", models.DateTimeField(db_index=True, null=True)),
("type", models.PositiveSmallIntegerField(db_index=True)),
],
),
migrations.CreateModel(
name="Client",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(db_index=True, max_length=30, unique=True)),
],
),
migrations.CreateModel(
name="UserGroup",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
],
),
migrations.CreateModel(
name="Realm",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=40)),
("description", models.TextField(default="")),
("string_id", models.CharField(max_length=40, unique=True)),
("uuid", models.UUIDField(default=uuid.uuid4, unique=True)),
(
"uuid_owner_secret",
models.TextField(default=zerver.models.realms.generate_realm_uuid_owner_secret),
),
("push_notifications_enabled", models.BooleanField(db_index=True, default=False)),
(
"push_notifications_enabled_end_timestamp",
models.DateTimeField(default=None, null=True),
),
("date_created", models.DateTimeField(default=django.utils.timezone.now)),
(
"demo_organization_scheduled_deletion_date",
models.DateTimeField(default=None, null=True),
),
("deactivated", models.BooleanField(default=False)),
("deactivated_redirect", models.URLField(max_length=128, null=True)),
("emails_restricted_to_domains", models.BooleanField(default=False)),
("invite_required", models.BooleanField(default=True)),
("_max_invites", models.IntegerField(db_column="max_invites", null=True)),
("disallow_disposable_email_addresses", models.BooleanField(default=True)),
("enable_spectator_access", models.BooleanField(default=False)),
(
"want_advertise_in_communities_directory",
models.BooleanField(db_index=True, default=False),
),
("inline_image_preview", models.BooleanField(default=True)),
("inline_url_embed_preview", models.BooleanField(default=False)),
("digest_emails_enabled", models.BooleanField(default=False)),
("digest_weekday", models.SmallIntegerField(default=1)),
("send_welcome_emails", models.BooleanField(default=True)),
(
"message_content_allowed_in_email_notifications",
models.BooleanField(default=True),
),
("mandatory_topics", models.BooleanField(default=False)),
("require_unique_names", models.BooleanField(default=False)),
("name_changes_disabled", models.BooleanField(default=False)),
("email_changes_disabled", models.BooleanField(default=False)),
("avatar_changes_disabled", models.BooleanField(default=False)),
(
"move_messages_within_stream_limit_seconds",
models.PositiveIntegerField(default=604800, null=True),
),
(
"move_messages_between_streams_limit_seconds",
models.PositiveIntegerField(default=604800, null=True),
),
(
"add_custom_emoji_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.CommonPolicyEnum["MEMBERS_ONLY"]
),
),
(
"delete_own_message_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.CommonMessagePolicyEnum["EVERYONE"]
),
),
(
"edit_topic_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.EditTopicPolicyEnum["EVERYONE"]
),
),
(
"invite_to_realm_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.InviteToRealmPolicyEnum["MEMBERS_ONLY"]
),
),
(
"invite_to_stream_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.CommonPolicyEnum["MEMBERS_ONLY"]
),
),
(
"move_messages_between_streams_policy",
models.PositiveSmallIntegerField(default=1),
),
(
"user_group_edit_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.CommonPolicyEnum["MEMBERS_ONLY"]
),
),
(
"wildcard_mention_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.WildcardMentionPolicyEnum["ADMINS"]
),
),
("waiting_period_threshold", models.PositiveIntegerField(default=0)),
(
"message_content_delete_limit_seconds",
models.PositiveIntegerField(default=600, null=True),
),
("allow_message_editing", models.BooleanField(default=True)),
(
"message_content_edit_limit_seconds",
models.PositiveIntegerField(default=600, null=True),
),
("allow_edit_history", models.BooleanField(default=True)),
("default_language", models.CharField(default="en", max_length=50)),
("zulip_update_announcements_level", models.PositiveIntegerField(null=True)),
("message_retention_days", models.IntegerField(default=-1)),
("message_visibility_limit", models.IntegerField(null=True)),
("first_visible_message_id", models.IntegerField(default=0)),
(
"org_type",
models.PositiveSmallIntegerField(
choices=[
(0, "Unspecified"),
(10, "Business"),
(20, "Open-source project"),
(30, "Education (non-profit)"),
(35, "Education (for-profit)"),
(40, "Research"),
(50, "Event or conference"),
(60, "Non-profit (registered)"),
(70, "Government"),
(80, "Political group"),
(90, "Community"),
(100, "Personal"),
(1000, "Other"),
],
default=0,
),
),
("plan_type", models.PositiveSmallIntegerField(default=1)),
(
"bot_creation_policy",
models.PositiveSmallIntegerField(
default=zerver.models.realms.BotCreationPolicyEnum["EVERYONE"]
),
),
("custom_upload_quota_gb", models.IntegerField(null=True)),
("video_chat_provider", models.PositiveSmallIntegerField(default=1)),
("jitsi_server_url", models.URLField(default=None, null=True)),
("giphy_rating", models.PositiveSmallIntegerField(default=2)),
("default_code_block_language", models.TextField(default="")),
("enable_read_receipts", models.BooleanField(default=False)),
("enable_guest_user_indicator", models.BooleanField(default=True)),
(
"icon_source",
models.CharField(
choices=[("G", "Hosted by Gravatar"), ("U", "Uploaded by administrator")],
default="G",
max_length=1,
),
),
("icon_version", models.PositiveSmallIntegerField(default=1)),
(
"logo_source",
models.CharField(
choices=[("D", "Default to Zulip"), ("U", "Uploaded by administrator")],
default="D",
max_length=1,
),
),
("logo_version", models.PositiveSmallIntegerField(default=1)),
(
"night_logo_source",
models.CharField(
choices=[("D", "Default to Zulip"), ("U", "Uploaded by administrator")],
default="D",
max_length=1,
),
),
("night_logo_version", models.PositiveSmallIntegerField(default=1)),
],
),
migrations.CreateModel(
name="UserProfile",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("password", models.CharField(max_length=128, verbose_name="password")),
(
"last_login",
models.DateTimeField(blank=True, null=True, verbose_name="last login"),
),
(
"is_superuser",
models.BooleanField(
default=False,
help_text="Designates that this user has all permissions without explicitly assigning them.",
verbose_name="superuser status",
),
),
("enter_sends", models.BooleanField(default=False)),
("left_side_userlist", models.BooleanField(default=False)),
("default_language", models.CharField(default="en", max_length=50)),
("web_home_view", models.TextField(default="inbox")),
("web_escape_navigates_to_home_view", models.BooleanField(default=True)),
("fluid_layout_width", models.BooleanField(default=False)),
("high_contrast_mode", models.BooleanField(default=False)),
("translate_emoticons", models.BooleanField(default=False)),
("display_emoji_reaction_users", models.BooleanField(default=True)),
("twenty_four_hour_time", models.BooleanField(default=False)),
("starred_message_counts", models.BooleanField(default=True)),
("color_scheme", models.PositiveSmallIntegerField(default=1)),
("dense_mode", models.BooleanField(default=False)),
("web_font_size_px", models.PositiveSmallIntegerField(default=16)),
("web_line_height_percent", models.PositiveSmallIntegerField(default=140)),
("web_animate_image_previews", models.TextField(default="on_hover")),
("demote_inactive_streams", models.PositiveSmallIntegerField(default=1)),
("web_mark_read_on_scroll_policy", models.SmallIntegerField(default=1)),
("web_channel_default_view", models.SmallIntegerField(db_default=1, default=1)),
(
"emojiset",
models.CharField(
choices=[
("google", "Google"),
("twitter", "Twitter"),
("text", "Plain text"),
("google-blob", "Google blobs"),
],
default="google",
max_length=20,
),
),
("user_list_style", models.PositiveSmallIntegerField(default=2)),
(
"web_stream_unreads_count_display_policy",
models.PositiveSmallIntegerField(default=2),
),
("web_navigate_to_sent_message", models.BooleanField(default=True)),
("email_notifications_batching_period_seconds", models.IntegerField(default=120)),
("enable_stream_desktop_notifications", models.BooleanField(default=False)),
("enable_stream_email_notifications", models.BooleanField(default=False)),
("enable_stream_push_notifications", models.BooleanField(default=False)),
("enable_stream_audible_notifications", models.BooleanField(default=False)),
("notification_sound", models.CharField(default="zulip", max_length=20)),
("wildcard_mentions_notify", models.BooleanField(default=True)),
("enable_followed_topic_desktop_notifications", models.BooleanField(default=True)),
("enable_followed_topic_email_notifications", models.BooleanField(default=True)),
("enable_followed_topic_push_notifications", models.BooleanField(default=True)),
("enable_followed_topic_audible_notifications", models.BooleanField(default=True)),
(
"enable_followed_topic_wildcard_mentions_notify",
models.BooleanField(default=True),
),
("enable_desktop_notifications", models.BooleanField(default=True)),
("pm_content_in_desktop_notifications", models.BooleanField(default=True)),
("enable_sounds", models.BooleanField(default=True)),
("enable_offline_email_notifications", models.BooleanField(default=True)),
("message_content_in_email_notifications", models.BooleanField(default=True)),
("enable_offline_push_notifications", models.BooleanField(default=True)),
("enable_online_push_notifications", models.BooleanField(default=True)),
("desktop_icon_count_display", models.PositiveSmallIntegerField(default=1)),
("enable_digest_emails", models.BooleanField(default=True)),
("enable_login_emails", models.BooleanField(default=True)),
("enable_marketing_emails", models.BooleanField(default=True)),
("presence_enabled", models.BooleanField(default=True)),
(
"realm_name_in_email_notifications_policy",
models.PositiveSmallIntegerField(default=1),
),
("automatically_follow_topics_policy", models.PositiveSmallIntegerField(default=3)),
(
"automatically_unmute_topics_in_muted_streams_policy",
models.PositiveSmallIntegerField(default=2),
),
("automatically_follow_topics_where_mentioned", models.BooleanField(default=True)),
("enable_drafts_synchronization", models.BooleanField(default=True)),
("send_stream_typing_notifications", models.BooleanField(default=True)),
("send_private_typing_notifications", models.BooleanField(default=True)),
("send_read_receipts", models.BooleanField(default=True)),
("receives_typing_notifications", models.BooleanField(default=True)),
("email_address_visibility", models.PositiveSmallIntegerField(default=1)),
("delivery_email", models.EmailField(db_index=True, max_length=254)),
("email", models.EmailField(db_index=True, max_length=254)),
("full_name", models.CharField(max_length=100)),
("date_joined", models.DateTimeField(default=django.utils.timezone.now)),
("tos_version", models.CharField(max_length=10, null=True)),
(
"api_key",
models.CharField(
default=zerver.lib.utils.generate_api_key, max_length=32, unique=True
),
),
("uuid", models.UUIDField(default=uuid.uuid4, unique=True)),
("is_staff", models.BooleanField(default=False)),
("is_active", models.BooleanField(db_index=True, default=True)),
("is_billing_admin", models.BooleanField(db_index=True, default=False)),
("is_bot", models.BooleanField(db_index=True, default=False)),
("bot_type", models.PositiveSmallIntegerField(db_index=True, null=True)),
("role", models.PositiveSmallIntegerField(db_index=True, default=400)),
("long_term_idle", models.BooleanField(db_index=True, default=False)),
("last_active_message_id", models.IntegerField(null=True)),
("is_mirror_dummy", models.BooleanField(default=False)),
("can_forge_sender", models.BooleanField(db_index=True, default=False)),
("can_create_users", models.BooleanField(db_index=True, default=False)),
("last_reminder", models.DateTimeField(default=None, null=True)),
("rate_limits", models.CharField(default="", max_length=100)),
("default_all_public_streams", models.BooleanField(default=False)),
("timezone", models.CharField(default="", max_length=40)),
(
"avatar_source",
models.CharField(
choices=[("G", "Hosted by Gravatar"), ("U", "Uploaded by user")],
default="G",
max_length=1,
),
),
("avatar_version", models.PositiveSmallIntegerField(default=1)),
("avatar_hash", models.CharField(max_length=64, null=True)),
("zoom_token", models.JSONField(default=None, null=True)),
(
"bot_owner",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
(
"groups",
models.ManyToManyField(
blank=True,
help_text="The groups this user belongs to. A user will get all permissions granted to each of their groups.",
related_name="user_set",
related_query_name="user",
to="auth.group",
verbose_name="groups",
),
),
(
"user_permissions",
models.ManyToManyField(
blank=True,
help_text="Specific permissions for this user.",
related_name="user_set",
related_query_name="user",
to="auth.permission",
verbose_name="user permissions",
),
),
],
managers=[
("objects", django.contrib.auth.models.UserManager()),
],
),
migrations.CreateModel(
name="ArchivedMessage",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"type",
models.PositiveSmallIntegerField(
choices=[(1, "Normal"), (2, "Resolve Topic Notification")],
db_default=1,
default=1,
),
),
("subject", models.CharField(db_index=True, max_length=60)),
("content", models.TextField()),
("rendered_content", models.TextField(null=True)),
("rendered_content_version", models.IntegerField(null=True)),
("date_sent", models.DateTimeField(db_index=True, verbose_name="date sent")),
("last_edit_time", models.DateTimeField(null=True)),
("edit_history", models.TextField(null=True)),
("has_attachment", models.BooleanField(db_index=True, default=False)),
("has_image", models.BooleanField(db_index=True, default=False)),
("has_link", models.BooleanField(db_index=True, default=False)),
(
"sender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"archive_transaction",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.archivetransaction"
),
),
(
"sending_client",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.client"
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="ArchivedSubMessage",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("msg_type", models.TextField()),
("content", models.TextField()),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.archivedmessage"
),
),
(
"sender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Message",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"type",
models.PositiveSmallIntegerField(
choices=[(1, "Normal"), (2, "Resolve Topic Notification")],
db_default=1,
default=1,
),
),
("subject", models.CharField(db_index=True, max_length=60)),
("content", models.TextField()),
("rendered_content", models.TextField(null=True)),
("rendered_content_version", models.IntegerField(null=True)),
("date_sent", models.DateTimeField(db_index=True, verbose_name="date sent")),
("last_edit_time", models.DateTimeField(null=True)),
("edit_history", models.TextField(null=True)),
("has_attachment", models.BooleanField(db_index=True, default=False)),
("has_image", models.BooleanField(db_index=True, default=False)),
("has_link", models.BooleanField(db_index=True, default=False)),
("search_tsvector", django.contrib.postgres.search.SearchVectorField(null=True)),
(
"sender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"sending_client",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.client"
),
),
],
),
migrations.CreateModel(
name="MissedMessageEmailAddress",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("email_token", models.CharField(db_index=True, max_length=34, unique=True)),
(
"timestamp",
models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
("times_used", models.PositiveIntegerField(db_index=True, default=0)),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="NamedUserGroup",
fields=[
(
"usergroup_ptr",
models.OneToOneField(
auto_created=True,
on_delete=django.db.models.deletion.CASCADE,
parent_link=True,
primary_key=True,
related_name="named_user_group",
serialize=False,
to="zerver.usergroup",
),
),
("name", models.CharField(db_column="name", max_length=100)),
("description", models.TextField(db_column="description", default="")),
(
"is_system_group",
models.BooleanField(db_column="is_system_group", default=False),
),
],
bases=("zerver.usergroup",),
),
migrations.CreateModel(
name="GroupGroupMembership",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"supergroup",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="zerver.usergroup",
),
),
],
),
migrations.AddField(
model_name="usergroup",
name="realm",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"),
),
migrations.AddField(
model_name="realm",
name="can_access_all_users_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="can_create_private_channel_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="can_create_public_channel_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="can_create_web_public_channel_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="can_delete_any_message_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="create_multiuse_invite_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="direct_message_initiator_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="realm",
name="direct_message_permission_group",
field=models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT,
related_name="+",
to="zerver.usergroup",
),
),
migrations.CreateModel(
name="PresenceSequence",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("last_update_id", models.PositiveBigIntegerField()),
(
"realm",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.CreateModel(
name="PreregistrationRealm",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=40)),
(
"org_type",
models.PositiveSmallIntegerField(
choices=[
(0, "Unspecified"),
(10, "Business"),
(20, "Open-source project"),
(30, "Education (non-profit)"),
(35, "Education (for-profit)"),
(40, "Research"),
(50, "Event or conference"),
(60, "Non-profit (registered)"),
(70, "Government"),
(80, "Political group"),
(90, "Community"),
(100, "Personal"),
(1000, "Other"),
],
default=0,
),
),
("default_language", models.CharField(default="en", max_length=50)),
("string_id", models.CharField(max_length=40)),
("email", models.EmailField(max_length=254)),
("status", models.IntegerField(default=0)),
(
"created_user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"created_realm",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.realm",
),
),
],
),
migrations.CreateModel(
name="OnboardingUserMessage",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("flags", bitfield.models.BitField(["read", "historical", "starred"], default=0)),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.CreateModel(
name="MultiuseInvite",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("invited_as", models.PositiveSmallIntegerField(default=400)),
("include_realm_default_subscriptions", models.BooleanField(default=True)),
("status", models.IntegerField(default=0)),
(
"referred_by",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.AddField(
model_name="message",
name="realm",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"),
),
migrations.CreateModel(
name="ImageAttachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("path_id", models.TextField(db_index=True, unique=True)),
("original_width_px", models.IntegerField()),
("original_height_px", models.IntegerField()),
("frames", models.IntegerField()),
("thumbnail_metadata", models.JSONField(default=list)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.CreateModel(
name="EmailChangeStatus",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("new_email", models.EmailField(max_length=254)),
("old_email", models.EmailField(max_length=254)),
("updated_at", models.DateTimeField(auto_now=True)),
("status", models.IntegerField(default=0)),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.CreateModel(
name="CustomProfileField",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=40)),
("hint", models.CharField(default="", max_length=80)),
("order", models.IntegerField(default=0)),
("display_in_profile_summary", models.BooleanField(default=False)),
("required", models.BooleanField(default=False)),
(
"field_type",
models.PositiveSmallIntegerField(
choices=[
(4, "Date"),
(7, "External account"),
(5, "Link"),
(3, "List of options"),
(8, "Pronouns"),
(2, "Text (long)"),
(1, "Text (short)"),
(6, "Users"),
],
default=1,
),
),
("field_data", models.TextField(default="")),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("realm", "name")},
},
),
migrations.AddField(
model_name="archivetransaction",
name="realm",
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
migrations.AddField(
model_name="archivedmessage",
name="realm",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"),
),
migrations.CreateModel(
name="ArchivedAttachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("file_name", models.TextField(db_index=True)),
("path_id", models.TextField(db_index=True, unique=True)),
(
"create_time",
models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
("size", models.IntegerField()),
("content_type", models.TextField(null=True)),
("is_realm_public", models.BooleanField(default=False, null=True)),
("is_web_public", models.BooleanField(default=False, null=True)),
(
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"messages",
models.ManyToManyField(
related_name="attachment_set",
related_query_name="attachment",
to="zerver.archivedmessage",
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"abstract": False,
},
),
migrations.AddField(
model_name="userprofile",
name="realm",
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"),
),
migrations.CreateModel(
name="RealmReactivationStatus",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("status", models.IntegerField(default=0)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
),
migrations.CreateModel(
name="RealmUserDefault",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("enter_sends", models.BooleanField(default=False)),
("left_side_userlist", models.BooleanField(default=False)),
("default_language", models.CharField(default="en", max_length=50)),
("web_home_view", models.TextField(default="inbox")),
("web_escape_navigates_to_home_view", models.BooleanField(default=True)),
("fluid_layout_width", models.BooleanField(default=False)),
("high_contrast_mode", models.BooleanField(default=False)),
("translate_emoticons", models.BooleanField(default=False)),
("display_emoji_reaction_users", models.BooleanField(default=True)),
("twenty_four_hour_time", models.BooleanField(default=False)),
("starred_message_counts", models.BooleanField(default=True)),
("color_scheme", models.PositiveSmallIntegerField(default=1)),
("dense_mode", models.BooleanField(default=False)),
("web_font_size_px", models.PositiveSmallIntegerField(default=16)),
("web_line_height_percent", models.PositiveSmallIntegerField(default=140)),
("web_animate_image_previews", models.TextField(default="on_hover")),
("demote_inactive_streams", models.PositiveSmallIntegerField(default=1)),
("web_mark_read_on_scroll_policy", models.SmallIntegerField(default=1)),
("web_channel_default_view", models.SmallIntegerField(db_default=1, default=1)),
(
"emojiset",
models.CharField(
choices=[
("google", "Google"),
("twitter", "Twitter"),
("text", "Plain text"),
("google-blob", "Google blobs"),
],
default="google",
max_length=20,
),
),
("user_list_style", models.PositiveSmallIntegerField(default=2)),
(
"web_stream_unreads_count_display_policy",
models.PositiveSmallIntegerField(default=2),
),
("web_navigate_to_sent_message", models.BooleanField(default=True)),
("email_notifications_batching_period_seconds", models.IntegerField(default=120)),
("enable_stream_desktop_notifications", models.BooleanField(default=False)),
("enable_stream_email_notifications", models.BooleanField(default=False)),
("enable_stream_push_notifications", models.BooleanField(default=False)),
("enable_stream_audible_notifications", models.BooleanField(default=False)),
("notification_sound", models.CharField(default="zulip", max_length=20)),
("wildcard_mentions_notify", models.BooleanField(default=True)),
("enable_followed_topic_desktop_notifications", models.BooleanField(default=True)),
("enable_followed_topic_email_notifications", models.BooleanField(default=True)),
("enable_followed_topic_push_notifications", models.BooleanField(default=True)),
("enable_followed_topic_audible_notifications", models.BooleanField(default=True)),
(
"enable_followed_topic_wildcard_mentions_notify",
models.BooleanField(default=True),
),
("enable_desktop_notifications", models.BooleanField(default=True)),
("pm_content_in_desktop_notifications", models.BooleanField(default=True)),
("enable_sounds", models.BooleanField(default=True)),
("enable_offline_email_notifications", models.BooleanField(default=True)),
("message_content_in_email_notifications", models.BooleanField(default=True)),
("enable_offline_push_notifications", models.BooleanField(default=True)),
("enable_online_push_notifications", models.BooleanField(default=True)),
("desktop_icon_count_display", models.PositiveSmallIntegerField(default=1)),
("enable_digest_emails", models.BooleanField(default=True)),
("enable_login_emails", models.BooleanField(default=True)),
("enable_marketing_emails", models.BooleanField(default=True)),
("presence_enabled", models.BooleanField(default=True)),
(
"realm_name_in_email_notifications_policy",
models.PositiveSmallIntegerField(default=1),
),
("automatically_follow_topics_policy", models.PositiveSmallIntegerField(default=3)),
(
"automatically_unmute_topics_in_muted_streams_policy",
models.PositiveSmallIntegerField(default=2),
),
("automatically_follow_topics_where_mentioned", models.BooleanField(default=True)),
("enable_drafts_synchronization", models.BooleanField(default=True)),
("send_stream_typing_notifications", models.BooleanField(default=True)),
("send_private_typing_notifications", models.BooleanField(default=True)),
("send_read_receipts", models.BooleanField(default=True)),
("receives_typing_notifications", models.BooleanField(default=True)),
("email_address_visibility", models.PositiveSmallIntegerField(default=1)),
(
"realm",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Recipient",
fields=[
(
"id",
models.AutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("type_id", models.IntegerField(db_index=True)),
("type", models.PositiveSmallIntegerField(db_index=True)),
],
options={
"unique_together": {("type", "type_id")},
},
),
migrations.AddField(
model_name="message",
name="recipient",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.recipient"
),
),
migrations.CreateModel(
name="Draft",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("topic", models.CharField(db_index=True, max_length=60)),
("content", models.TextField()),
("last_edit_time", models.DateTimeField(db_index=True)),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"recipient",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="zerver.recipient",
),
),
],
),
migrations.CreateModel(
name="DirectMessageGroup",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("huddle_hash", models.CharField(db_index=True, max_length=40, unique=True)),
(
"recipient",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="zerver.recipient",
),
),
],
options={
"db_table": "zerver_huddle",
},
),
migrations.AddField(
model_name="archivedmessage",
name="recipient",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.recipient"
),
),
migrations.AddField(
model_name="userprofile",
name="recipient",
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.SET_NULL, to="zerver.recipient"
),
),
migrations.CreateModel(
name="ScheduledEmail",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("scheduled_timestamp", models.DateTimeField(db_index=True)),
("data", models.TextField()),
("address", models.EmailField(db_index=True, max_length=254, null=True)),
("type", models.PositiveSmallIntegerField()),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
("users", models.ManyToManyField(to=settings.AUTH_USER_MODEL)),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="ScheduledMessage",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("subject", models.CharField(max_length=60)),
("content", models.TextField()),
("rendered_content", models.TextField()),
("scheduled_timestamp", models.DateTimeField(db_index=True)),
("read_by_sender", models.BooleanField()),
("delivered", models.BooleanField(default=False)),
("has_attachment", models.BooleanField(db_index=True, default=False)),
("failed", models.BooleanField(default=False)),
("failure_message", models.TextField(null=True)),
(
"delivery_type",
models.PositiveSmallIntegerField(
choices=[(1, "send_later"), (2, "remind")], default=1
),
),
(
"delivered_message",
models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
(
"recipient",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.recipient"
),
),
(
"sender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"sending_client",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.client"
),
),
],
),
migrations.CreateModel(
name="Attachment",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("file_name", models.TextField(db_index=True)),
("path_id", models.TextField(db_index=True, unique=True)),
(
"create_time",
models.DateTimeField(db_index=True, default=django.utils.timezone.now),
),
("size", models.IntegerField()),
("content_type", models.TextField(null=True)),
("is_realm_public", models.BooleanField(default=False, null=True)),
("is_web_public", models.BooleanField(default=False, null=True)),
(
"owner",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
("messages", models.ManyToManyField(to="zerver.message")),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
("scheduled_messages", models.ManyToManyField(to="zerver.scheduledmessage")),
],
),
migrations.CreateModel(
name="Service",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=100)),
("base_url", models.TextField()),
("token", models.TextField()),
("interface", models.PositiveSmallIntegerField(default=1)),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="Stream",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(db_index=True, max_length=60)),
("date_created", models.DateTimeField(default=django.utils.timezone.now)),
("deactivated", models.BooleanField(default=False)),
("description", models.CharField(default="", max_length=1024)),
("rendered_description", models.TextField(default="")),
("invite_only", models.BooleanField(default=False)),
("history_public_to_subscribers", models.BooleanField(default=True)),
("is_web_public", models.BooleanField(default=False)),
("stream_post_policy", models.PositiveSmallIntegerField(default=1)),
("is_in_zephyr_realm", models.BooleanField(default=False)),
(
"email_token",
models.CharField(
default=zerver.models.streams.generate_email_token_for_stream,
max_length=32,
unique=True,
),
),
("message_retention_days", models.IntegerField(default=None, null=True)),
("first_message_id", models.IntegerField(db_index=True, null=True)),
(
"can_remove_subscribers_group",
models.ForeignKey(
on_delete=django.db.models.deletion.RESTRICT, to="zerver.usergroup"
),
),
(
"creator",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to=settings.AUTH_USER_MODEL,
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
(
"recipient",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="zerver.recipient",
),
),
],
),
migrations.AddField(
model_name="scheduledmessage",
name="stream",
field=models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.stream"
),
),
migrations.AddField(
model_name="realm",
name="new_stream_announcements_stream",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.stream",
),
),
migrations.AddField(
model_name="realm",
name="signup_announcements_stream",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.stream",
),
),
migrations.AddField(
model_name="realm",
name="zulip_update_announcements_stream",
field=models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.stream",
),
),
migrations.CreateModel(
name="PreregistrationUser",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("email", models.EmailField(max_length=254)),
("full_name", models.CharField(max_length=100, null=True)),
("full_name_validated", models.BooleanField(default=False)),
("notify_referrer_on_join", models.BooleanField(default=True)),
("invited_at", models.DateTimeField(auto_now=True)),
("realm_creation", models.BooleanField(default=False)),
("password_required", models.BooleanField(default=True)),
("status", models.IntegerField(default=0)),
("invited_as", models.PositiveSmallIntegerField(default=400)),
("include_realm_default_subscriptions", models.BooleanField(default=True)),
(
"created_user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"multiuse_invite",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
to="zerver.multiuseinvite",
),
),
(
"referred_by",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
(
"realm",
models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
("streams", models.ManyToManyField(to="zerver.stream")),
],
),
migrations.AddField(
model_name="multiuseinvite",
name="streams",
field=models.ManyToManyField(to="zerver.stream"),
),
migrations.CreateModel(
name="DefaultStreamGroup",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(db_index=True, max_length=60)),
("description", models.CharField(default="", max_length=1024)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
("streams", models.ManyToManyField(to="zerver.stream")),
],
),
migrations.CreateModel(
name="DefaultStream",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
(
"stream",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.stream"
),
),
],
),
migrations.AddField(
model_name="userprofile",
name="default_events_register_stream",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.stream",
),
),
migrations.AddField(
model_name="userprofile",
name="default_sending_stream",
field=models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.SET_NULL,
related_name="+",
to="zerver.stream",
),
),
migrations.CreateModel(
name="SubMessage",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("msg_type", models.TextField()),
("content", models.TextField()),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"sender",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="Subscription",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("active", models.BooleanField(default=True)),
("is_user_active", models.BooleanField()),
("is_muted", models.BooleanField(default=False)),
("color", models.CharField(default="#c2c2c2", max_length=10)),
("pin_to_top", models.BooleanField(default=False)),
("desktop_notifications", models.BooleanField(default=None, null=True)),
("audible_notifications", models.BooleanField(default=None, null=True)),
("push_notifications", models.BooleanField(default=None, null=True)),
("email_notifications", models.BooleanField(default=None, null=True)),
("wildcard_mentions_notify", models.BooleanField(default=None, null=True)),
(
"recipient",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.recipient"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="UserActivity",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("query", models.CharField(db_index=True, max_length=50)),
("count", models.IntegerField()),
("last_visit", models.DateTimeField(verbose_name="last visit")),
(
"client",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.client"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="UserActivityInterval",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("start", models.DateTimeField(db_index=True, verbose_name="start time")),
("end", models.DateTimeField(db_index=True, verbose_name="end time")),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="UserGroupMembership",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"user_group",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="zerver.usergroup",
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
],
),
migrations.AddField(
model_name="usergroup",
name="direct_members",
field=models.ManyToManyField(
related_name="direct_groups",
through="zerver.UserGroupMembership",
to=settings.AUTH_USER_MODEL,
),
),
migrations.CreateModel(
name="UserMessage",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
(
"flags",
bitfield.models.BitField(
[
"read",
"starred",
"collapsed",
"mentioned",
"stream_wildcard_mentioned",
"topic_wildcard_mentioned",
"group_mentioned",
"force_expand",
"force_collapse",
"has_alert_word",
"historical",
"is_private",
"active_mobile_push_notification",
],
default=0,
),
),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="UserPresence",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("last_update_id", models.PositiveBigIntegerField(db_index=True, default=0)),
(
"last_connected_time",
models.DateTimeField(
db_index=True, default=django.utils.timezone.now, null=True
),
),
(
"last_active_time",
models.DateTimeField(
db_index=True, default=django.utils.timezone.now, null=True
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
(
"user_profile",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="UserStatus",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"reaction_type",
models.CharField(
choices=[
("unicode_emoji", "Unicode emoji"),
("realm_emoji", "Custom emoji"),
("zulip_extra_emoji", "Zulip extra emoji"),
],
default="unicode_emoji",
max_length=30,
),
),
("timestamp", models.DateTimeField()),
("emoji_name", models.TextField(default="")),
("emoji_code", models.TextField(default="")),
("status_text", models.CharField(default="", max_length=255)),
(
"client",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.client"
),
),
(
"user_profile",
models.OneToOneField(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
},
),
migrations.CreateModel(
name="UserTopic",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("topic_name", models.CharField(max_length=60)),
(
"last_updated",
models.DateTimeField(
default=datetime.datetime(2020, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
),
),
(
"visibility_policy",
models.SmallIntegerField(
choices=[
(1, "Muted topic"),
(2, "Unmuted topic in muted stream"),
(3, "Followed topic"),
(0, "User's default policy for the stream."),
],
default=1,
),
),
(
"recipient",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.recipient"
),
),
(
"stream",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.stream"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
),
migrations.CreateModel(
name="ArchivedReaction",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("emoji_name", models.TextField()),
(
"reaction_type",
models.CharField(
choices=[
("unicode_emoji", "Unicode emoji"),
("realm_emoji", "Custom emoji"),
("zulip_extra_emoji", "Zulip extra emoji"),
],
default="unicode_emoji",
max_length=30,
),
),
("emoji_code", models.TextField()),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.archivedmessage"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
"unique_together": {("user_profile", "message", "reaction_type", "emoji_code")},
},
),
migrations.CreateModel(
name="ArchivedUserMessage",
fields=[
("id", models.BigAutoField(primary_key=True, serialize=False)),
(
"flags",
bitfield.models.BitField(
[
"read",
"starred",
"collapsed",
"mentioned",
"stream_wildcard_mentioned",
"topic_wildcard_mentioned",
"group_mentioned",
"force_expand",
"force_collapse",
"has_alert_word",
"historical",
"is_private",
"active_mobile_push_notification",
],
default=0,
),
),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.archivedmessage"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
"unique_together": {("user_profile", "message")},
},
),
migrations.CreateModel(
name="BotConfigData",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("key", models.TextField(db_index=True)),
("value", models.TextField()),
(
"bot_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"unique_together": {("bot_profile", "key")},
},
),
migrations.CreateModel(
name="BotStorageData",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("key", models.TextField(db_index=True)),
("value", models.TextField()),
(
"bot_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"unique_together": {("bot_profile", "key")},
},
),
migrations.CreateModel(
name="CustomProfileFieldValue",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("value", models.TextField()),
("rendered_value", models.TextField(default=None, null=True)),
(
"field",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.customprofilefield"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"unique_together": {("user_profile", "field")},
},
),
migrations.CreateModel(
name="MutedUser",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("date_muted", models.DateTimeField(default=django.utils.timezone.now)),
(
"muted_user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="muted",
to=settings.AUTH_USER_MODEL,
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="muter",
to=settings.AUTH_USER_MODEL,
),
),
],
options={
"unique_together": {("user_profile", "muted_user")},
},
),
migrations.AddField(
model_name="usergroup",
name="direct_subgroups",
field=models.ManyToManyField(
related_name="direct_supergroups",
through="zerver.GroupGroupMembership",
to="zerver.namedusergroup",
),
),
migrations.CreateModel(
name="ScheduledMessageNotificationEmail",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"trigger",
models.TextField(
choices=[
("direct_message", "Direct message"),
("mentioned", "Mention"),
("topic_wildcard_mentioned", "Topic wildcard mention"),
("stream_wildcard_mentioned", "Stream wildcard mention"),
("stream_email_notify", "Stream notifications enabled"),
("followed_topic_email_notify", "Followed topic notifications enabled"),
(
"topic_wildcard_mentioned_in_followed_topic",
"Topic wildcard mention in followed topic",
),
(
"stream_wildcard_mentioned_in_followed_topic",
"Stream wildcard mention in followed topic",
),
]
),
),
("scheduled_timestamp", models.DateTimeField(db_index=True)),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"mentioned_user_group",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="zerver.namedusergroup",
),
),
],
),
migrations.CreateModel(
name="RealmAuditLog",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("event_time", models.DateTimeField(db_index=True)),
("backfilled", models.BooleanField(default=False)),
(
"extra_data",
models.JSONField(
default=dict, encoder=django.core.serializers.json.DjangoJSONEncoder
),
),
("event_type", models.PositiveSmallIntegerField()),
("event_last_message_id", models.IntegerField(null=True)),
(
"acting_user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"modified_user",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to=settings.AUTH_USER_MODEL,
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
(
"modified_stream",
models.ForeignKey(
null=True, on_delete=django.db.models.deletion.CASCADE, to="zerver.stream"
),
),
(
"modified_user_group",
models.ForeignKey(
null=True,
on_delete=django.db.models.deletion.CASCADE,
to="zerver.namedusergroup",
),
),
],
options={
"ordering": ["id"],
},
),
migrations.AddField(
model_name="namedusergroup",
name="can_mention_group",
field=models.ForeignKey(
db_column="can_mention_group_id",
on_delete=django.db.models.deletion.RESTRICT,
to="zerver.usergroup",
),
),
migrations.AddField(
model_name="namedusergroup",
name="realm_for_sharding",
field=models.ForeignKey(
db_column="realm_id", on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
migrations.AddField(
model_name="groupgroupmembership",
name="subgroup",
field=models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE,
related_name="+",
to="zerver.namedusergroup",
),
),
migrations.CreateModel(
name="OnboardingStep",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("onboarding_step", models.CharField(max_length=40)),
("timestamp", models.DateTimeField(default=django.utils.timezone.now)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"unique_together": {("user", "onboarding_step")},
},
),
migrations.CreateModel(
name="PushDeviceToken",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("kind", models.PositiveSmallIntegerField(choices=[(1, "apns"), (2, "gcm")])),
("token", models.CharField(db_index=True, max_length=4096)),
("last_updated", models.DateTimeField(auto_now=True)),
("ios_app_id", models.TextField(null=True)),
(
"user",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"unique_together": {("user", "kind", "token")},
},
),
migrations.CreateModel(
name="Reaction",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("emoji_name", models.TextField()),
(
"reaction_type",
models.CharField(
choices=[
("unicode_emoji", "Unicode emoji"),
("realm_emoji", "Custom emoji"),
("zulip_extra_emoji", "Zulip extra emoji"),
],
default="unicode_emoji",
max_length=30,
),
),
("emoji_code", models.TextField()),
(
"message",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.message"
),
),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
],
options={
"abstract": False,
"unique_together": {("user_profile", "message", "reaction_type", "emoji_code")},
},
),
migrations.CreateModel(
name="AlertWord",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("word", models.TextField()),
(
"user_profile",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("user_profile", "word")},
},
),
migrations.CreateModel(
name="RealmAuthenticationMethod",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("name", models.CharField(max_length=80)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("realm", "name")},
},
),
migrations.CreateModel(
name="RealmDomain",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("domain", models.CharField(db_index=True, max_length=80)),
("allow_subdomains", models.BooleanField(default=False)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("realm", "domain")},
},
),
migrations.CreateModel(
name="RealmEmoji",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"name",
models.TextField(
validators=[
django.core.validators.MinLengthValidator(1),
django.core.validators.RegexValidator(
message="Invalid characters in emoji name",
regex="^[0-9a-z.\\-_]+(?<![.\\-_])$",
),
]
),
),
("file_name", models.TextField(blank=True, db_index=True, null=True)),
("is_animated", models.BooleanField(default=False)),
("deactivated", models.BooleanField(default=False)),
(
"author",
models.ForeignKey(
blank=True,
null=True,
on_delete=django.db.models.deletion.CASCADE,
to=settings.AUTH_USER_MODEL,
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"constraints": [
models.UniqueConstraint(
condition=models.Q(("deactivated", False)),
fields=("realm", "name"),
name="unique_realm_emoji_when_false_deactivated",
)
],
},
),
migrations.CreateModel(
name="RealmFilter",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
("pattern", models.TextField()),
(
"url_template",
models.TextField(validators=[zerver.models.linkifiers.url_template_validator]),
),
("order", models.IntegerField(default=0)),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("realm", "pattern")},
},
),
migrations.CreateModel(
name="RealmPlayground",
fields=[
(
"id",
models.BigAutoField(
auto_created=True, primary_key=True, serialize=False, verbose_name="ID"
),
),
(
"url_template",
models.TextField(validators=[zerver.models.linkifiers.url_template_validator]),
),
("name", models.TextField(db_index=True)),
(
"pygments_language",
models.CharField(
db_index=True,
max_length=40,
validators=[
django.core.validators.RegexValidator(
message="Invalid characters in pygments language",
regex="^[ a-zA-Z0-9_+-./#]*$",
)
],
),
),
(
"realm",
models.ForeignKey(
on_delete=django.db.models.deletion.CASCADE, to="zerver.realm"
),
),
],
options={
"unique_together": {("realm", "pygments_language", "name")},
},
),
migrations.AddIndex(
model_name="message",
index=django.contrib.postgres.indexes.GinIndex(
models.F("search_tsvector"), fastupdate=False, name="zerver_message_search_tsvector"
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.F("recipient_id"),
models.F("id"),
name="zerver_message_realm_recipient_id",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.F("recipient_id"),
models.F("date_sent"),
name="zerver_message_realm_recipient_date_sent",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.F("sender_id"),
models.F("recipient_id"),
name="zerver_message_realm_sender_recipient",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"), models.F("date_sent"), name="zerver_message_realm_date_sent"
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
django.db.models.functions.text.Upper("subject"),
models.OrderBy(models.F("id"), descending=True, nulls_last=True),
name="zerver_message_realm_upper_subject",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.F("recipient_id"),
django.db.models.functions.text.Upper("subject"),
models.OrderBy(models.F("id"), descending=True, nulls_last=True),
name="zerver_message_realm_recipient_upper_subject",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.F("recipient_id"),
models.F("subject"),
models.OrderBy(models.F("id"), descending=True, nulls_last=True),
name="zerver_message_realm_recipient_subject",
),
),
migrations.AddIndex(
model_name="message",
index=models.Index(
models.F("realm_id"),
models.OrderBy(models.F("id"), descending=True, nulls_last=True),
name="zerver_message_realm_id",
),
),
migrations.AddIndex(
model_name="attachment",
index=models.Index(
models.F("realm"),
models.F("create_time"),
name="zerver_attachment_realm_create_time",
),
),
migrations.AddIndex(
model_name="stream",
index=models.Index(
django.db.models.functions.text.Upper("name"), name="upper_stream_name_idx"
),
),
migrations.AddIndex(
model_name="scheduledmessage",
index=models.Index(
condition=models.Q(("delivered", False), ("failed", False)),
fields=["scheduled_timestamp"],
name="zerver_unsent_scheduled_messages_by_time",
),
),
migrations.AddIndex(
model_name="scheduledmessage",
index=models.Index(
condition=models.Q(("delivered", False)),
fields=["realm_id", "sender", "delivery_type", "scheduled_timestamp"],
name="zerver_realm_unsent_scheduled_messages_by_user",
),
),
migrations.AddIndex(
model_name="preregistrationuser",
index=models.Index(
django.db.models.functions.text.Upper("email"),
name="upper_preregistration_email_idx",
),
),
migrations.AlterUniqueTogether(
name="defaultstreamgroup",
unique_together={("realm", "name")},
),
migrations.AlterUniqueTogether(
name="defaultstream",
unique_together={("realm", "stream")},
),
migrations.AddIndex(
model_name="userprofile",
index=models.Index(
django.db.models.functions.text.Upper("email"), name="upper_userprofile_email_idx"
),
),
migrations.AddIndex(
model_name="subscription",
index=models.Index(
condition=models.Q(("active", True), ("is_user_active", True)),
fields=["recipient", "user_profile"],
name="zerver_subscription_recipient_id_user_profile_id_idx",
),
),
migrations.AlterUniqueTogether(
name="subscription",
unique_together={("user_profile", "recipient")},
),
migrations.AlterUniqueTogether(
name="useractivity",
unique_together={("user_profile", "client", "query")},
),
migrations.AddIndex(
model_name="useractivityinterval",
index=models.Index(
fields=["user_profile", "end"],
name="zerver_useractivityinterval_user_profile_id_end_bb3bfc37_idx",
),
),
migrations.AlterUniqueTogether(
name="usergroupmembership",
unique_together={("user_group", "user_profile")},
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 2)),
name="zerver_usermessage_starred_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 8)),
name="zerver_usermessage_mentioned_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andz", 1)),
name="zerver_usermessage_unread_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 512)),
name="zerver_usermessage_has_alert_word_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 8), ("flags__andnz", 16), _connector="OR"),
name="zerver_usermessage_wildcard_mentioned_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 120)),
name="zerver_usermessage_any_mentioned_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 2048)),
name="zerver_usermessage_is_private_message_id",
),
),
migrations.AddIndex(
model_name="usermessage",
index=models.Index(
models.F("user_profile"),
models.F("message"),
condition=models.Q(("flags__andnz", 4096)),
name="zerver_usermessage_active_mobile_push_notification_id",
),
),
migrations.AlterUniqueTogether(
name="usermessage",
unique_together={("user_profile", "message")},
),
migrations.AddIndex(
model_name="userpresence",
index=models.Index(
fields=["realm", "last_active_time"],
name="zerver_userpresence_realm_id_last_active_time_1c5aa9a2_idx",
),
),
migrations.AddIndex(
model_name="userpresence",
index=models.Index(
fields=["realm", "last_connected_time"],
name="zerver_userpresence_realm_id_last_connected_time_98d2fc9f_idx",
),
),
migrations.AddIndex(
model_name="userpresence",
index=models.Index(
fields=["realm", "last_update_id"],
name="zerver_userpresence_realm_last_update_id_idx",
),
),
migrations.AddIndex(
model_name="usertopic",
index=models.Index(
models.F("stream"),
django.db.models.functions.text.Upper("topic_name"),
name="zerver_mutedtopic_stream_topic",
),
),
migrations.AddIndex(
model_name="usertopic",
index=models.Index(
fields=["stream", "topic_name", "visibility_policy", "user_profile"],
name="zerver_usertopic_stream_topic_user_visibility_idx",
),
),
migrations.AddIndex(
model_name="usertopic",
index=models.Index(
fields=["user_profile", "visibility_policy", "stream", "topic_name"],
name="zerver_usertopic_user_visibility_idx",
),
),
migrations.AddConstraint(
model_name="usertopic",
constraint=models.UniqueConstraint(
models.F("user_profile"),
models.F("stream"),
django.db.models.functions.text.Lower("topic_name"),
name="usertopic_case_insensitive_topic_uniq",
),
),
migrations.AddIndex(
model_name="realmauditlog",
index=models.Index(
fields=["realm", "event_type", "event_time"],
name="zerver_realmauditlog_realm__event_type__event_time",
),
),
migrations.AddIndex(
model_name="realmauditlog",
index=models.Index(
condition=models.Q(("event_type__in", [301, 302, 303])),
fields=["modified_user", "modified_stream"],
name="zerver_realmauditlog_user_subscriptions_idx",
),
),
migrations.AddIndex(
model_name="realmauditlog",
index=models.Index(
condition=models.Q(("event_type__in", [101, 102, 103, 104])),
fields=["modified_user", "event_time"],
name="zerver_realmauditlog_user_activations_idx",
),
),
migrations.AlterUniqueTogether(
name="namedusergroup",
unique_together={("realm_for_sharding", "name")},
),
migrations.AddConstraint(
model_name="groupgroupmembership",
constraint=models.UniqueConstraint(
fields=("supergroup", "subgroup"), name="zerver_groupgroupmembership_uniq"
),
),
# The "most common values" list for a tsvector is 10x this
# number, which defaults to 100. Increasing it allows for
# better query planning, at a small cost of size, and
# `ANALYZE` time. It only takes effect after the next
# `ANALYZE`, which we run immediately.
migrations.RunSQL(
sql="ALTER TABLE zerver_message ALTER COLUMN search_tsvector SET STATISTICS 10000",
reverse_sql="ALTER TABLE zerver_message ALTER COLUMNS search_tsvector SET STATISTICS -1",
),
migrations.RunSQL(
sql="CREATE STATISTICS IF NOT EXISTS zerver_message_realm_recipient ON realm_id, recipient_id FROM zerver_message",
reverse_sql="DROP STATISTICS IF EXISTS zerver_message_realm_recipient",
),
migrations.RunSQL(
sql="CREATE STATISTICS IF NOT EXISTS zerver_message_realm_sender ON realm_id, sender_id FROM zerver_message",
reverse_sql="DROP STATISTICS IF EXISTS zerver_message_realm_sender",
),
migrations.RunSQL(
sql="ANALYZE zerver_message",
reverse_sql=migrations.RunSQL.noop,
),
# Ensure streams have unique names, case-insensitive, within their realm.
migrations.RunSQL(
"""
CREATE UNIQUE INDEX zerver_stream_realm_id_name_uniq ON zerver_stream (realm_id, upper(name::text));
"""
),
# Ensure users have unique email addresses, case-insensitive, within their realm.
migrations.RunSQL(
"""
CREATE UNIQUE INDEX zerver_userprofile_realm_id_email_uniq ON zerver_userprofile (realm_id, upper(email::text));
CREATE UNIQUE INDEX zerver_userprofile_realm_id_delivery_email_uniq ON zerver_userprofile (realm_id, upper(delivery_email::text));
"""
),
# Set up full-text search indexes.
migrations.RunSQL(
sql=get_fts_sql(),
),
]