Skip to content

Commit

Permalink
use nulls_distinct=False instead
Browse files Browse the repository at this point in the history
  • Loading branch information
wedamija committed Oct 18, 2024
1 parent 4d50c05 commit 0193e90
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion migrations_lockfile.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ replays: 0004_index_together
sentry: 0777_add_related_name_to_dashboard_permissions
social_auth: 0002_default_auto_field
uptime: 0017_unique_on_timeout
workflow_engine: 0010_detector_state_unique_group_key
workflow_engine: 0010_detector_state_unique_gruop
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Generated by Django 5.1.1 on 2024-10-18 22:51
# Generated by Django 5.1.1 on 2024-10-18 23:02

import django.db.models.functions.comparison
from django.db import migrations, models

from sentry.new_migrations.migrations import CheckedMigration
Expand Down Expand Up @@ -29,11 +28,9 @@ class Migration(CheckedMigration):
migrations.AddConstraint(
model_name="detectorstate",
constraint=models.UniqueConstraint(
models.F("detector"),
django.db.models.functions.comparison.Coalesce(
"detector_group_key", models.Value("")
),
fields=("detector", "detector_group_key"),
name="detector_state_unique_group_key",
nulls_distinct=False,
),
),
]
6 changes: 2 additions & 4 deletions src/sentry/workflow_engine/models/detector_state.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from enum import StrEnum

from django.db import models
from django.db.models import F, Value
from django.db.models.functions import Coalesce

from sentry.backup.scopes import RelocationScope
from sentry.db.models import DefaultFieldsModel, FlexibleForeignKey, region_silo_model
Expand Down Expand Up @@ -31,8 +29,8 @@ class DetectorState(DefaultFieldsModel):
class Meta:
constraints = [
models.UniqueConstraint(
F("detector"),
Coalesce("detector_group_key", Value("")),
fields=["detector", "detector_group_key"],
nulls_distinct=False,
name="detector_state_unique_group_key",
),
]

0 comments on commit 0193e90

Please sign in to comment.