-- 运维设备：设备数量
SET @db := DATABASE();

SET @sql := IF(
  (SELECT COUNT(*) FROM information_schema.COLUMNS
   WHERE TABLE_SCHEMA = @db AND TABLE_NAME = 'yw_device' AND COLUMN_NAME = 'device_num') = 0,
  'ALTER TABLE `yw_device` ADD COLUMN `device_num` int NOT NULL DEFAULT 1 COMMENT ''设备数量'' AFTER `name`',
  'SELECT 1'
);
PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
