Add new filter through mysql database (with insert statement)

José Da Costa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 15, 2018

Hi all,

I'm trying to add a new jira filter by using an insert statement directly on the Jira Mysql database.

Following the commands used:

INSERT INTO jiradb.searchrequest (id, filtername, authorname, username, reqcontent, FAV_COUNT, filtername_lower)
SELECT MAX(id) + 1, 'filter name', 'jirausername', 'jirausername', 'filter request',1,'filter name' FROM jiradb.searchrequest;

 

INSERT INTO jiradb.sharepermissions (id, entityid, entitytype, sharetype, PARAM1)
SELECT MAX(id) + 1, new id of new filter, 'SearchRequest', 'group', 'group name' FROM jiradb.sharepermissions;

 

All seems to be done successfully, but I'm not able to find this new filter on my Jira Filter Search page.

 

May I ask if someone know what's the missing step or the issue here?

 

Thanks.

2 answers

1 vote
Alexey Matveev
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
June 15, 2018

Hello,

You should not use Jira database to modify Jira data. Use Jira REST API to create a filter. You can use POST /rest/api/2/filter. You can find more info here:

https://docs.atlassian.com/software/jira/docs/api/REST/7.6.1/?_ga=2.265358281.754660632.1528872807-1659643416.1506407535#api/2/filter-createFilter

José Da Costa
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
June 15, 2018

Thanks for your reply... I've tried through the API and it works well to create a filter.

 

However there is a limitation, as you cannot change the permissions on the creation request.

So you have to do it manually or later if you can get the id of the new filter.

https://jira.atlassian.com/browse/JRASERVER-45485

 

Anyway it simplifies my current process.

 

Thanks.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 15, 2018

For your SQL to work, you will need to have Jira off-line while it is run, and you'll need to re-index in full (a locking index) after restarting it.  You're also missing stuff in your SQL which will cause you problems later, possibly some loss of data (although it won't be issue data)

Please, stick with the API to do this sort of thing.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events