Skip to content

Commit e80be56

Browse files
committed
fix: #362
1 parent 69972e2 commit e80be56

File tree

4 files changed

+248
-157
lines changed

4 files changed

+248
-157
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from tortoise import connections
2+
3+
4+
async def add_save_path_to_uploadchunk():
5+
conn = connections.get("default")
6+
await conn.execute_script(
7+
"""
8+
ALTER TABLE uploadchunk ADD COLUMN save_path VARCHAR(512) NULL;
9+
"""
10+
)
11+
12+
13+
async def migrate():
14+
await add_save_path_to_uploadchunk()

apps/base/models.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ class UploadChunk(models.Model):
4949
file_size = fields.BigIntField()
5050
chunk_size = fields.IntField()
5151
file_name = fields.CharField(max_length=255)
52+
save_path = fields.CharField(max_length=512, null=True)
5253
created_at = fields.DatetimeField(auto_now_add=True)
5354
completed = fields.BooleanField(default=False)
5455

@@ -66,6 +67,7 @@ class KeyValue(Model):
6667

6768
class PresignUploadSession(models.Model):
6869
"""预签名上传会话模型"""
70+
6971
id = fields.IntField(pk=True)
7072
upload_id = fields.CharField(max_length=36, unique=True, index=True)
7173
file_name = fields.CharField(max_length=255)
@@ -85,4 +87,6 @@ async def is_expired(self):
8587
file_codes_pydantic = pydantic_model_creator(FileCodes, name="FileCodes")
8688
upload_chunk_pydantic = pydantic_model_creator(UploadChunk, name="UploadChunk")
8789
key_value_pydantic = pydantic_model_creator(KeyValue, name="KeyValue")
88-
presign_upload_session_pydantic = pydantic_model_creator(PresignUploadSession, name="PresignUploadSession")
90+
presign_upload_session_pydantic = pydantic_model_creator(
91+
PresignUploadSession, name="PresignUploadSession"
92+
)

0 commit comments

Comments
 (0)