0

Previously my colleague asked to delete all bug reports except for one project. I would like to know how to have multiple projects available to send. I.E. not delete 2 Bug reports. this was his question: http://fogbugz.stackexchange.com/questions/3245/how-do-i-clear-my-database-of-all-but-one-project

flag
Thanks, that was exactly what i was looking for – Tyler Jun 17 2010 at 15:41

1 Answer

1

Do you mean delete all cases in all projects except project A and project B?

If so, you can modify the SQL from the other post. Wherever it says ixProject = 123, you want ixProject IN (123,456) and change DELETE FROM Bug WHERE ixProject <> 123; to include both projects: DELETE FROM Bug WHERE ixProject NOT IN (123,456);

DELETE FROM Attachment  
  WHERE ixBugEvent > 0 AND ixBugEvent NOT IN  
  (SELECT BugEvent.ixBugEvent FROM BugEvent  
    LEFT JOIN Bug ON Bug.ixBug = BugEvent.ixBug  
    WHERE Bug.ixProject IN (123,456));
DELETE FROM BugEvent  
  WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM BugView  
  WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM BugRelation  
  WHERE ixBugFrom NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM BugRelation  
  WHERE ixBugTo NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM Duplicates  
  WHERE ixBugDupe NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM Duplicates  
  WHERE ixBugDupeOf NOT IN (SELECT ixBug FROM Bug WHERE ixProject in (123,456));
DELETE FROM Scout WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM TagAssociation 
  WHERE ixBug > 0 AND ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject IN (123,456));
DELETE FROM Bug WHERE ixProject NOT IN (123,456);

You probably also want to run:

DELETE FROM Mailbox;
DELETE FROM MailQueue;

This will prevent the duplicate database from checking the mailboxes of the original.

link|flag

Your Answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.