AW: Re: [rt-users] clean up user table

Gordon Messmer gmessmer at u.washington.edu
Tue Nov 27 11:27:24 EST 2007


Sven Sternberger wrote:
> oops!
> 
> On Di, 2007-11-27 at 10:07 +0100, Sven Sternberger wrote:
>> But rtx-shredder don't give you a simple way to delete all
>> users without a ticket, so you have to combine the select
>> statement from Gordon, and then call rtx-shredder
> 
> so Geordons sql statemaent is of course not correct
> (for most of us) we have a lot of valid users who never
> owned a ticket.
> So replace Ticket.owner with Transaction.creator, 
> which gives us all users where we deleted 
> their tickets via rtx-shredder.

Yep, I noticed that later. So far, the best I've got is this:

SELECT users.id
FROM users
WHERE users.id NOT IN
  (SELECT users.id
   FROM users
   INNER JOIN principals ON users.id = principals.id
   LEFT JOIN tickets ON principals.id = tickets.Owner
          OR principals.id = tickets.creator
   WHERE Tickets.id IS NOT NULL);

I still don't know how other relationships are tracked, like CCs?



More information about the rt-users mailing list