完善虎牙外部单展示、状态恢复与礼包配置
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
"""虎牙积分中心活动参数改为可配置。
|
||||
|
||||
礼包页签会随活动调整;pageCode/sourceId/scene 及可选 pageId/tabIds
|
||||
放进 ``huya_config``,避免每次换活动都改代码。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20261111_0076"
|
||||
down_revision: str | None = "20261109_0075"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
TABLE = "huya_config"
|
||||
COLUMNS: tuple[tuple[str, sa.String, str], ...] = (
|
||||
("points_page_code", sa.String(length=128), "heping_baodian_credit_center_page"),
|
||||
("points_source_id", sa.String(length=64), "yellowcarlist"),
|
||||
("points_scene", sa.String(length=16), "7"),
|
||||
("points_page_id", sa.String(length=32), ""),
|
||||
("points_tab_ids", sa.String(length=256), ""),
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if not inspector.has_table(TABLE):
|
||||
return
|
||||
existing = {column["name"] for column in inspector.get_columns(TABLE)}
|
||||
for name, column_type, default in COLUMNS:
|
||||
if name in existing:
|
||||
continue
|
||||
op.add_column(
|
||||
TABLE,
|
||||
sa.Column(
|
||||
name,
|
||||
column_type,
|
||||
nullable=False,
|
||||
server_default=default,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
inspector = sa.inspect(op.get_bind())
|
||||
if not inspector.has_table(TABLE):
|
||||
return
|
||||
existing = {column["name"] for column in inspector.get_columns(TABLE)}
|
||||
for name, _column_type, _default in reversed(COLUMNS):
|
||||
if name in existing:
|
||||
op.drop_column(TABLE, name)
|
||||
Reference in New Issue
Block a user