✨ 新增回收站审计与八位取件码

This commit is contained in:
orion committed 2026-09-11 16:49:50 +08:00
1 parent 5e71cde60e
commit 6bc1c30797
17 files changed
+6309

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);
"""
)