# Moving the default notification state for a tag gives error

**URL:** https://meta.discourse.org/t/moving-the-default-notification-state-for-a-tag-gives-error/326069
**Category:** Bug
**Tags:** fixed
**Created:** [September 11, 2024, 7:33pm UTC](https://meta.discourse.org/t/moving-the-default-notification-state-for-a-tag-gives-error/326069 "2024-09-11T19:33:53Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [September 11, 2024, 7:33pm UTC](https://meta.discourse.org/t/moving-the-default-notification-state-for-a-tag-gives-error/326069/1 "2024-09-11T19:33:53Z")

</div>

- Go to the “tags default notifications” for a group
- Add a tag to “watching”
- Save

 ![image](https://global.discourse-cdn.com/meta/original/4X/5/c/4/5c4948d6be883902d38f7a7de238619078292597.png)

- Remove the tag from “watching”
- Add the same tag to “tracking”
- Save

 ![image](https://global.discourse-cdn.com/meta/original/4X/3/f/7/3f7e4574594503e1fceb8504b31e44e06fb80cf8.png)

`ActiveRecord::RecordNotUnique (PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "idx_group_tag_notification_defaults_unique" DETAIL: Key (group_id, tag_id)=(45, 36) already exists.`

Looks like the code does not first remove the records that need to be removed and then adds the records that need to be added, but tries to do it all at once.

Pressing “Save” in between removing it and adding it works around the issue.

The interface in user preferences does not allow this by the way, you are unable to select it for another category if you just removed it - you are **forced** to press Save first.

---

<div class="post-metadata">

### Author: ![jancernik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jancernik/32/275892_2.png) [@jancernik](https://meta.discourse.org/u/jancernik)
#### Post date: [September 13, 2024, 7:02pm UTC](https://meta.discourse.org/t/moving-the-default-notification-state-for-a-tag-gives-error/326069/5 "2024-09-13T19:02:57Z")

</div>

Hi @RGJ, thanks for the report!  
This should be fixed after:  
[https://github.com/discourse/discourse/commit/0c019b2e45787b9062605904e4a9dff07b4f2331](https://github.com/discourse/discourse/commit/0c019b2e45787b9062605904e4a9dff07b4f2331)

---

<div class="post-metadata">

### Author: ![jancernik](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jancernik/32/275892_2.png) [@jancernik](https://meta.discourse.org/u/jancernik)
#### Post date: [September 17, 2024, 8:03pm UTC](https://meta.discourse.org/t/moving-the-default-notification-state-for-a-tag-gives-error/326069/6 "2024-09-17T20:03:07Z")

</div>

This topic was automatically closed after 4 days. New replies are no longer allowed.
