38 lines
1.0 KiB
Python
38 lines
1.0 KiB
Python
"""斗鱼和平小店账号新增扭蛋碎片字段
|
|
|
|
Revision ID: 20260807_0017
|
|
Revises: 20260806_0016
|
|
Create Date: 2026-08-07
|
|
"""
|
|
|
|
from typing import Sequence, Union
|
|
|
|
from alembic import op
|
|
import sqlalchemy as sa
|
|
|
|
|
|
revision: str = "20260807_0017"
|
|
down_revision: Union[str, None] = "20260806_0016"
|
|
branch_labels: Union[str, Sequence[str], None] = None
|
|
depends_on: Union[str, Sequence[str], None] = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
bind = op.get_bind()
|
|
if not sa.inspect(bind).has_table("accounts"):
|
|
return
|
|
columns = {column["name"] for column in sa.inspect(bind).get_columns("accounts")}
|
|
if "xpd_fragments" not in columns:
|
|
op.add_column(
|
|
"accounts", sa.Column("xpd_fragments", sa.Integer(), nullable=True)
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
bind = op.get_bind()
|
|
if not sa.inspect(bind).has_table("accounts"):
|
|
return
|
|
columns = {column["name"] for column in sa.inspect(bind).get_columns("accounts")}
|
|
if "xpd_fragments" in columns:
|
|
op.drop_column("accounts", "xpd_fragments")
|