How to delete a client

From ISPWiki
Jump to: navigation, search

Execute the following queries to the database to delete a test client:

set @account_id = КОД_КЛИЕНТА;
DELETE FROM expense WHERE subaccount IN (SELECT id FROM subaccount WHERE account = @account_id);
DELETE FROM payment WHERE subaccount IN (SELECT id FROM subaccount WHERE account = @account_id);
DELETE FROM billorder WHERE subaccount IN (SELECT id FROM subaccount WHERE account = @account_id);
UPDATE ip SET item = NULL WHERE item IN (SELECT id FROM item WHERE account = @account_id OR parent IN (SELECT id FROM item WHERE account = @account_id));
DELETE FROM item WHERE parent IN (SELECT id FROM (SELECT id FROM item WHERE account = @account_id) itm);
DELETE FROM item WHERE account = @account_id;
DELETE FROM service_profile WHERE account = @account_id;
DELETE FROM invoice WHERE customer IN (SELECT id FROM profile WHERE account = @account_id);
DELETE FROM profile WHERE account = @account_id;
DELETE FROM ticket WHERE account_client = @account_id;
DELETE FROM user WHERE account = @account_id;
DELETE FROM affiliatereward WHERE account = @account_id OR referal = @account_id;
DELETE FROM account WHERE id = @account_id;

The whole client history will be deleted, including his billing and support history. User configuration files, avatars, and ticket attachments won't be deleted.