/* Excluding accounts: instance.actor:instance.acc instance.Acc1::userAcc1 instance.Acc2::userAcc2 instance.BotAcc1:botAcc1 */ /* Tidy (DELETE FROM) the iceshrimp.net db drive_file table */ DELETE FROM public.drive_file df WHERE /* Don't remove any accounts with the following id's */ df."userId" NOT LIKE ALL(ARRAY['instance.acc', 'userAcc1', 'userAcc2', 'botAcc1']) OR df."userId" IS NULL; /* Tidy (DELETE FROM) the iceshrimp.net db user table */ DELETE FROM public.user u WHERE NOT EXISTS /* Remove any accounts that are neither followers nor followees */ (SELECT FROM public.following f WHERE f."followeeId" = u."id") AND /* Don't remove any accounts that are in the blocking table */ NOT EXISTS (SELECT FROM public.blocking b WHERE b."blockeeId" = u."id") AND /* Don't remove any accounts that are in the muting table */ NOT EXISTS (SELECT FROM public.muting m WHERE m."muteeId" = u."id") AND /* Don't remove any accounts with the following id's */ NOT (u."id" = ('instance.acc') OR u."id" = ('userAcc1') OR u."id" = ('userAcc2') OR u."id" = ('botAcc1')); /* Tidy (DELETE FROM) the iceshrimp.net db user table */ /* Remove any accounts that have moved */ DELETE FROM public."user" u WHERE "movedToUri" IS NOT NULL; /* Tidy (DELETE FROM) the iceshrimp.net db session table */ /* Keeping the (bot) sessions */ DELETE FROM public."session" WHERE "token" NOT LIKE 'botAcc1_TOKEN'; /* Tidy (TRUNCATE) the iceshrimp.net db tables: public.oauth_app public.oauth_token public.push_subscription */ TRUNCATE public.oauth_app, public.oauth_token, public.push_subscription; /* Tidy (VACUUM.ANALYZE) the iceshrimp.net db */ VACUUM ANALYZE;