20 lines
633 B
SQL
20 lines
633 B
SQL
-- +goose Up
|
|
|
|
-- 修复历史数据:订单已取消但支付流水仍停留在 created/paying 时,同步关闭支付流水。
|
|
UPDATE payment_orders p
|
|
JOIN rental_orders o ON o.id = p.order_id
|
|
SET p.status = 'closed',
|
|
p.raw_response = JSON_OBJECT(
|
|
'source', 'migration_cancelled_order',
|
|
'reason', '订单已取消,关闭历史未完成支付单'
|
|
),
|
|
p.updated_at = CURRENT_TIMESTAMP
|
|
WHERE p.biz_type = 'order_pay'
|
|
AND p.status IN ('created', 'paying')
|
|
AND o.status = 'cancelled';
|
|
|
|
-- +goose Down
|
|
|
|
-- 数据修复无法安全反推原状态,回滚时不重新打开已关闭支付流水。
|
|
SELECT 1;
|