Files
vmall/apps/api/migrations/0031_provision_task_replacement.sql
T
Chengdong ZhangandCursor cc9a522589 feat(orders): provision paid services through shop tasks
Payment opens one provision task and a pending subscription. Delivery completes the order, a cancelled claim reopens it, and renewal records the chosen term without taking anchor stock.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-11-18 16:44:36 +08:00

10 lines
412 B
SQL

-- A cancelled provision task must not keep the one-task slot. Done and open
-- tasks still do, so a payment replay cannot insert a second live task.
DROP INDEX provisioning_tasks_one_provision_per_item;
CREATE UNIQUE INDEX provisioning_tasks_one_provision_per_item
ON provisioning_tasks (order_item_id)
WHERE task_type = 'provision'
AND order_item_id IS NOT NULL
AND status <> 'cancelled';