Looking to Clear/Reset Issue History

We are moving a project from a secure zone to a public zone. Some of the issues previously had sensitive data in them, but have modified for public consumption. We would like to clear the history/changelog, so the previous changes cannot be seen.

We have the project on an interim server, so we can pretty much do whatever.. I've just not seen a clear answer on how to perform this.

3 answers

1 accepted

1 votes

Only way of doing this is to drop the records out of the history using SQL. You'll need to find the stuff you want to destroy in "changeitem" and then check the associated "changegroup" record - if it has no changeitems left, then you should remove that too. For comments, jiraaction is the table to look at. I would not recommend touching anything else though, I don't know them well enough.

Normally, I warn people off SQL tinkering, but in this case, it is moderately safe as long as you keep the changegroup/item relationship above clean. The history is not directly used a lot and there aren't associated counters to update for deleteion. You really do need to do the standard Jira/SQL routine though - shut down Jira, backup the database, prove you can restore it, run your SQL, restart Jira and do a full re-index.

Nic, would you recommend certain documentation to get queries from for this, or a certain command to clear the tables?

Sorry, I was half understanding what I was typing. I was essentially asking if you were using "DELETE FROM" or "TRUNCATE" or "REPLACE", whathaveyou. I ended up doing this with "DELETE FROM" and it worked well.

Not sure what you mean by "certain documentation to get queries from this". If you delete the history data, it's gone, dead, never to be recovered, so there's no queries you can run on it after you destroy it.

I'm not sure about "certain command" either. I would like to jump on the "clear the tables" clause - you absolutely do NOT want to do this. The aim is to destroy some historical data, not the entire system. So you run deletes in SQL to remove the lines you know you don't want.

Ah, I see. Yes, it's definitely "delete from ... Where ..."

If you have script runner plugin you can run the following. replace ABC-1234 with your own issue key. Don't forget to test it in a test env first.

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.component.ComponentAccessor
def issueManager = ComponentAccessor.getIssueManager()
Issue issue = issueManager.getIssueObject("ABC-1234")
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
changeHistoryManager.removeAllChangeItems(issue)

Er, that won't actually work - this question is about a version where those calls are different.

I've just run this script from Ravi in 7.1.8 which works (thanks!). 

I was just wondering if there is a way to specify a particular entry from the change history rather than all of the change history?

0 votes
Joe Wai Tye Atlassian Team Jun 12, 2014

Hmm, as far as I know, there really isn't any method to do this except to perform some queries on the database directly to erase them. However, as you might expect, this method can be a tad risky, as there could be quite a number of tables linked to each other that could affect this.

I'd recommend that yuo work with the DBA for this, and make sure you always have a backup on hand, in case anything goes awry.

Suggest an answer

Log in or Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

2,772 views 11 18
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot