DROP TABLE IF EXISTS `histories`;
CREATE TABLE `histories` (
                             `id` int NOT NULL AUTO_INCREMENT,
                             `device` varchar(30) NOT NULL,
                             `platform` varchar(30) NOT NULL,
                             `os` varchar(30) DEFAULT NULL,
                             `country_code` varchar(5) NOT NULL,
                             `country` varchar(50) NOT NULL,
                             `flag` varchar(155) NOT NULL DEFAULT '',
                             `city` varchar(50) NOT NULL,
                             `browser` varchar(30) NOT NULL,
                             `language` varchar(10) NOT NULL,
                             `model` varchar(50) NOT NULL,
                             `brand` varchar(50) NOT NULL,
                             `user_id` int DEFAULT NULL,
                             `sale_id` int DEFAULT NULL,
                             `shop_id` int DEFAULT NULL,
                             `session_id` varchar(255) NOT NULL,
                             `isp` varchar(155) NOT NULL,
                             `page` varchar(255) NOT NULL DEFAULT '',
                             `ip` varchar(50) NOT NULL,
                             `referrer` varchar(255) NOT NULL,
                             `user_agent` text,
                             `status` tinyint(1) NOT NULL DEFAULT '0',
                             `is_bot` tinyint(1) NOT NULL,
                             `bot_type` varchar(50) NOT NULL DEFAULT '',
                             `query_string` varchar(255) NOT NULL,
                             `ad_type` varchar(50) NOT NULL,
                             `date_added` datetime NOT NULL,
                             `date_modified` datetime NOT NULL,
                             PRIMARY KEY (`id`),
                             UNIQUE KEY `sale_id` (`sale_id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8mb3;