zulip/zerver/migrations
Tim Abbott c57c4cf703 notifications: Fix push notifications with multiple realms.
Previously, Zulip did not correctly handle the case of a mobile device
being registered with a push device token being registered for
multiple accounts on the same server (which is a common case on
zulipchat.com).  This was because our database `unique` and
`unique_together` indexes incorrectly enforced the token being unique
on a given server, rather than unique for a given user_id.

We fix this gap, and at the same time remove unnecessary (and
incorrectly racey) logic deleting and recreating the tokens in the
appropriate tables.

There's still an open mobile app bug causing repeated re-registrations
in a loop, but this should fix the fact that the relevant mobile bug
causes the server to 500.

Follow-up work that may be of value includes:
* Removing `ios_app_id`, which may not have much purpose.
* Renaming `last_updated` to `data_created`, since that's what it is now.

But none of those are critical to solving the actual bug here.

Fixes #8841.
2018-10-10 16:15:52 -07:00
..
0001_initial.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0029_realm_subdomain.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0030_realm_org_type.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0031_remove_system_avatar_source.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0032_verify_all_medium_avatar_images.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0033_migrate_domain_to_realmalias.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0034_userprofile_enable_online_push_notifications.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0035_realm_message_retention_period_days.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0036_rename_subdomain_to_string_id.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0037_disallow_null_string_id.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0038_realm_change_to_community_defaults.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0039_realmalias_drop_uniqueness.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0040_realm_authentication_methods.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0041_create_attachments_for_old_messages.py migrations: Convert migration 0041 to not import from zerver. 2018-07-24 09:00:14 -07:00
0042_attachment_file_name_length.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0043_realm_filter_validators.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0044_reaction.py models: Remove unused ModelReprMixin class. 2018-05-15 19:11:22 -07:00
0045_realm_waiting_period_threshold.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0046_realmemoji_author.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0047_realm_add_emoji_by_admins_only.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0048_enter_sends_default_to_false.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0049_userprofile_pm_content_in_desktop_notifications.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0050_userprofile_avatar_version.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0051_realmalias_add_allow_subdomains.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0052_auto_fix_realmalias_realm_nullable.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0053_emailchangestatus.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0054_realm_icon.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0055_attachment_size.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0056_userprofile_emoji_alt_code.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0057_realmauditlog.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0058_realm_email_changes_disabled.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0059_userprofile_quota.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0060_move_avatars_to_be_uid_based.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0061_userprofile_timezone.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0062_default_timezone.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0063_realm_description.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0064_sync_uploads_filesize_with_db.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0065_realm_inline_image_preview.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0066_realm_inline_url_embed_preview.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0067_archived_models.py models: Remove unused ModelReprMixin class. 2018-05-15 19:11:22 -07:00
0068_remove_realm_domain.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0069_realmauditlog_extra_data.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0070_userhotspot.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0071_rename_realmalias_to_realmdomain.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0072_realmauditlog_add_index_event_time.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0073_custom_profile_fields.py i18n: Add missing strings for custom profile fields and fix capitalization. 2018-05-06 19:44:36 -07:00
0074_fix_duplicate_attachments.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0075_attachment_path_id_unique.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0076_userprofile_emojiset.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0077_add_file_name_field_to_realm_emoji.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0078_service.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0079_remove_old_scheduled_jobs.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0080_realm_description_length.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0081_make_emoji_lowercase.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0082_index_starred_user_messages.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0083_index_mentioned_user_messages.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0084_realmemoji_deactivated.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0085_fix_bots_with_none_bot_type.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0086_realm_alter_default_org_type.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0087_remove_old_scheduled_jobs.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0088_remove_referral_and_invites.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0089_auto_20170710_1353.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0090_userprofile_high_contrast_mode.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0091_realm_allow_edit_history.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0092_create_scheduledemail.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0093_subscription_event_log_backfill.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0094_realm_filter_url_validator.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0095_index_unread_user_messages.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0096_add_password_required.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0097_reactions_emoji_code.py migrations: Fix text version to Custom Emoji. 2018-03-16 17:16:18 -07:00
0098_index_has_alert_word_user_messages.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0099_index_wildcard_mentioned_user_messages.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0100_usermessage_remove_is_me_message.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0101_muted_topic.py models: Remove unused ModelReprMixin class. 2018-05-15 19:11:22 -07:00
0102_convert_muted_topic.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0103_remove_userprofile_muted_topics.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0104_fix_unreads.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0105_userprofile_enable_stream_push_notifications.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0106_subscription_push_notifications.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0107_multiuseinvite.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0108_fix_default_string_id.py zerver/migrations: Use python 3 syntax for typing. 2017-10-26 15:24:56 -07:00
0109_mark_tutorial_status_finished.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0110_stream_is_in_zephyr_realm.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0111_botuserstatedata.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0112_index_muted_topics.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0113_default_stream_group.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0114_preregistrationuser_invited_as_admin.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0115_user_groups.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0116_realm_allow_message_deleting.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0117_add_desc_to_user_group.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0118_defaultstreamgroup_description.py python: Sort imports in database migrations. 2017-11-15 15:44:00 -08:00
0119_userprofile_night_mode.py settings: Add backend storage and interface for night mode. 2017-11-15 16:36:06 -08:00
0120_botuserconfigdata.py migrations: Fix conflict. 2017-11-17 08:24:56 -08:00
0121_realm_signup_notifications_stream.py models: Add signup_notifications_stream attribute to Realm. 2017-11-21 17:39:50 -08:00
0122_rename_botuserstatedata_botstoragedata.py embedded bots: Consistently use 'storage' instead of 'state.' 2017-11-27 21:05:34 -08:00
0123_userprofile_make_realm_email_pair_unique.py auth: Allow accounts with the same email in different realms. 2017-11-28 16:23:10 -08:00
0124_stream_enable_notifications.py notification settings: Add stream email notifications setting. 2017-11-28 17:51:18 -08:00
0125_realm_max_invites.py invitations: Limit realms to 100 invites per day. 2017-11-29 22:18:05 -08:00
0126_prereg_remove_users_without_realm.py registration: Enforce realm is None only if realm_creation. 2017-12-11 18:36:14 -08:00
0127_disallow_chars_in_stream_and_user_name.py migrations: Fix mypy error in placeholder migration. 2018-02-05 18:03:07 -08:00
0128_scheduledemail_realm.py models: Add ScheduledEmail.realm. 2017-12-19 17:46:36 -08:00
0129_remove_userprofile_autoscroll_forever.py settings: Remove autoscroll_forever setting. 2018-01-02 10:35:49 -05:00
0130_text_choice_in_emojiset.py migrations: Add reverser for emoji_alt_code migration. 2018-02-05 16:55:21 -08:00
0131_realm_create_generic_bot_by_admins_only.py settings: Limit the creation of generic bots. 2018-01-02 18:12:22 -05:00
0132_realm_message_visibility_limit.py models: Add message_visibility_limit attribute to Realm. 2018-01-04 08:52:40 -05:00
0133_rename_botuserconfigdata_botconfigdata.py Rename BotUserConfigData to BotConfigData. 2018-01-06 14:13:18 -05:00
0134_scheduledmessage.py scheduledmessages: Add model for the ScheduledMessage table. 2018-01-10 09:18:02 -05:00
0135_scheduledmessage_delivery_type.py scheduledmessages: Add delivery_type field to the table. 2018-01-19 11:33:11 -05:00
0136_remove_userprofile_quota.py upload: Remove UserProfile field for old per-user quota. 2018-01-29 16:06:11 -08:00
0137_realm_upload_quota_gb.py upload: Add a quota field to Realm. 2018-01-29 16:06:11 -08:00
0138_userprofile_realm_name_in_notifications.py settings: Added setting to turn on and off realm name in email subject. 2018-02-05 18:01:54 -08:00
0139_fill_last_message_id_in_subscription_logs.py RealmAuditLog: Fill subscription events with event_last_message_id=None. 2018-02-22 09:45:22 -08:00
0140_realm_send_welcome_emails.py org-settings: Add setting to turn off welcome emails. 2018-02-28 12:39:01 -08:00
0141_change_usergroup_description_to_textfield.py models: Change description attribute of user group to textfield. 2018-03-01 11:27:26 -08:00
0142_userprofile_translate_emoticons.py emoji: Add support for translating emoticons. 2018-03-04 15:37:24 -08:00
0143_realm_bot_creation_policy.py org settings: Add setting to prevent users from adding bots. 2018-03-09 13:21:55 -08:00
0144_remove_realm_create_generic_bot_by_admins_only.py org settings: Add setting to prevent users from adding bots. 2018-03-09 13:21:55 -08:00
0145_reactions_realm_emoji_name_to_id.py reactions: Fix buggy migration for realm emoji. 2018-03-20 21:50:47 -07:00
0146_userprofile_message_content_in_email_notifications.py settings: Add setting to disable message content in missed message emails. 2018-03-09 21:16:02 -08:00
0147_realm_disallow_disposable_email_addresses.py emails: Add backend for disallowing disposable email addresses. 2018-03-11 22:05:58 -07:00
0148_max_invites_forget_default.py antispam: Make a setting for default Realm.max_invites. 2018-03-16 18:00:11 -07:00
0149_realm_emoji_drop_unique_constraint.py migrations: Fix 0149_realm_emoji migration for S3 case. 2018-03-23 10:48:50 -07:00
0150_realm_allow_community_topic_editing.py models: Add allow_community_topic_editing setting. 2018-03-22 16:02:24 -07:00
0151_last_reminder_default_none.py models: Fix default value for last_reminder. 2018-03-29 11:53:12 -07:00
0152_realm_default_twenty_four_hour_time.py org settings: Add realm level default time format setting. 2018-03-31 16:23:26 -07:00
0153_remove_int_float_custom_fields.py i18n: Add missing strings for custom profile fields and fix capitalization. 2018-05-06 19:44:36 -07:00
0154_fix_invalid_bot_owner.py bots: Clean up editing bots impacting non-bot users. 2018-04-02 18:58:26 -07:00
0155_change_default_realm_description.py org settings: Change default realm description to empty string. 2018-04-06 15:15:47 -07:00
0156_add_hint_to_profile_field.py profile: Add hint attribute to custom profile fields. 2018-04-19 11:32:35 -07:00
0157_userprofile_is_guest.py guest: Add a model field for guest users. 2018-04-20 16:08:29 -07:00
0158_realm_video_chat_provider.py models: Add attribute for video provider in realm. 2018-04-23 09:15:12 -07:00
0159_realm_google_hangouts_domain.py settings: Add support for Hangouts as the video chat provider. 2018-04-23 09:39:47 -07:00
0160_add_choice_field.py i18n: Add missing strings for custom profile fields and fix capitalization. 2018-05-06 19:44:36 -07:00
0161_realm_message_content_delete_limit_seconds.py org setting: Add time limits for message deleting. 2018-04-27 19:22:28 -07:00
0162_change_default_community_topic_editing.py org settings: Change default allow_community_topic_editing value. 2018-04-28 13:00:29 -07:00
0163_remove_userprofile_default_desktop_notifications.py settings: Remove obsolete default_desktop_notifications setting. 2018-04-28 13:46:07 -07:00
0164_stream_history_public_to_subscribers.py migrations: Remove dependence on PRIVATE_STREAM_HISTORY_FOR_SUBSCRIBERS. 2018-05-29 07:36:53 -07:00
0165_add_date_to_profile_field.py i18n: Add missing strings for custom profile fields and fix capitalization. 2018-05-06 19:44:36 -07:00
0166_add_url_to_profile_field.py i18n: Add missing strings for custom profile fields and fix capitalization. 2018-05-06 19:44:36 -07:00
0167_custom_profile_fields_sort_order.py migrations: Add missing reverse_code for migration 0167. 2018-05-21 09:42:19 -07:00
0168_stream_is_web_public.py web_public_streams: Add is_web_public to Stream table. 2018-05-02 15:23:33 -07:00
0169_stream_is_announcement_only.py models: Add field is_announcement_only to stream. 2018-05-13 09:06:20 -07:00
0170_submessage.py Add SubMessage table. 2018-05-16 15:13:33 -07:00
0171_userprofile_dense_mode.py settings: Add a development-only setting for less dense mode. 2018-05-24 12:31:37 -07:00
0172_add_user_type_of_custom_profile_field.py custom fields: Add user type of custom fields. 2018-05-27 23:01:21 -07:00
0173_support_seat_based_plans.py billing: Add initial support for seat based plans. 2018-07-09 14:33:08 +05:30
0174_userprofile_delivery_email.py migrations: Disable atomic for delivery_email migration. 2018-09-28 14:14:20 -07:00
0175_change_realm_audit_log_event_type_tense.py models: Rename remaining audit log event types to past tense. 2018-07-22 20:00:28 -07:00
0176_remove_subscription_notifications.py models: Delete unused Subscription.notifications field. 2018-07-26 15:54:57 -07:00
0177_user_message_add_and_index_is_private_flag.py models: Add is_private flag to UserMessage and add index for it. 2018-07-30 15:43:55 -07:00
0178_rename_to_emails_restricted_to_domains.py models: Rename Realm.restricted_to_domain field. 2018-07-31 09:28:33 -07:00
0179_rename_to_digest_emails_enabled.py models: Rename Realm.show_digest_email field. 2018-08-01 11:05:58 -07:00
0180_usermessage_add_active_mobile_push_notification.py models: Add new UserMessage flag active_mobile_push_notification. 2018-08-01 16:51:56 -07:00
0181_userprofile_change_emojiset.py emoji: Disable support for letting users switch emojisets. 2018-08-08 15:48:04 -07:00
0182_set_initial_value_is_private_flag.py migrations: Fix accounting in is_private migration. 2018-08-20 16:49:08 -07:00
0183_change_custom_field_name_max_length.py zerver/models.py: Change custom field name max length to 40 char. 2018-08-17 08:36:22 -07:00
0184_rename_custom_field_types.py custom profile field: Rename field types in UI. 2018-08-21 11:37:51 -07:00
0185_realm_plan_type.py models: Add plan_type to Realm. 2018-08-21 12:39:06 -07:00
0186_userprofile_starred_message_counts.py models: Create starred_message_counts boolean field. 2018-08-21 13:42:22 -07:00
0187_userprofile_is_billing_admin.py billing: Use UserProfile.is_billing_admin instead of Customer.billing_user. 2018-08-27 12:35:46 -07:00
0188_userprofile_enable_login_emails.py user settings: Add setting to make login notifications optional. 2018-08-28 14:02:31 -07:00
0189_userprofile_add_some_emojisets.py emoji: Set default emoji to google-blob for existing users too. 2018-08-31 15:45:33 -07:00
0190_cleanup_pushdevicetoken.py notifications: Fix push notifications with multiple realms. 2018-10-10 16:15:52 -07:00
__init__.py [manual] Rename Django app from zephyr to zerver. 2013-08-06 07:39:36 -04:00