🔧 chore: 同步完整后端运行模块

This commit is contained in:
orion committed 2026-09-11 17:13:03 +08:00
1 parent d104b9fc8b
commit 2d44699eec
20 files changed
+1465 -235

No files matched your search

+19
View File
@@ -0,0 +1,19 @@
from tortoise import connections
async def migrate():
conn = connections.get("default")
await conn.execute_script(
"""
CREATE TABLE IF NOT EXISTS storagereservation (
id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
token VARCHAR(64) NOT NULL UNIQUE,
size BIGINT NOT NULL,
expires_at TIMESTAMP NOT NULL
);
CREATE UNIQUE INDEX IF NOT EXISTS idx_storagereservation_token
ON storagereservation (token);
CREATE INDEX IF NOT EXISTS idx_storagereservation_expires_at
ON storagereservation (expires_at);
"""
)
@@ -0,0 +1,20 @@
from tortoise import connections
async def migrate():
conn = connections.get("default")
await conn.execute_script(
"""
CREATE TABLE IF NOT EXISTS share_code_reservations (
id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
code VARCHAR(255) NOT NULL UNIQUE,
file_code_id INT NULL,
reason VARCHAR(32) NOT NULL DEFAULT 'retired',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
);
CREATE INDEX IF NOT EXISTS idx_share_code_reservations_code
ON share_code_reservations(code);
CREATE INDEX IF NOT EXISTS idx_share_code_reservations_file_code_id
ON share_code_reservations(file_code_id);
"""
)
@@ -0,0 +1,14 @@
from tortoise import connections
async def migrate():
"""把既有审计日志中的取件码也登记为永久占用。"""
conn = connections.get("default")
await conn.execute_query(
"""
INSERT OR IGNORE INTO share_code_reservations (code, file_code_id, reason)
SELECT DISTINCT TRIM(code), file_code_id, 'historical_audit'
FROM transfer_stats
WHERE code IS NOT NULL AND TRIM(code) <> ''
"""
)