It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Any way to bulk remove drafts in confluence?

I have approx 100 drafts and would like to bulk remove them.

And I'd like to provide this option to our users.

2 answers

Hi Anne,

You can easily deduct the SQL you need from the SQL on that page.

You'll need to do the following :

  1. select * into temp_conf from CONTENT where CONTENTTYPE='DRAFT' (maybe change this to how it works in you DB)
  2. DELETE FROM BODYCONTENT where CONTENTID IN (select CONTENTID from temp_conf);
  3. DELETE from ATTACHMENTS where PAGEID in (select CONTENTID from temp_conf);
  4. DELETE from CONTENT where CONTENTID in (select CONTENTID from temp_conf);

Keep in mind that doing stuff in your database is not something you should consider doing lightly and is completely at your own risk.

Please take a backup before doing any changes.

Best regards,

Peter

Thanks - unfortunately this is nothing I can provide to our users.

 

Like Deb Hanrahan likes this

This is so essential when your application creates a draft every time you open a page for editing.  In general, I've noticed that Atlassian software is *severely* lacking when it comes to bulk editing functionality *cough jira cough*. 

Like Deb Hanrahan likes this

USE <<ConfluenceDatabase>>

BEGIN TRANSACTION
SELECT * INTO #temp_conf FROM CONTENT WHERE (SPACEID = <<SPACEID>>) AND (CONTENTTYPE = 'PAGE') AND (CONTENT_STATUS = 'draft')

DELETE FROM CONTENT_LABEL WHERE CONTENTID IN (SELECT CONTENTID FROM #temp_conf);


DELETE FROM CONFANCESTORS WHERE DESCENDENTID IN (SELECT CONTENTID FROM #temp_conf);


DELETE FROM USERCONTENT_RELATION WHERE TARGETCONTENTID in (SELECT CONTENTID FROM #temp_conf);


DELETE FROM LINKS WHERE CONTENTID in (SELECT CONTENTID FROM #temp_conf);


DELETE FROM CONTENTPROPERTIES WHERE CONTENTID in (SELECT CONTENTID FROM #temp_conf)


DELETE FROM BODYCONTENT WHERE CONTENTID IN (SELECT CONTENTID FROM #temp_conf);


DELETE FROM CONTENT WHERE CONTENTID in (SELECT CONTENTID FROM #temp_conf);


DROP TABLE #temp_conf
--COMMIT TRANSACTION
ROLLBACK TRANSACTION

 

This worked for us in 6.14.2

Thanks, but still: This is a solution with database access, we need an option for our endusers.

You could create an interface around this that does the database call on their behave.  Then they access the interface to do this.   I don't know your environment, but you could create a secure REST service that does the SQL and then put a link to that REST service.  That REST service would use what ever authentication model you want to use (Active Directory, Cerfificates, ....) and that would allow you to protect against unauthorized use of this.

Like Anne EQS likes this

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Confluence

Lessons and Learnings: Six Months of Working Remote [Discussion]

Hey there, folks! For most of us, the past six months- yes, you read that right- have been a journey. More people than ever before have pivoted to working remotely, and navigating being on-scre...

8,341 views 6 6
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you