优化(账号自动化): 履约保护登录配额与重登优先级
This commit is contained in:
@@ -537,6 +537,10 @@
|
||||
"20261125_0134_login_task_logs.py": {
|
||||
"revision": "20261125_0134",
|
||||
"sha256": "c21a4833874676b08a9156e20cfb89c2786aece628d998e8a1bf87a8d0b3cd4b"
|
||||
},
|
||||
"20261125_0135_protected_login_quota_limits.py": {
|
||||
"revision": "20261125_0135",
|
||||
"sha256": "8bc4b6a5e9952087e6a18f038f1cb4a054bf25feed311677c94ffcbd1b5711f2"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
Reference in New Issue
Block a user