e1bd0e3ef7
改了什么:新增新版大盘日期窗口聚合、广告收益拆分、比价耗时字段、美团 CPS 拉单入库与大盘展示,并同步反馈审核和邀请奖励下线口径。 验证:python -m pytest tests/test_admin_read.py tests/test_admin_write.py tests/test_compare_record.py tests/test_invite.py tests/test_feedback.py -q。
79 lines
2.5 KiB
Python
79 lines
2.5 KiB
Python
"""feedback review fields
|
|
|
|
Revision ID: feedback_review_fields
|
|
Revises: coupon_daily_completion
|
|
Create Date: 2026-06-22 20:00:00.000000
|
|
|
|
"""
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
# revision identifiers, used by Alembic.
|
|
revision: str = "feedback_review_fields"
|
|
down_revision: str | Sequence[str] | None = "coupon_daily_completion"
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
with op.batch_alter_table("feedback", schema=None) as batch_op:
|
|
batch_op.add_column(sa.Column("reject_reason", sa.String(length=256), nullable=True))
|
|
batch_op.add_column(sa.Column("reward_coins", sa.Integer(), nullable=True))
|
|
batch_op.add_column(sa.Column("review_note", sa.String(length=256), nullable=True))
|
|
batch_op.add_column(sa.Column("reviewed_by_admin_id", sa.Integer(), nullable=True))
|
|
batch_op.add_column(sa.Column("reviewed_at", sa.DateTime(timezone=True), nullable=True))
|
|
batch_op.create_index(batch_op.f("ix_feedback_status"), ["status"], unique=False)
|
|
batch_op.create_foreign_key(
|
|
batch_op.f("fk_feedback_reviewed_by_admin_id_admin_user"),
|
|
"admin_user",
|
|
["reviewed_by_admin_id"],
|
|
["id"],
|
|
)
|
|
|
|
feedback = sa.table(
|
|
"feedback",
|
|
sa.column("status", sa.String(length=16)),
|
|
)
|
|
op.execute(
|
|
feedback.update()
|
|
.where(feedback.c.status == "new")
|
|
.values(status="pending")
|
|
)
|
|
op.execute(
|
|
feedback.update()
|
|
.where(feedback.c.status == "handled")
|
|
.values(status="adopted")
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
feedback = sa.table(
|
|
"feedback",
|
|
sa.column("status", sa.String(length=16)),
|
|
)
|
|
op.execute(
|
|
feedback.update()
|
|
.where(feedback.c.status == "pending")
|
|
.values(status="new")
|
|
)
|
|
op.execute(
|
|
feedback.update()
|
|
.where(feedback.c.status == "adopted")
|
|
.values(status="handled")
|
|
)
|
|
|
|
with op.batch_alter_table("feedback", schema=None) as batch_op:
|
|
batch_op.drop_constraint(
|
|
batch_op.f("fk_feedback_reviewed_by_admin_id_admin_user"),
|
|
type_="foreignkey",
|
|
)
|
|
batch_op.drop_index(batch_op.f("ix_feedback_status"))
|
|
batch_op.drop_column("reviewed_at")
|
|
batch_op.drop_column("reviewed_by_admin_id")
|
|
batch_op.drop_column("review_note")
|
|
batch_op.drop_column("reward_coins")
|
|
batch_op.drop_column("reject_reason")
|