加密敏感数据并优化补CK流程
This commit is contained in:
@@ -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} 个值")
|
||||
|
||||
Reference in New Issue
Block a user