fix(platform): 持久化并完善斗鱼兑换结果图片
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
"""履约任务保存兑换结果图片。"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import sqlalchemy as sa
|
||||
from alembic import op
|
||||
|
||||
revision = "20261121_0105"
|
||||
down_revision = "20261121_0104"
|
||||
branch_labels = None
|
||||
depends_on = None
|
||||
|
||||
|
||||
def _column_exists(column: str) -> bool:
|
||||
return bool(
|
||||
op.get_bind()
|
||||
.execute(
|
||||
sa.text(
|
||||
"""
|
||||
SELECT COUNT(*)
|
||||
FROM information_schema.columns
|
||||
WHERE table_schema = DATABASE()
|
||||
AND table_name = 'platform_fulfillment_tasks'
|
||||
AND column_name = :column
|
||||
"""
|
||||
),
|
||||
{"column": column},
|
||||
)
|
||||
.scalar()
|
||||
)
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
if not _column_exists("exchange_result_image_key"):
|
||||
op.add_column(
|
||||
"platform_fulfillment_tasks",
|
||||
sa.Column(
|
||||
"exchange_result_image_key",
|
||||
sa.String(length=512),
|
||||
nullable=False,
|
||||
server_default="",
|
||||
),
|
||||
)
|
||||
if not _column_exists("exchange_result_image_saved_at"):
|
||||
op.add_column(
|
||||
"platform_fulfillment_tasks",
|
||||
sa.Column(
|
||||
"exchange_result_image_saved_at",
|
||||
sa.DateTime(),
|
||||
nullable=True,
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
if _column_exists("exchange_result_image_saved_at"):
|
||||
op.drop_column("platform_fulfillment_tasks", "exchange_result_image_saved_at")
|
||||
if _column_exists("exchange_result_image_key"):
|
||||
op.drop_column("platform_fulfillment_tasks", "exchange_result_image_key")
|
||||
Reference in New Issue
Block a user