diff --git a/CHANGELOG.md b/CHANGELOG.md index ce5d3caf..884088ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## Unreleased +### Fixed + +- Fix deleting integrations with duplicate names by @vadimkerr ([#3397](https://github.com/grafana/oncall/pull/3397)) + ## v1.3.60 (2023-11-20) ### Fixed diff --git a/engine/apps/alerts/migrations/0039_remove_alertreceivechannel_unique_integration_name.py b/engine/apps/alerts/migrations/0039_remove_alertreceivechannel_unique_integration_name.py new file mode 100644 index 00000000..2ef02170 --- /dev/null +++ b/engine/apps/alerts/migrations/0039_remove_alertreceivechannel_unique_integration_name.py @@ -0,0 +1,17 @@ +# Generated by Django 4.2.7 on 2023-11-21 12:25 + +from django.db import migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('alerts', '0038_remove_alertgroup_is_restricted_db'), + ] + + operations = [ + migrations.RemoveConstraint( + model_name='alertreceivechannel', + name='unique integration name', + ), + ] diff --git a/engine/apps/alerts/models/alert_receive_channel.py b/engine/apps/alerts/models/alert_receive_channel.py index 03c433ca..fb465193 100644 --- a/engine/apps/alerts/models/alert_receive_channel.py +++ b/engine/apps/alerts/models/alert_receive_channel.py @@ -206,14 +206,6 @@ class AlertReceiveChannel(IntegrationOptionsMixin, MaintainableObject): rate_limited_in_slack_at = models.DateTimeField(null=True, default=None) rate_limit_message_task_id = models.CharField(max_length=100, null=True, default=None) - class Meta: - constraints = [ - models.UniqueConstraint( - fields=["organization", "verbal_name", "deleted_at"], - name="unique integration name", - ) - ] - def __str__(self): short_name_with_emojis = emojize(self.short_name, language="alias") return f"{self.pk}: {short_name_with_emojis}" diff --git a/engine/apps/alerts/tests/test_alert_receiver_channel.py b/engine/apps/alerts/tests/test_alert_receiver_channel.py index a4628cb7..7e38766a 100644 --- a/engine/apps/alerts/tests/test_alert_receiver_channel.py +++ b/engine/apps/alerts/tests/test_alert_receiver_channel.py @@ -220,3 +220,12 @@ def test_alertmanager_available_for_heartbeat(make_organization, make_alert_rece organization = make_organization() alert_receive_channel = make_alert_receive_channel(organization, integration=integration) assert alert_receive_channel.is_available_for_integration_heartbeat + + +@pytest.mark.django_db +def test_delete_duplicate_names(make_organization, make_alert_receive_channel): + """Check that it's possible to delete two integrations with the same name at once.""" + organization = make_organization() + for _ in range(2): + make_alert_receive_channel(organization, verbal_name="duplicate") + organization.alert_receive_channels.all().delete()