Skip to content

Commit 137448c

Browse files
ref(uptime): Make subscription unique on timeout as well (#78787)
The timeout will become configurable, so we need subscriptions to be unique on this additional facet.
1 parent f85e2ac commit 137448c

File tree

3 files changed

+50
-1
lines changed

3 files changed

+50
-1
lines changed

migrations_lockfile.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ remote_subscriptions: 0003_drop_remote_subscription
1212
replays: 0004_index_together
1313
sentry: 0773_make_group_score_nullable
1414
social_auth: 0002_default_auto_field
15-
uptime: 0016_translate_uptime_object_headers_to_lists
15+
uptime: 0017_unique_on_timeout
1616
workflow_engine: 0009_detector_type
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Generated by Django 5.1.1 on 2024-10-08 19:37
2+
3+
import django.db.models.functions.comparison
4+
import django.db.models.functions.text
5+
from django.db import migrations, models
6+
7+
from sentry.new_migrations.migrations import CheckedMigration
8+
9+
10+
class Migration(CheckedMigration):
11+
# This flag is used to mark that a migration shouldn't be automatically run in production.
12+
# This should only be used for operations where it's safe to run the migration after your
13+
# code has deployed. So this should not be used for most operations that alter the schema
14+
# of a table.
15+
# Here are some things that make sense to mark as post deployment:
16+
# - Large data migrations. Typically we want these to be run manually so that they can be
17+
# monitored and not block the deploy for a long period of time while they run.
18+
# - Adding indexes to large tables. Since this can take a long time, we'd generally prefer to
19+
# run this outside deployments so that we don't block them. Note that while adding an index
20+
# is a schema change, it's completely safe to run the operation after the code has deployed.
21+
# Once deployed, run these manually via: https://develop.sentry.dev/database-migrations/#migration-deployment
22+
23+
is_post_deployment = False
24+
25+
dependencies = [
26+
("uptime", "0016_translate_uptime_object_headers_to_lists"),
27+
]
28+
29+
operations = [
30+
migrations.RemoveConstraint(
31+
model_name="uptimesubscription",
32+
name="uptime_uptimesubscription_unique_subscription_check",
33+
),
34+
migrations.AddConstraint(
35+
model_name="uptimesubscription",
36+
constraint=models.UniqueConstraint(
37+
models.F("url"),
38+
models.F("interval_seconds"),
39+
models.F("timeout_ms"),
40+
models.F("method"),
41+
django.db.models.functions.text.MD5("headers"),
42+
django.db.models.functions.comparison.Coalesce(
43+
django.db.models.functions.text.MD5("body"), models.Value("")
44+
),
45+
name="uptime_uptimesubscription_unique_subscription_check",
46+
),
47+
),
48+
]

src/sentry/uptime/models.py

+1
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ class Meta:
7171
models.UniqueConstraint(
7272
"url",
7373
"interval_seconds",
74+
"timeout_ms",
7475
"method",
7576
MD5("headers"),
7677
Coalesce(MD5("body"), Value("")),

0 commit comments

Comments
 (0)