feat(douyu): 增加协作单礼包字典与权限控制
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
"""斗鱼外部单协作的礼包字典。
|
||||
|
||||
接口暂时不返回礼包信息,新建协作单时需要手填标准礼包名和所需积分。
|
||||
这里把「名称 + 积分」做成可维护字典:管理员维护,客服只能选择;
|
||||
以后接口恢复返回商品时,两边的选项会一起出现在下拉里。
|
||||
|
||||
订单里仍存礼包名字(`douyu_external_orders.gift_name`),不是 id。
|
||||
改名会级联更新历史订单上的礼包名,但改积分**不回填**历史订单,
|
||||
避免影响已经形成的积分核账结果。
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision: str = "20261106_0066"
|
||||
down_revision: str | None = "20261106_0065"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
TABLE = "douyu_collab_gifts"
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if TABLE in set(sa.inspect(bind).get_table_names()):
|
||||
return
|
||||
op.create_table(
|
||||
TABLE,
|
||||
sa.Column("id", sa.Integer(), primary_key=True, autoincrement=True),
|
||||
sa.Column("name", sa.String(length=128), nullable=False),
|
||||
sa.Column("points", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("sort_order", sa.Integer(), nullable=False, server_default="0"),
|
||||
sa.Column("is_active", sa.Boolean(), nullable=False, server_default="1"),
|
||||
sa.Column("remark", sa.String(length=255), nullable=False, server_default=""),
|
||||
sa.Column("created_by", sa.Integer(), nullable=True),
|
||||
sa.Column("updated_by", sa.Integer(), nullable=True),
|
||||
sa.Column("created_at", sa.DateTime(), nullable=False),
|
||||
sa.Column("updated_at", sa.DateTime(), nullable=False),
|
||||
)
|
||||
op.create_index(f"ix_{TABLE}_name", TABLE, ["name"], unique=True)
|
||||
op.create_index(f"ix_{TABLE}_is_active", TABLE, ["is_active"])
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
bind = op.get_bind()
|
||||
if TABLE in set(sa.inspect(bind).get_table_names()):
|
||||
# MySQL 删表会连索引一起删。
|
||||
op.drop_table(TABLE)
|
||||
Reference in New Issue
Block a user