Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions fixtures/backup/fresh-install.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,30 +39,6 @@
"value": "23.6.1"
}
},
{
"model": "sentry.email",
"pk": 1,
"fields": {
"email": "admin@example.com",
"date_added": "2023-06-22T22:59:55.531Z"
}
},
{
"model": "sentry.email",
"pk": 2,
"fields": {
"email": "member@example.com",
"date_added": "2023-06-22T22:59:56.531Z"
}
},
{
"model": "sentry.email",
"pk": 3,
"fields": {
"email": "superadmin@example.com",
"date_added": "2023-06-22T22:59:57.531Z"
}
},
{
"model": "sentry.organization",
"pk": 1,
Expand Down
8 changes: 0 additions & 8 deletions fixtures/backup/user-with-maximum-privileges.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"avatar_url": null
}
},
{
"model": "sentry.email",
"pk": 1,
"fields": {
"email": "maximum@example.com",
"date_added": "2023-06-22T22:59:54.521Z"
}
},
{
"model": "sentry.authenticator",
"pk": 1,
Expand Down
8 changes: 0 additions & 8 deletions fixtures/backup/user-with-minimum-privileges.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"avatar_url": null
}
},
{
"model": "sentry.email",
"pk": 2,
"fields": {
"email": "testing@example.com",
"date_added": "2023-06-22T22:59:54.521Z"
}
},
{
"model": "sentry.authenticator",
"pk": 2,
Expand Down
8 changes: 0 additions & 8 deletions fixtures/backup/user-with-roles-no-superadmin.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"avatar_url": null
}
},
{
"model": "sentry.email",
"pk": 3,
"fields": {
"email": "testing@example.com",
"date_added": "2023-06-22T22:59:54.521Z"
}
},
{
"model": "sentry.authenticator",
"pk": 3,
Expand Down
8 changes: 0 additions & 8 deletions fixtures/backup/user-with-superadmin-no-roles.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,6 @@
"avatar_url": null
}
},
{
"model": "sentry.email",
"pk": 4,
"fields": {
"email": "testing@example.com",
"date_added": "2023-06-22T22:59:54.521Z"
}
},
{
"model": "sentry.authenticator",
"pk": 4,
Expand Down
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ replays: 0007_organizationmember_replay_access

seer: 0017_drop_old_fk_columns

sentry: 1100_add_relocation_file_bucket_path
sentry: 1101_remove_email_model_pending

social_auth: 0003_social_auth_json_field

Expand Down
1 change: 0 additions & 1 deletion src/sentry/backup/comparators.py
Original file line number Diff line number Diff line change
Expand Up @@ -879,7 +879,6 @@ def get_default_comparators() -> dict[str, list[JSONScrubbingComparator]]:
"sentry.dashboardwidgetqueryondemand": [DateUpdatedComparator("date_modified")],
"sentry.dashboardwidgetquery": [DateUpdatedComparator("date_modified")],
"sentry.dashboardfieldlink": [DateUpdatedComparator("date_added", "date_updated")],
"sentry.email": [DateUpdatedComparator("date_added")],
"sentry.organization": [AutoSuffixComparator("slug")],
"sentry.organizationintegration": [DateUpdatedComparator("date_updated")],
"sentry.organizationmember": [
Expand Down
35 changes: 2 additions & 33 deletions src/sentry/backup/imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ def _import(
# Import here to prevent circular module resolutions.
from sentry.models.organization import Organization
from sentry.models.organizationmember import OrganizationMember
from sentry.users.models.email import Email
from sentry.users.models.user import User

if SiloMode.get_current_mode() == SiloMode.CONTROL:
Expand All @@ -144,7 +143,6 @@ def _import(
flags = flags._replace(import_uuid=uuid4().hex)

deps = dependencies()
user_model_name = get_model_name(User)
org_auth_token_model_name = get_model_name(OrgAuthToken)
org_member_model_name = get_model_name(OrganizationMember)
org_model_name = get_model_name(Organization)
Expand Down Expand Up @@ -181,10 +179,6 @@ def _import(
if filter_by is not None:
filters.append(filter_by)

# `sentry.Email` models don't have any explicit dependencies on `sentry.User`, so we need to
# find and record them manually.
user_to_email = dict()

if filter_by.model == Organization:
# To properly filter organizations, we need to grab their users first. There is no
# elegant way to do this: we'll just have to read the import JSON until we get to the
Expand All @@ -203,12 +197,7 @@ def _import(
for obj in serializers.deserialize("json", content):
o = obj.object
model_name = get_model_name(o)
if model_name == user_model_name:
username = getattr(o, "username", None)
email = getattr(o, "email", None)
if username is not None and email is not None:
user_to_email[username] = email
elif model_name == org_model_name:
if model_name == org_model_name:
pk = getattr(o, "pk", None)
slug = getattr(o, "slug", None)
if pk is not None and slug in filter_by.values:
Expand All @@ -224,30 +213,10 @@ def _import(
# org member we're going to see. We can ignore the rest of the models.
break
elif filter_by.model == User:
seen_first_user_model = False
for obj in serializers.deserialize("json", content):
o = obj.object
model_name = get_model_name(o)
if model_name == user_model_name:
seen_first_user_model = False
username = getattr(o, "username", None)
email = getattr(o, "email", None)
if username is not None and email is not None:
user_to_email[username] = email
elif seen_first_user_model:
break
pass
else:
raise TypeError("Filter arguments must only apply to `Organization` or `User` models")

user_filter = next(f for f in filters if f.model == User)
email_filter = Filter[str](
model=Email,
field="email",
values={v for k, v in user_to_email.items() if k in user_filter.values},
)

filters.append(email_filter)

# Reorder models according to dependencies to ensure correct import order.
# This is necessary for backward compatibility with exports created before
# __relocation_dependencies__ was added to models like DataSource.
Expand Down
1 change: 1 addition & 0 deletions src/sentry/db/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class SiloRouter:
"sentry_dashboardtombstone": SiloMode.CELL,
"sentry_dashboardwidgetsnapshot": SiloMode.CELL,
"sentry_datasecrecywaiver": SiloMode.CELL,
"sentry_email": SiloMode.CELL,
"sentry_incidentseen": SiloMode.CELL,
"sentry_incidentsubscription": SiloMode.CELL,
"sentry_incidenttrigger": SiloMode.CELL,
Expand Down
29 changes: 29 additions & 0 deletions src/sentry/migrations/1101_remove_email_model_pending.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Generated by Django 5.2.14 on 2026-05-26 20:43

from sentry.new_migrations.migrations import CheckedMigration
from sentry.new_migrations.monkey.models import SafeDeleteModel
from sentry.new_migrations.monkey.state import DeletionAction


class Migration(CheckedMigration):
# This flag is used to mark that a migration shouldn't be automatically run in production.
# This should only be used for operations where it's safe to run the migration after your
# code has deployed. So this should not be used for most operations that alter the schema
# of a table.
# Here are some things that make sense to mark as post deployment:
# - Large data migrations. Typically we want these to be run manually so that they can be
# monitored and not block the deploy for a long period of time while they run.
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
# run this outside deployments so that we don't block them. Note that while adding an index
# is a schema change, it's completely safe to run the operation after the code has deployed.
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment

is_post_deployment = False

dependencies = [
("sentry", "1100_add_relocation_file_bucket_path"),
]

operations = [
SafeDeleteModel(name="Email", deletion_action=DeletionAction.MOVE_TO_PENDING),
]
1 change: 0 additions & 1 deletion src/sentry/receivers/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
from .auth import * # noqa: F401,F403
from .core import * # noqa: F401,F403
from .data_forwarding import * # noqa: F401,F403
from .email import * # noqa: F401,F403
from .experiments import * # noqa: F401,F403
from .features import * # noqa: F401,F403
from .onboarding import * # noqa: F401,F403
Expand Down
25 changes: 0 additions & 25 deletions src/sentry/receivers/email.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/sentry/users/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from sentry.users.models.authenticator import Authenticator
from sentry.users.models.email import Email
from sentry.users.models.identity import Identity
from sentry.users.models.lostpasswordhash import LostPasswordHash
from sentry.users.models.user import User
Expand All @@ -11,7 +10,6 @@

__all__ = (
"Authenticator",
"Email",
"Identity",
"LostPasswordHash",
"User",
Expand Down
62 changes: 0 additions & 62 deletions src/sentry/users/models/email.py

This file was deleted.

1 change: 0 additions & 1 deletion src/sentry/users/models/useremail.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def get_primary_email(self, user: RpcUser | User) -> UserEmail:
@control_silo_model
class UserEmail(ControlOutboxProducingModel):
__relocation_scope__ = RelocationScope.User
__relocation_dependencies__ = {"sentry.Email"}
__relocation_custom_ordinal__ = ["user", "email"]

user = FlexibleForeignKey(settings.AUTH_USER_MODEL, related_name="emails")
Expand Down
Loading
Loading