Closed mzanella closed 6 years ago
What does it mean Orphan Wallet (!= -1)?
Delete the accounts that do not have an AccountWallet anymore and consequently remove also the information related to them.
DROP TABLE IF EXISTS _Variables;
CREATE TEMP TABLE _Variables(account_id INTEGER, info_id INTEGER);
INSERT INTO _Variables ( account_id, info_id )
SELECT _id, info
FROM Account
WHERE _id not in
(SELECT a._id
FROM Account as a, AccountWallet as aw
WHERE aw.Account = a._id);
DELETE FROM Account WHERE _id in (SELECT account_id FROM _Variables);
DELETE FROM Information WHERE _id in (SELECT info_id FROM _Variables);
DROP TABLE _Variables;
delete orphan information
DROP TABLE IF EXISTS _Variables;
CREATE TEMP TABLE _Variables(info_id INTEGER);
INSERT INTO _Variables ( info_id )
SELECT _id
FROM Information
WHERE _id not in
(SELECT info
FROM Account as a);
DELETE FROM Information WHERE _id in (SELECT info_id FROM _Variables);
DROP TABLE _Variables;
Walllet
(!=-1)AccountWallet
Account
Information