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>
10 lines
412 B
SQL
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';
|