✨ 新增回收站审计与八位取件码
This commit is contained in:
1 parent
c25c495657
commit
4ee06e2d29
15 files changed
+534
-132
No files matched your search
@@ -0,0 +1,24 @@
|
||||
from tortoise import connections
|
||||
|
||||
|
||||
async def migrate():
|
||||
conn = connections.get("default")
|
||||
result = await conn.execute_query("PRAGMA table_info(filecodes)")
|
||||
columns = {row[1] for row in (result[1] if result and len(result) > 1 else [])}
|
||||
additions = [
|
||||
("is_trashed", "BOOLEAN NOT NULL DEFAULT 0"),
|
||||
("trashed_at", "TIMESTAMP NULL"),
|
||||
("trash_expires_at", "TIMESTAMP NULL"),
|
||||
("trash_reason", "VARCHAR(32) NULL"),
|
||||
("trash_original_path", "VARCHAR(1024) NULL"),
|
||||
("trash_purged_at", "TIMESTAMP NULL"),
|
||||
]
|
||||
for name, definition in additions:
|
||||
if name not in columns:
|
||||
await conn.execute_query(f"ALTER TABLE filecodes ADD COLUMN {name} {definition}")
|
||||
await conn.execute_script(
|
||||
"""
|
||||
CREATE INDEX IF NOT EXISTS idx_filecodes_is_trashed ON filecodes(is_trashed);
|
||||
CREATE INDEX IF NOT EXISTS idx_filecodes_trash_expires_at ON filecodes(trash_expires_at);
|
||||
"""
|
||||
)
|
||||
Reference in new issue
Block a user