feat(fulfillment): 支持选号优先级、三皮肤联合资格捆绑与同角色共享租约
This commit is contained in:
+36
-32
@@ -45,7 +45,7 @@ TESTS_DIR = Path(__file__).resolve().parent
|
||||
PROJECT_ROOT = TESTS_DIR.parent
|
||||
VERSIONS_DIR = PROJECT_ROOT / "web" / "backend" / "migrations" / "versions"
|
||||
|
||||
HEAD_REVISION = "20261125_0135"
|
||||
HEAD_REVISION = "20261128_0136"
|
||||
|
||||
# 迁移新增、但不声明在模型里的复合查询索引。
|
||||
EXTRA_INDEXES = (
|
||||
@@ -108,6 +108,9 @@ _LATER_ORM_COLUMNS = {
|
||||
"store_status": "INTEGER NULL",
|
||||
"open_status": "INTEGER NULL",
|
||||
},
|
||||
"platform_fulfillment_settings": {
|
||||
"allocation_policy_json": "JSON NULL",
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -302,10 +305,10 @@ class TestMigrationSmoke:
|
||||
"(user_id, username, action, target, detail, success, created_at) "
|
||||
"VALUES "
|
||||
"(NULL, 'migration-test', 'douyu:collab:status', :target, "
|
||||
"'{\"from\":\"scripted\",\"to\":\"done\"}', 1, "
|
||||
'\'{"from":"scripted","to":"done"}\', 1, '
|
||||
"'2026-11-02 10:00:00'), "
|
||||
"(NULL, 'migration-test', 'douyu:collab:status', :target, "
|
||||
"'{\"from\":\"done\",\"to\":\"to_recharge\"}', 1, "
|
||||
'\'{"from":"done","to":"to_recharge"}\', 1, '
|
||||
"'2026-11-03 10:00:00')"
|
||||
),
|
||||
{"target": f"douyu_external_order:{rolled_back_id}"},
|
||||
@@ -320,10 +323,7 @@ class TestMigrationSmoke:
|
||||
"FROM douyu_external_orders ORDER BY id"
|
||||
)
|
||||
).mappings()
|
||||
succeeded = {
|
||||
row["order_no"]: row["succeeded_at"]
|
||||
for row in rows
|
||||
}
|
||||
succeeded = {row["order_no"]: row["succeeded_at"] for row in rows}
|
||||
assert succeeded["DY-MIG-DONE"] is not None
|
||||
assert succeeded["DY-MIG-ROLLED-BACK"] is not None
|
||||
assert succeeded["DY-MIG-ACTIVE"] is None
|
||||
@@ -804,24 +804,32 @@ class TestMigrationSmoke:
|
||||
command.upgrade(cfg, "head")
|
||||
|
||||
with mig_engine.begin() as conn:
|
||||
shops = conn.execute(
|
||||
text(
|
||||
"""
|
||||
shops = (
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT name, aliases
|
||||
FROM douyu_collab_shops
|
||||
ORDER BY id
|
||||
"""
|
||||
)
|
||||
)
|
||||
).mappings().all()
|
||||
order = conn.execute(
|
||||
text(
|
||||
"""
|
||||
.mappings()
|
||||
.all()
|
||||
)
|
||||
order = (
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT shop, shop_original_name
|
||||
FROM douyu_external_orders
|
||||
WHERE order_no = 'DY-SHOP-MIGRATION'
|
||||
"""
|
||||
)
|
||||
)
|
||||
).mappings().one()
|
||||
.mappings()
|
||||
.one()
|
||||
)
|
||||
assert [shop["name"] for shop in shops] == ["向日葵"]
|
||||
aliases = (
|
||||
json.loads(shops[0]["aliases"])
|
||||
@@ -862,9 +870,7 @@ class TestMigrationSmoke:
|
||||
command.upgrade(cfg, "20261121_0104")
|
||||
before = {
|
||||
row["name"]
|
||||
for row in inspect(mig_engine).get_columns(
|
||||
"platform_fulfillment_tasks"
|
||||
)
|
||||
for row in inspect(mig_engine).get_columns("platform_fulfillment_tasks")
|
||||
}
|
||||
assert "exchange_result_image_key" not in before
|
||||
assert "exchange_result_image_saved_at" not in before
|
||||
@@ -872,9 +878,7 @@ class TestMigrationSmoke:
|
||||
command.upgrade(cfg, "head")
|
||||
after = {
|
||||
row["name"]
|
||||
for row in inspect(mig_engine).get_columns(
|
||||
"platform_fulfillment_tasks"
|
||||
)
|
||||
for row in inspect(mig_engine).get_columns("platform_fulfillment_tasks")
|
||||
}
|
||||
assert "exchange_result_image_key" in after
|
||||
assert "exchange_result_image_saved_at" in after
|
||||
@@ -882,9 +886,7 @@ class TestMigrationSmoke:
|
||||
command.downgrade(cfg, "20261121_0104")
|
||||
downgraded = {
|
||||
row["name"]
|
||||
for row in inspect(mig_engine).get_columns(
|
||||
"platform_fulfillment_tasks"
|
||||
)
|
||||
for row in inspect(mig_engine).get_columns("platform_fulfillment_tasks")
|
||||
}
|
||||
assert "exchange_result_image_key" not in downgraded
|
||||
assert "exchange_result_image_saved_at" not in downgraded
|
||||
@@ -1031,23 +1033,25 @@ class TestMigrationSmoke:
|
||||
command.upgrade(cfg, "head")
|
||||
with mig_engine.connect() as conn:
|
||||
columns = {
|
||||
item["name"]
|
||||
for item in inspect(conn).get_columns("douyu_tasks")
|
||||
item["name"] for item in inspect(conn).get_columns("douyu_tasks")
|
||||
}
|
||||
indexes = {
|
||||
item["name"]
|
||||
for item in inspect(conn).get_indexes("douyu_tasks")
|
||||
item["name"] for item in inspect(conn).get_indexes("douyu_tasks")
|
||||
}
|
||||
rows = conn.execute(
|
||||
text(
|
||||
"""
|
||||
rows = (
|
||||
conn.execute(
|
||||
text(
|
||||
"""
|
||||
SELECT status, message, active_binding_key
|
||||
FROM douyu_tasks
|
||||
WHERE batch_id = 'repair-0107-batch'
|
||||
ORDER BY id
|
||||
"""
|
||||
)
|
||||
)
|
||||
).mappings().all()
|
||||
.mappings()
|
||||
.all()
|
||||
)
|
||||
assert "active_binding_key" in columns
|
||||
assert "uq_douyu_tasks_active_binding" in indexes
|
||||
assert [row["status"] for row in rows] == ["stopped", "running"]
|
||||
|
||||
Reference in New Issue
Block a user