0

We're spinning off a division and I want them to have a copy of the cases we worked on. How do I give them just one project.

flag

1 Answer

1

Find the project id you'd like to keep and run these delete statements, which will delete everything not associated with a given project. Note that wikis and discussion groups should be unaffected.

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 = 123);
DELETE FROM BugEvent  
  WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM BugView  
  WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM BugRelation  
  WHERE ixBugFrom NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM BugRelation  
  WHERE ixBugTo NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM Duplicates  
  WHERE ixBugDupe NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM Duplicates  
  WHERE ixBugDupeOf NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM Scout WHERE ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM TagAssociation 
  WHERE ixBug > 0 AND ixBug NOT IN (SELECT ixBug FROM Bug WHERE ixProject=123);
DELETE FROM Bug WHERE ixProject <> 123;

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.