Files
BMS/bms-back/sql/price/prc_order_bl_pickup_alter.sql
T
2026-10-16 17:46:50 +08:00

32 lines
985 B
SQL
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
-- prc_order.bl_pickup from TAB_ORDER.BL_PICKUP (0/1)
SET NAMES utf8mb4;
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order'
AND COLUMN_NAME = 'bl_pickup'
LIMIT 1
);
SET @sql := IF(
@col IS NULL,
'ALTER TABLE prc_order ADD COLUMN bl_pickup tinyint(4) DEFAULT NULL COMMENT \'是否收货(0未收货 1已收货,TAB_ORDER.BL_PICKUP)\' AFTER order_status, ADD KEY idx_prc_order_bl_pickup (bl_pickup)',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;
-- drop from ext if still present (moved to prc_order)
SET @col := (
SELECT COLUMN_NAME FROM information_schema.COLUMNS
WHERE TABLE_SCHEMA = DATABASE()
AND TABLE_NAME = 'prc_order_ext'
AND COLUMN_NAME = 'bl_pickup'
LIMIT 1
);
SET @sql := IF(
@col IS NOT NULL,
'ALTER TABLE prc_order_ext DROP COLUMN bl_pickup',
'SELECT 1'
);
PREPARE stmt FROM @sql; EXECUTE stmt; DEALLOCATE PREPARE stmt;