1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-25 14:50:29 +00:00

Update clean_db_records.py (#6902)

This commit is contained in:
Ranjiwei
2024-10-15 15:54:10 +08:00
committed by GitHub
parent 5c00fa2607
commit 3d448b094b

View File

@@ -18,6 +18,7 @@ class Command(BaseCommand):
clean_sql4 = "DELETE FROM FileUpdate WHERE to_days(now()) - to_days(timestamp) > 90" clean_sql4 = "DELETE FROM FileUpdate WHERE to_days(now()) - to_days(timestamp) > 90"
clean_sql5 = "DELETE FROM FileHistory WHERE to_days(now()) - to_days(timestamp) > 90" clean_sql5 = "DELETE FROM FileHistory WHERE to_days(now()) - to_days(timestamp) > 90"
clean_sql6 = "DELETE FROM PermAudit WHERE to_days(now()) - to_days(timestamp) > 90" clean_sql6 = "DELETE FROM PermAudit WHERE to_days(now()) - to_days(timestamp) > 90"
clean_sql7 = "DELETE FROM FileTrash WHERE to_days(now()) - to_days(delete_time) > 90"
def handle(self, *args, **options): def handle(self, *args, **options):
logger.debug('Start clean database records.') logger.debug('Start clean database records.')
@@ -35,6 +36,7 @@ class Command(BaseCommand):
cursor.execute(self.clean_sql4) cursor.execute(self.clean_sql4)
cursor.execute(self.clean_sql5) cursor.execute(self.clean_sql5)
cursor.execute(self.clean_sql6) cursor.execute(self.clean_sql6)
cursor.execute(self.clean_sql7)
except Exception as e: except Exception as e:
logger.error('Failed to clean database records, error: %s.' % e) logger.error('Failed to clean database records, error: %s.' % e)
self.stderr.write('[%s] Failed to clean database records, error: %s.' % (datetime.now(), e)) self.stderr.write('[%s] Failed to clean database records, error: %s.' % (datetime.now(), e))