1
0
mirror of https://github.com/haiwen/seahub.git synced 2025-09-19 10:26:17 +00:00

truncate table related_files_relatedfiles (#5604)

* truncate table related_files_relatedfiles

* check whether dry run
This commit is contained in:
WJH
2023-08-23 15:41:31 +08:00
committed by GitHub
parent e0ece547e2
commit e75f9d2679

View File

@@ -277,7 +277,7 @@ class Command(BaseCommand):
cursor.execute(sql, (invalid_repo_ids, i, 1000))
res = cursor.fetchall()
except Exception as e:
self.stderr.write('[%s] Failed to query invalid uuid of %s, error: tags_fileuuidmap.' %
self.stderr.write('[%s] Failed to query invalid uuid of tags_fileuuidmap, error: %s.' %
(datetime.now(), e))
return
@@ -293,6 +293,19 @@ class Command(BaseCommand):
if clean_up_success is False:
return
# truncate related_files_relatedfiles
self.stdout.write('[%s] Start to truncate table related_files_relatedfiles.' % datetime.now())
if dry_run == 'false':
truncate_sql = """TRUNCATE TABLE related_files_relatedfiles"""
try:
with connection.cursor() as cursor:
cursor.execute(truncate_sql)
except Exception as e:
self.stderr.write('[%s] Failed to truncate table related_files_relatedfiles, error: %s.' %
(datetime.now(), e))
return
self.stdout.write('[%s] Successfully truncated table related_files_relatedfiles.' % datetime.now())
self.stdout.write('[%s] Successfully cleaned up tables associated with the tags_fileuuidmap.' %
datetime.now())