Files
hfb_jysh/backend/migrations/000006_order_handoff_started_at.sql

16 lines
654 B
SQL

-- +goose Up
-- 新增进入“待号主交接”的时间,用于精确计算号主交接超时(以支付完成时刻为基准,而非订单创建时刻)。
ALTER TABLE rental_orders
ADD COLUMN handoff_started_at DATETIME NULL COMMENT '进入待号主交接的时间,用于计算交接超时' AFTER rented_at;
-- 历史数据兜底:已进入交接及之后阶段的订单,用 created_at 回填,避免基准缺失。
UPDATE rental_orders
SET handoff_started_at = created_at
WHERE handoff_started_at IS NULL
AND status NOT IN ('pending_payment', 'cancelled');
-- +goose Down
ALTER TABLE rental_orders DROP COLUMN handoff_started_at;