加密敏感数据并优化补CK流程

This commit is contained in:
yml2213
2026-06-24 09:10:31 +08:00
parent 8e65af538c
commit 177ec42416
9 changed files with 315 additions and 23 deletions
+11
View File
@@ -35,6 +35,7 @@ def init_db():
"""执行数据库迁移 + 写入初始数据。"""
run_migrations()
_seed()
_encrypt_existing_sensitive_data()
def run_migrations():
@@ -70,3 +71,13 @@ def _seed():
db.commit()
finally:
db.close()
def _encrypt_existing_sensitive_data():
"""启动时把历史明文敏感数据迁移为密文。"""
from loguru import logger
from .crypto_storage import encrypt_existing_sensitive_data
changed = encrypt_existing_sensitive_data(engine)
if changed:
logger.info(f"已加密历史敏感字段: {changed} 个值")