-- 空调电表：多联机 MAC、波特率、校验位
SET @db := DATABASE();

SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'dlj_mac') = 0,
  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `dlj_mac` varchar(64) DEFAULT NULL COMMENT ''多联机MAC'' AFTER `xy_name`',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'btl') = 0,
  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `btl` int DEFAULT NULL COMMENT ''波特率'' AFTER `dlj_mac`',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;

SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_conditioner_meter' AND COLUMN_NAME = 'jy') = 0,
  'ALTER TABLE `yw_conditioner_meter` ADD COLUMN `jy` int DEFAULT NULL COMMENT ''是否校验 0无校验 1校验'' AFTER `btl`',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
