diff --git a/zephyr/management/commands/expunge_db.py b/zephyr/management/commands/expunge_db.py new file mode 100644 index 0000000000..bbccc364ea --- /dev/null +++ b/zephyr/management/commands/expunge_db.py @@ -0,0 +1,11 @@ +from django.core.management.base import BaseCommand +from zephyr.retention_policy import get_UserMessages_to_expunge +from zephyr.models import Message + +class Command(BaseCommand): + help = ('Expunge old UserMessages and Messages from the database, ' + + 'according to the retention policy.') + + def handle(self, *args, **kwargs): + get_UserMessages_to_expunge().delete() + Message.remove_unreachable()