Skip to content

Commit d45b2de

Browse files
committed
ref: soft delete omt is_active
1 parent 014ad52 commit d45b2de

File tree

7 files changed

+39
-12
lines changed

7 files changed

+39
-12
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ nodestore: 0001_squashed_0002_nodestore_no_dictfield
2121

2222
replays: 0001_squashed_0005_drop_replay_index
2323

24-
sentry: 0912_make_organizationmemberteam_replica_is_active_true
24+
sentry: 0913_soft_delete_omt_is_active
2525

2626
social_auth: 0001_squashed_0002_default_auto_field
2727

src/sentry/api/endpoints/organization_member/team_details.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ def serialize(
6464
self, obj: OrganizationMemberTeam, attrs: Mapping[Any, Any], user: Any, **kwargs: Any
6565
) -> OrganizationMemberTeamSerializerResponse:
6666
return {
67-
"isActive": obj.is_active,
6867
"teamRole": obj.role, # type:ignore[typeddict-item]
6968
}
7069

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Generated by Django 5.2.1 on 2025-05-22 21:31
2+
3+
4+
from sentry.new_migrations.migrations import CheckedMigration
5+
from sentry.new_migrations.monkey.fields import SafeRemoveField
6+
from sentry.new_migrations.monkey.state import DeletionAction
7+
8+
9+
class Migration(CheckedMigration):
10+
# This flag is used to mark that a migration shouldn't be automatically run in production.
11+
# This should only be used for operations where it's safe to run the migration after your
12+
# code has deployed. So this should not be used for most operations that alter the schema
13+
# of a table.
14+
# Here are some things that make sense to mark as post deployment:
15+
# - Large data migrations. Typically we want these to be run manually so that they can be
16+
# monitored and not block the deploy for a long period of time while they run.
17+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
18+
# run this outside deployments so that we don't block them. Note that while adding an index
19+
# is a schema change, it's completely safe to run the operation after the code has deployed.
20+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
21+
22+
is_post_deployment = False
23+
24+
dependencies = [
25+
("sentry", "0912_make_organizationmemberteam_replica_is_active_true"),
26+
]
27+
28+
operations = [
29+
SafeRemoveField(
30+
model_name="organizationmemberteam",
31+
name="is_active",
32+
deletion_action=DeletionAction.MOVE_TO_PENDING,
33+
),
34+
]

src/sentry/models/organizationmemberteam.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,6 @@ class OrganizationMemberTeam(ReplicatedRegionModel):
2929
id = BoundedAutoField(primary_key=True)
3030
team = FlexibleForeignKey("sentry.Team")
3131
organizationmember = FlexibleForeignKey("sentry.OrganizationMember")
32-
# an inactive membership simply removes the team from the default list
33-
# but still allows them to re-join without request
34-
is_active = models.BooleanField(db_default=True)
3532
role = models.CharField(max_length=32, null=True, blank=True)
3633

3734
class Meta:
@@ -76,7 +73,6 @@ def get_audit_log_data(self):
7673
"team_slug": self.team.slug,
7774
"member_id": self.organizationmember_id,
7875
"email": self.organizationmember.get_email(),
79-
"is_active": self.is_active,
8076
}
8177

8278
def get_team_role(self) -> TeamRole:

src/sentry/models/project.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,6 @@ def member_set(self):
458458

459459
return self.organization.member_set.filter(
460460
id__in=OrganizationMember.objects.filter(
461-
organizationmemberteam__is_active=True,
462461
organizationmemberteam__team__in=self.teams.all(),
463462
).values("id"),
464463
user_is_active=True,

src/sentry/models/team.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def get_for_user(
6767
return []
6868

6969
org_member_team_filter = OrganizationMemberTeam.objects.filter(
70-
organizationmember=om, is_active=True
70+
organizationmember=om,
7171
)
7272
if is_team_admin:
7373
org_member_team_filter = org_member_team_filter.filter(role="admin")
@@ -175,7 +175,6 @@ def member_set(self):
175175
""":returns a QuerySet of all Users that belong to this Team"""
176176
return self.organization.member_set.filter(
177177
organizationmemberteam__team=self,
178-
organizationmemberteam__is_active=True,
179178
user_id__isnull=False,
180179
user_is_active=True,
181180
).distinct()

src/sentry/organizations/services/organization/serial.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def serialize_member(member: OrganizationMember) -> RpcOrganizationMember:
5858
)
5959

6060
omts = OrganizationMemberTeam.objects.filter(
61-
organizationmember=member, is_active=True, team__status=TeamStatus.ACTIVE
61+
organizationmember=member, team__status=TeamStatus.ACTIVE
6262
).select_related("team")
6363

6464
all_project_ids: set[int] = set()
@@ -108,7 +108,7 @@ def _serialize_team_member(
108108
result = RpcTeamMember(
109109
id=team_member.id,
110110
slug=team_member.team.slug,
111-
is_active=team_member.is_active,
111+
is_active=True, # this field is being deprecated on the omt model
112112
role_id=team_member.get_team_role().id,
113113
team_id=team_member.team_id,
114114
project_ids=list(project_ids),
@@ -161,6 +161,6 @@ def serialize_rpc_organization_member_team(
161161
team_id=omt.team_id,
162162
organizationmember_id=omt.organizationmember_id,
163163
organization_id=omt.organizationmember.organization_id,
164-
is_active=omt.is_active,
164+
is_active=True, # this field is being deprecated on the omt model
165165
role=omt.role,
166166
)

0 commit comments

Comments
 (0)