[RCD] db maintenance when removing a mailbox

A.L.E.C alec at alec.pl
Fri Feb 18 08:24:57 CET 2011


On 18.02.2011 03:24, ben at electricembers.net wrote:

> SELECT user_id FROM users WHERE username LIKE '$ARGV'
> UPDATE identities SET del=1 WHERE user_id = '$user_id'
> DELETE FROM cache WHERE user_id = '$user_id'
> UPDATE contacts SET del=1 WHERE user_id = '$user_id' 
> UPDATE contactgroups SET del=1 WHERE user_id = '$user_id' 
> DELETE FROM messages WHERE user_id = '$user_id'
> 
> ??DELETE FROM users WHERE username = '$ARGV' LIMIT 1??
> 
> This last line is where I get stuck because I don't really want to delete 
> it, but there is no del column to mark. . .

When you delete a user record all related records in other tables will
be auto-removed because of foreign key constraints.

We would probably need to add users.del column, but there will be a
problem with uniqueness constraint (or creation of the same user will
fail until you remove the original record). I don't know if this is a
real problem.
Then all you need will be just to set this column.

-- 
Aleksander 'A.L.E.C' Machniak
LAN Management System Developer [http://lms.org.pl]
Roundcube Webmail Developer  [http://roundcube.net]
---------------------------------------------------
PGP: 19359DC1 @@ GG: 2275252 @@ WWW: http://alec.pl
_______________________________________________
List info: http://lists.roundcube.net/dev/
BT/aba52c80



More information about the Dev mailing list