优化(账号自动化): 履约保护登录配额与重登优先级

This commit is contained in:
yml
2026-11-25 22:13:21 +08:00
parent 0943b7a362
commit 9bdd2f4e1a
25 changed files with 1510 additions and 193 deletions
@@ -0,0 +1,56 @@
"""为履约保护失效重登与快过期续期新增独立的每日登录预算列。"""
from __future__ import annotations
import sqlalchemy as sa
from alembic import op
revision: str = "20261125_0135"
down_revision: str | None = "20261125_0134"
branch_labels: str | None = None
depends_on: str | None = None
TABLE = "login_quota_settings"
def _column_exists(name: str) -> bool:
conn = op.get_bind()
count = conn.execute(
sa.text(
"SELECT COUNT(*) FROM information_schema.columns "
"WHERE table_schema = DATABASE() AND table_name = :table "
"AND column_name = :name"
),
{"table": TABLE, "name": name},
).scalar()
return bool(count)
def upgrade() -> None:
if not _column_exists("relogin_protected_daily_limit"):
op.add_column(
TABLE,
sa.Column(
"relogin_protected_daily_limit",
sa.Integer(),
nullable=False,
server_default="500",
),
)
if not _column_exists("lease_refresh_daily_limit"):
op.add_column(
TABLE,
sa.Column(
"lease_refresh_daily_limit",
sa.Integer(),
nullable=False,
server_default="300",
),
)
def downgrade() -> None:
if _column_exists("lease_refresh_daily_limit"):
op.drop_column(TABLE, "lease_refresh_daily_limit")
if _column_exists("relogin_protected_daily_limit"):
op.drop_column(TABLE, "relogin_protected_daily_limit")