# Linea21 DB patch - UTF-8 format
# patch v2.6.x To v2.7



# Adding l21_banned_ip table
CREATE TABLE `l21_banned_ip` (  `ban_id` INT NOT NULL AUTO_INCREMENT PRIMARY KEY,  `ban_ip` varchar(255) NOT NULL, `ban_user_id` INT UNSIGNED NOT NULL DEFAULT '1', `ban_date_crea` datetime NOT NULL DEFAULT '0001-01-01 00:00:00',  `ban_last_modify` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

# Adding sticky field in news 
ALTER TABLE `l21_news` ADD `news_sticky` VARCHAR(1) NOT NULL DEFAULT 'N' AFTER `news_range`; 


# Adding API fields in indicators table
ALTER TABLE `l21_sdi_info` ADD `sdii_api_enabled` VARCHAR(1) NOT NULL DEFAULT 'N' AFTER `sdii_to_dashboard`, ADD `sdii_api_url` VARCHAR(2000) NOT NULL DEFAULT '' AFTER `sdii_api_enabled`, ADD `sdii_api_datefield` VARCHAR(100) NOT NULL DEFAULT '' AFTER `sdii_api_url`, ADD `sdii_api_valuefield` VARCHAR(100) NOT NULL DEFAULT '' AFTER `sdii_api_datefield`, ADD `sdii_api_decimal` INT NOT NULL DEFAULT '0' AFTER `sdii_api_valuefield`, ADD `sdii_api_getvalues` VARCHAR(1) NOT NULL DEFAULT 'N' AFTER `sdii_api_decimal`, ADD `sdii_api_getvalues_since` VARCHAR(100) NOT NULL DEFAULT '' AFTER `sdii_api_getvalues`;

# Adding sdii_multiple_type field in indicators table
ALTER TABLE `l21_sdi_info` ADD `sdii_multiple_type` VARCHAR(50) NOT NULL DEFAULT 'sum' AFTER `sdii_value_type`;

# Adding sdiv_analysis field in indicators value table
ALTER TABLE `l21_sdi_value` ADD `sdiv_analysis` TEXT NOT NULL AFTER `sdiv_threshold`;