PropertySet: how to remove my-setting value for all users?

I need to store a my-setting value per a user. I.e. some users might set it and some don’t.

I found PropertySet, which allows to store a propertyset per a user. Good. It stores values in propertyentry and propertystring db tables. Fine.

Also I need to reset my-setting value for all users. If I had a straight access to db, then I would execute just one SQL query

delete pe, ps from propertyentry as pe inner join propertystring as ps on pe.ID=ps.ID where pe.PROPERTY_KEY = "my-setting-name";"

Unfortunately UserSearchService doesn’t allow to do it. So I have to loop through all users and remove my-setting value for each user separately.

Question 1: Is there analogue of “delete pe, ps from propertyentry as pe inner join propertystring as ps on pe.ID=ps.ID where pe.PROPERTY_KEY = “my-setting-name”;” in Jira API?

Question 2: I expected, that PropertySet would remove whole propertyset, when a user has been deleted. But it doesn’t happen. hm… Is it expected behaviour. Why PropertySet created with help of UserSearchService is not responsible for this?

In other words, why I still see the next in db table propertyentry even if user=10100 is deleted?

+-------+-----------------+-----------+--------------------+--------------+
| ID    | ENTITY_NAME     | ENTITY_ID | PROPERTY_KEY       | propertytype | 
+-------+-----------------+-----------+--------------------+--------------+
| 10614 | ApplicationUser |     10000 | my-setting-key |            5 | 
| 10620 | ApplicationUser |     10100 | my-setting-key |            5 | 
+-------+-----------------+-----------+--------------------+--------------+
2 Likes