SET @listing_in_transaction_exists := (
  SELECT COUNT(*)
  FROM information_schema.columns
  WHERE table_schema = DATABASE()
    AND table_name = 'rental_listings'
    AND column_name = 'in_transaction'
);

SET @add_listing_in_transaction_sql := IF(
  @listing_in_transaction_exists = 0,
  'ALTER TABLE rental_listings ADD COLUMN in_transaction TINYINT(1) NOT NULL DEFAULT 0 AFTER deposit_amount',
  'SELECT 1'
);
PREPARE add_listing_in_transaction_stmt FROM @add_listing_in_transaction_sql;
EXECUTE add_listing_in_transaction_stmt;
DEALLOCATE PREPARE add_listing_in_transaction_stmt;

INSERT INTO system_configs (`key`, `value`, description)
VALUES ('order.pending_payment_timeout_minutes', '15', '订单待支付超时取消分钟数')
ON DUPLICATE KEY UPDATE `key` = VALUES(`key`);
