SET @column_exists := (
  SELECT COUNT(*)
  FROM INFORMATION_SCHEMA.COLUMNS
  WHERE TABLE_SCHEMA = DATABASE()
    AND TABLE_NAME = 'tm_configuracion'
    AND COLUMN_NAME = 'mostrar_precio_comanda'
);

SET @sql := IF(
  @column_exists = 0,
  'ALTER TABLE `tm_configuracion` ADD COLUMN `mostrar_precio_comanda` int(11) NOT NULL DEFAULT 0 AFTER `precio_comanda`',
  'SELECT ''mostrar_precio_comanda already exists'' AS message'
);

PREPARE stmt FROM @sql;
EXECUTE stmt;
DEALLOCATE PREPARE stmt;
