-
Notifications
You must be signed in to change notification settings - Fork 15
Crap Database Entries Cleanup
Simple, because they are not being deleted by v7 itself. Honestly they are harmless and only occupy database space. Unfortunately this can change easily, like when you start using those relationship with some addons/modules or when you try to export/import database tables those nice harmless records become a problem.
You can have some automation for cleaning them up periodically, like maybe every night with cron or weekly, monthly it is up you as the admin of the VA. Also you can use the queries here at your database workbench tool whenever you need to. Technically there will be no difference between a cron/automation and a manual cleanup.
Personally I have them in my cron tasks, some running every night some each month, so I am ok with deleting old and useless records. Below you can find the simplified versions of the queries I use.
DELETE
FROM acars
WHERE pirep_id NOT IN (SELECT id FROM pireps);
DELETE
FROM flight_subfleet
WHERE flight_id NOT IN (SELECT id FROM flights);
DELETE
FROM flight_subfleet
WHERE subfleet_id NOT IN (SELECT id FROM subfleets);
DELETE
FROM flight_fare
WHERE flight_id NOT IN (SELECT id FROM flights);
DELETE
FROM flight_fare
WHERE fare_id NOT IN (SELECT id FROM fares);
DELETE
FROM subfleet_fare
WHERE subfleet_id NOT IN (SELECT id FROM subfleets);
DELETE
FROM subfleet_fare
WHERE fare_id NOT IN (SELECT id FROM fares);
DELETE
FROM subfleet_rank
WHERE subfleet_id NOT IN (SELECT id FROM subfleets);
DELETE
FROM subfleet_rank
WHERE rank_id NOT IN (SELECT id FROM ranks);
DELETE
FROM typerating_subfleet
WHERE subfleet_id NOT IN (SELECT id FROM subfleets);
DELETE
FROM typerating_user
WHERE user_id NOT IN (SELECT id FROM users);
DELETE
FROM user_field_values
WHERE user_id NOT IN (SELECT id FROM users);