mirror of
https://github.com/QingdaoU/OnlineJudge.git
synced 2024-12-28 16:12:13 +00:00
migration to delete user output
u need to run “vacuum full submission” to reduce db file size
This commit is contained in:
parent
df50662b97
commit
09c8819c4e
24
submission/migrations/0009_delete_user_output.py
Normal file
24
submission/migrations/0009_delete_user_output.py
Normal file
@ -0,0 +1,24 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from django.db import migrations
|
||||
|
||||
|
||||
def delete_user_output(apps, schema_editor):
|
||||
Submission = apps.get_model("submission", "Submission")
|
||||
for item in Submission.objects.all():
|
||||
if "data" in item.info and isinstance(item.info["data"], list):
|
||||
for index in range(len(item.info["data"])):
|
||||
item.info["data"][index]["output"] = ""
|
||||
item.save()
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('submission', '0008_submission_ip'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.RunPython(delete_user_output, reverse_code=migrations.RunPython.noop)
|
||||
]
|
Loading…
Reference in New Issue
Block a user