Skip to content
Merged
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
56 changes: 0 additions & 56 deletions fixtures/backup/model_dependencies/detailed.json
Original file line number Diff line number Diff line change
Expand Up @@ -486,34 +486,6 @@
"table_name": "sentry_alertruleactivity",
"uniques": []
},
"sentry.alertruleexcludedprojects": {
"dangling": false,
"foreign_keys": {
"alert_rule": {
"kind": "FlexibleForeignKey",
"model": "sentry.alertrule",
"nullable": false
},
"project": {
"kind": "FlexibleForeignKey",
"model": "sentry.project",
"nullable": false
}
},
"model": "sentry.alertruleexcludedprojects",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"silos": [
"Region"
],
"table_name": "sentry_alertruleexcludedprojects",
"uniques": [
[
"alert_rule",
"project"
]
]
},
"sentry.alertruleprojects": {
"dangling": false,
"foreign_keys": {
Expand Down Expand Up @@ -593,34 +565,6 @@
"table_name": "sentry_alertruletriggeraction",
"uniques": []
},
"sentry.alertruletriggerexclusion": {
"dangling": false,
"foreign_keys": {
"alert_rule_trigger": {
"kind": "FlexibleForeignKey",
"model": "sentry.alertruletrigger",
"nullable": false
},
"query_subscription": {
"kind": "FlexibleForeignKey",
"model": "sentry.querysubscription",
"nullable": false
}
},
"model": "sentry.alertruletriggerexclusion",
"relocation_dependencies": [],
"relocation_scope": "Organization",
"silos": [
"Region"
],
"table_name": "sentry_alertruletriggerexclusion",
"uniques": [
[
"alert_rule_trigger",
"query_subscription"
]
]
},
"sentry.apiapplication": {
"dangling": false,
"foreign_keys": {
Expand Down
8 changes: 0 additions & 8 deletions fixtures/backup/model_dependencies/flat.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,6 @@
"sentry.alertrule",
"sentry.user"
],
"sentry.alertruleexcludedprojects": [
"sentry.alertrule",
"sentry.project"
],
"sentry.alertruleprojects": [
"sentry.alertrule",
"sentry.project"
Expand All @@ -84,10 +80,6 @@
"sentry.integration",
"sentry.sentryapp"
],
"sentry.alertruletriggerexclusion": [
"sentry.alertruletrigger",
"sentry.querysubscription"
],
"sentry.apiapplication": [
"sentry.user"
],
Expand Down
2 changes: 0 additions & 2 deletions fixtures/backup/model_dependencies/sorted.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
"sentry.dashboardpermissionsteam",
"sentry.alertruletrigger",
"sentry.alertruleprojects",
"sentry.alertruleexcludedprojects",
"sentry.alertruleactivity",
"sentry.alertruleactivations",
"sentry.alertruleactivationcondition",
Expand All @@ -234,7 +233,6 @@
"sentry.sentryappinstallationforprovider",
"sentry.incident",
"sentry.dashboardwidgetqueryondemand",
"sentry.alertruletriggerexclusion",
"sentry.alertruletriggeraction",
"sentry.timeseriessnapshot",
"sentry.servicehookproject",
Expand Down
2 changes: 0 additions & 2 deletions fixtures/backup/model_dependencies/truncate.json
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,6 @@
"sentry_dashboardpermissionsteam",
"sentry_alertruletrigger",
"sentry_alertruleprojects",
"sentry_alertruleexcludedprojects",
"sentry_alertruleactivity",
"sentry_alertruleactivations",
"sentry_alertruleactivationcondition",
Expand All @@ -234,7 +233,6 @@
"sentry_sentryappinstallationforprovider",
"sentry_incident",
"sentry_dashboardwidgetqueryondemand",
"sentry_alertruletriggerexclusion",
"sentry_alertruletriggeraction",
"sentry_timeseriessnapshot",
"sentry_servicehookproject",
Expand Down
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ remote_subscriptions: 0003_drop_remote_subscription

replays: 0004_index_together

sentry: 0795_drop_included_excluded_projects
sentry: 0796_rm_excluded_projects_triggers

social_auth: 0002_default_auto_field

Expand Down
40 changes: 0 additions & 40 deletions src/sentry/incidents/models/alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,6 @@ def conditionally_subscribe_project_to_alert_rules(
return []


@region_silo_model
class AlertRuleExcludedProjects(Model):
"""
Excludes a specific project from an AlertRule

NOTE: This feature is not currently utilized.
"""

__relocation_scope__ = RelocationScope.Organization

alert_rule = FlexibleForeignKey("sentry.AlertRule", db_index=False, db_constraint=False)
project = FlexibleForeignKey("sentry.Project", db_constraint=False)
date_added = models.DateTimeField(default=timezone.now)

class Meta:
app_label = "sentry"
db_table = "sentry_alertruleexcludedprojects"
unique_together = (("alert_rule", "project"),)


@region_silo_model
class AlertRuleProjects(Model):
"""
Expand Down Expand Up @@ -473,26 +453,6 @@ class Meta:
unique_together = (("alert_rule", "label"),)


@region_silo_model
class AlertRuleTriggerExclusion(Model):
"""
Allows us to define a specific trigger to be excluded from a query subscription
"""

__relocation_scope__ = RelocationScope.Organization

alert_rule_trigger = FlexibleForeignKey(
"sentry.AlertRuleTrigger", related_name="exclusions", db_constraint=False
)
query_subscription = FlexibleForeignKey("sentry.QuerySubscription", db_constraint=False)
date_added = models.DateTimeField(default=timezone.now)

class Meta:
app_label = "sentry"
db_table = "sentry_alertruletriggerexclusion"
unique_together = (("alert_rule_trigger", "query_subscription"),)


class AlertRuleTriggerActionMethod(StrEnum):
FIRE = "fire"
RESOLVE = "resolve"
Expand Down
36 changes: 36 additions & 0 deletions src/sentry/migrations/0796_rm_excluded_projects_triggers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Generated by Django 5.1.1 on 2024-11-25 20:06

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", "0795_drop_included_excluded_projects"),
]

operations = [
SafeDeleteModel(
name="AlertRuleExcludedProjects",
deletion_action=DeletionAction.MOVE_TO_PENDING,
),
SafeDeleteModel(
name="AlertRuleTriggerExclusion",
deletion_action=DeletionAction.MOVE_TO_PENDING,
),
]
11 changes: 1 addition & 10 deletions src/sentry/testutils/helpers/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,7 @@
from sentry.backup.validate import validate
from sentry.data_secrecy.models import DataSecrecyWaiver
from sentry.db.models.paranoia import ParanoidModel
from sentry.incidents.models.alert_rule import (
AlertRuleExcludedProjects,
AlertRuleMonitorTypeInt,
AlertRuleTriggerExclusion,
)
from sentry.incidents.models.alert_rule import AlertRuleMonitorTypeInt
from sentry.incidents.models.incident import (
IncidentActivity,
IncidentSnapshot,
Expand Down Expand Up @@ -511,20 +507,15 @@ def create_exhaustive_organization(
)

# AlertRule*
other_project = self.create_project(name=f"other-project-{slug}", teams=[team])
alert = self.create_alert_rule(
organization=org,
projects=[project],
user=owner,
)
AlertRuleExcludedProjects.objects.create(alert_rule=alert, project=other_project)
alert.user_id = owner_id
alert.save()
trigger = self.create_alert_rule_trigger(alert_rule=alert)
assert alert.snuba_query is not None
AlertRuleTriggerExclusion.objects.create(
alert_rule_trigger=trigger, query_subscription=alert.snuba_query.subscriptions.get()
)
self.create_alert_rule_trigger_action(alert_rule_trigger=trigger)
activated_alert = self.create_alert_rule(
organization=org,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2024-11-15T23:09:32.075671+00:00'
created: '2024-11-25T23:04:25.041092+00:00'
creator: sentry
source: tests/sentry/backup/test_sanitize.py
---
Expand Down Expand Up @@ -265,12 +265,6 @@ source: tests/sentry/backup/test_sanitize.py
- date_added
- name
- slug
- model_name: sentry.project
ordinal: 4
sanitized_fields:
- date_added
- name
- slug
- model_name: sentry.orgauthtoken
ordinal: 1
sanitized_fields:
Expand Down Expand Up @@ -599,9 +593,6 @@ source: tests/sentry/backup/test_sanitize.py
- model_name: sentry.projectteam
ordinal: 1
sanitized_fields: []
- model_name: sentry.projectteam
ordinal: 2
sanitized_fields: []
- model_name: sentry.projectredirect
ordinal: 1
sanitized_fields:
Expand All @@ -620,9 +611,6 @@ source: tests/sentry/backup/test_sanitize.py
- model_name: sentry.projectoption
ordinal: 3
sanitized_fields: []
- model_name: sentry.projectoption
ordinal: 4
sanitized_fields: []
- model_name: sentry.projectkey
ordinal: 1
sanitized_fields:
Expand All @@ -638,11 +626,6 @@ source: tests/sentry/backup/test_sanitize.py
sanitized_fields:
- date_added
- secret_key
- model_name: sentry.projectkey
ordinal: 4
sanitized_fields:
- date_added
- secret_key
- model_name: sentry.projectintegration
ordinal: 1
sanitized_fields:
Expand Down Expand Up @@ -814,10 +797,6 @@ source: tests/sentry/backup/test_sanitize.py
ordinal: 3
sanitized_fields:
- date_added
- model_name: sentry.alertruleexcludedprojects
ordinal: 1
sanitized_fields:
- date_added
- model_name: sentry.alertruleactivity
ordinal: 1
sanitized_fields:
Expand Down Expand Up @@ -860,10 +839,6 @@ source: tests/sentry/backup/test_sanitize.py
sanitized_fields:
- date_added
- date_modified
- model_name: sentry.alertruletriggerexclusion
ordinal: 1
sanitized_fields:
- date_added
- model_name: sentry.alertruletriggeraction
ordinal: 1
sanitized_fields:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
created: '2024-11-25T20:44:29.207064+00:00'
created: '2024-11-25T21:49:40.423739+00:00'
creator: sentry
source: tests/sentry/backup/test_comparators.py
---
Expand Down Expand Up @@ -120,12 +120,6 @@ source: tests/sentry/backup/test_comparators.py
- previous_alert_rule
- user_id
model_name: sentry.alertruleactivity
- comparators:
- class: ForeignKeyComparator
fields:
- alert_rule
- project
model_name: sentry.alertruleexcludedprojects
- comparators:
- class: ForeignKeyComparator
fields:
Expand All @@ -144,12 +138,6 @@ source: tests/sentry/backup/test_comparators.py
- integration_id
- sentry_app_id
model_name: sentry.alertruletriggeraction
- comparators:
- class: ForeignKeyComparator
fields:
- alert_rule_trigger
- query_subscription
model_name: sentry.alertruletriggerexclusion
- comparators:
- class: HashObfuscatingComparator
fields:
Expand Down
11 changes: 5 additions & 6 deletions tests/sentry/backup/test_imports.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,13 +687,12 @@ def test_import_signaling_organization(self):

assert OrganizationMember.objects.count() == 3

# The exhaustive org has 2 projects which automatically get 1 key and 3 options each.
assert Project.objects.count() == 2
# The exhaustive org has 1 project which automatically gets 1 key and 3 options.
assert Project.objects.count() == 1
assert Project.objects.filter(name="project-some-org").exists()
assert Project.objects.filter(name="other-project-some-org").exists()

assert ProjectKey.objects.count() == 2
assert ProjectOption.objects.count() == 2
assert ProjectKey.objects.count() == 1
assert ProjectOption.objects.count() == 1
assert ProjectOption.objects.filter(key="sentry:option-epoch").exists()

with assume_test_silo_mode(SiloMode.CONTROL):
Expand Down Expand Up @@ -1514,7 +1513,7 @@ def test_colliding_project_key(self, expected_models: list[type[Model]]):
with open(tmp_path, "rb") as tmp_file:
import_in_organization_scope(tmp_file, printer=NOOP_PRINTER)

assert ProjectKey.objects.count() == 4
assert ProjectKey.objects.count() == 3
assert ProjectKey.objects.filter(public_key=colliding.public_key).count() == 1
assert ProjectKey.objects.filter(secret_key=colliding.secret_key).count() == 1

Expand Down
Loading
Loading