Skip to content

Commit 7d2b58a

Browse files
authored
migrations(crons): Add is_muted to MonitorEnvironment (#62115)
First phase of allowing monitor environments to be individually muted
1 parent 2fdfae7 commit 7d2b58a

File tree

3 files changed

+53
-1
lines changed

3 files changed

+53
-1
lines changed

migrations_lockfile.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ feedback: 0003_feedback_add_env
99
hybridcloud: 0009_make_user_id_optional_for_slug_reservation_replica
1010
nodestore: 0002_nodestore_no_dictfield
1111
replays: 0003_add_size_to_recording_segment
12-
sentry: 0623_increase_regression_fingerprint_length
12+
sentry: 0624_add_is_muted_monitorenvironment
1313
social_auth: 0002_default_auto_field
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Generated by Django 3.2.23 on 2023-12-20 19:54
2+
3+
from django.db import migrations, models
4+
5+
from sentry.new_migrations.migrations import CheckedMigration
6+
7+
8+
class Migration(CheckedMigration):
9+
# This flag is used to mark that a migration shouldn't be automatically run in production. For
10+
# the most part, this should only be used for operations where it's safe to run the migration
11+
# after your code has deployed. So this should not be used for most operations that alter the
12+
# schema of a table.
13+
# Here are some things that make sense to mark as dangerous:
14+
# - Large data migrations. Typically we want these to be run manually by ops so that they can
15+
# be monitored and not block the deploy for a long period of time while they run.
16+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
17+
# have ops run this and not block the deploy. Note that while adding an index is a schema
18+
# change, it's completely safe to run the operation after the code has deployed.
19+
is_dangerous = False
20+
21+
dependencies = [
22+
("sentry", "0623_increase_regression_fingerprint_length"),
23+
]
24+
25+
operations = [
26+
migrations.SeparateDatabaseAndState(
27+
database_operations=[
28+
migrations.RunSQL(
29+
"""
30+
ALTER TABLE "sentry_monitorenvironment" ADD COLUMN "is_muted" boolean NOT NULL DEFAULT FALSE;
31+
""",
32+
reverse_sql="""
33+
ALTER TABLE "sentry_monitorenvironment" DROP COLUMN "is_muted";
34+
""",
35+
hints={"tables": ["sentry_monitorenvironment"]},
36+
),
37+
],
38+
state_operations=[
39+
migrations.AddField(
40+
model_name="monitorenvironment",
41+
name="is_muted",
42+
field=models.BooleanField(default=False),
43+
),
44+
],
45+
)
46+
]

src/sentry/monitors/models.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,12 @@ class MonitorEnvironment(Model):
558558
check-ins. It is denormalized for simplicity.
559559
"""
560560

561+
is_muted = models.BooleanField(default=False)
562+
"""
563+
Monitor environment is operating normally but will not produce incidents or produce
564+
occurrences into the issues platform.
565+
"""
566+
561567
next_checkin = models.DateTimeField(null=True)
562568
"""
563569
The expected time that the next-checkin will occur

0 commit comments

Comments
 (0)