Skip to content

Commit

Permalink
fix(backup): Move Incident and related models relocation scope (#81066
Browse files Browse the repository at this point in the history
)

These models turn out to actually be "high-volume" in certain cases, so
they are better suited for the `Global` scope instead.
  • Loading branch information
azaslavsky authored Nov 20, 2024
1 parent a8141a9 commit 802e70a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
14 changes: 7 additions & 7 deletions fixtures/backup/model_dependencies/detailed.json
Original file line number Diff line number Diff line change
Expand Up @@ -3005,7 +3005,7 @@
},
"model": "sentry.incident",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down Expand Up @@ -3033,7 +3033,7 @@
},
"model": "sentry.incidentactivity",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down Expand Up @@ -3112,7 +3112,7 @@
},
"model": "sentry.incidentsnapshot",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand All @@ -3139,7 +3139,7 @@
},
"model": "sentry.incidentsubscription",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down Expand Up @@ -3167,7 +3167,7 @@
},
"model": "sentry.incidenttrigger",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down Expand Up @@ -4096,7 +4096,7 @@
},
"model": "sentry.pendingincidentsnapshot",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down Expand Up @@ -6059,7 +6059,7 @@
"relocation_dependencies": [
"sentry.incident"
],
"relocation_scope": "Organization",
"relocation_scope": "Global",
"silos": [
"Region"
],
Expand Down
14 changes: 7 additions & 7 deletions src/sentry/incidents/models/incident.py
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class Incident(Model):
- UI should be able to handle multiple active incidents
"""

__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

objects: ClassVar[IncidentManager] = IncidentManager()

Expand Down Expand Up @@ -250,7 +250,7 @@ def normalize_before_relocation_import(

@region_silo_model
class PendingIncidentSnapshot(Model):
__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

incident = OneToOneCascadeDeletes("sentry.Incident", db_constraint=False)
target_run_date = models.DateTimeField(db_index=True, default=timezone.now)
Expand All @@ -263,7 +263,7 @@ class Meta:

@region_silo_model
class IncidentSnapshot(Model):
__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

incident = OneToOneCascadeDeletes("sentry.Incident", db_constraint=False)
event_stats_snapshot = FlexibleForeignKey("sentry.TimeSeriesSnapshot", db_constraint=False)
Expand All @@ -278,7 +278,7 @@ class Meta:

@region_silo_model
class TimeSeriesSnapshot(Model):
__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global
__relocation_dependencies__ = {"sentry.Incident"}

start = models.DateTimeField()
Expand Down Expand Up @@ -313,7 +313,7 @@ class IncidentActivity(Model):
An IncidentActivity is a record of a change that occurred in an Incident. This could be a status change,
"""

__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

incident = FlexibleForeignKey("sentry.Incident")
user_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, on_delete="CASCADE", null=True)
Expand Down Expand Up @@ -348,7 +348,7 @@ class IncidentSubscription(Model):
Not to be confused with a snuba QuerySubscription
"""

__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

incident = FlexibleForeignKey("sentry.Incident", db_index=False)
user_id = HybridCloudForeignKey(settings.AUTH_USER_MODEL, on_delete="CASCADE")
Expand Down Expand Up @@ -405,7 +405,7 @@ class IncidentTrigger(Model):
NOTE: dissimilar to an AlertRuleTrigger which represents the trigger threshold required to initialize an Incident
"""

__relocation_scope__ = RelocationScope.Organization
__relocation_scope__ = RelocationScope.Global

objects: ClassVar[IncidentTriggerManager] = IncidentTriggerManager()

Expand Down

0 comments on commit 802e70a

Please sign in to comment.