虎牙支持先导入账号密码再登录
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
"""虎牙账号增加密码导入字段
|
||||
|
||||
Revision ID: 20260705_0006
|
||||
Revises: 20260704_0005
|
||||
Create Date: 2026-07-05
|
||||
"""
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
|
||||
|
||||
revision: str = "20260705_0006"
|
||||
down_revision: Union[str, None] = "20260704_0005"
|
||||
branch_labels: Union[str, Sequence[str], None] = None
|
||||
depends_on: Union[str, Sequence[str], None] = None
|
||||
|
||||
|
||||
def _has_table(bind, table_name: str) -> bool:
|
||||
return sa.inspect(bind).has_table(table_name)
|
||||
|
||||
|
||||
def _columns(bind, table_name: str) -> set[str]:
|
||||
if not _has_table(bind, table_name):
|
||||
return set()
|
||||
return {column["name"] for column in sa.inspect(bind).get_columns(table_name)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "account_password" not in _columns(bind, "huya_accounts"):
|
||||
op.add_column(
|
||||
"huya_accounts",
|
||||
sa.Column("account_password", sa.Text(), nullable=True),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if "account_password" in _columns(bind, "huya_accounts"):
|
||||
op.drop_column("huya_accounts", "account_password")
|
||||
Reference in New Issue
Block a user