CREATE DATABASE ticket_db;
use ticket_db;
# 20 instances of tools that run on a SPIDER/TOKUDB environment
# 3 SPIDER nodes
#                HEAD(192.168.1.100)
#    COMP01(192.168.1.101)                  COMP02(192.168.1.102)
# HEAD for SPIDER monitoring
# COMP01 and COMP02 run each 10 instances of the tools
#
# 4 TOKUDB nodes
#    DB01(192.168.1.111)    DB02(192.168.1.112)    DB03(192.168.1.113)    DB04(192.168.1.114)
# contains each the replication of the table

GRANT ALL PRIVILEGES ON *.* TO 'user_spider'@'localhost' IDENTIFIED BY 'spider';
GRANT ALL PRIVILEGES ON *.* TO 'user_spider'@'%' IDENTIFIED BY 'spider';
GRANT GRANT OPTION ON *.* TO 'user_spider'@'localhost';
GRANT GRANT OPTION ON *.* TO 'user_spider'@'%';
GRANT ALL PRIVILEGES ON ticket_db.* TO 'user_spider'@'localhost' IDENTIFIED BY 'spider';
GRANT ALL PRIVILEGES ON ticket_db.* TO 'user_spider'@'%' IDENTIFIED BY 'spider';
GRANT GRANT OPTION ON ticket_db.* TO 'user_spider'@'localhost';
GRANT GRANT OPTION ON ticket_db.* TO 'user_spider'@'%';
GRANT CREATE USER ON *.* TO 'user_spider'@'localhost';
GRANT CREATE USER ON *.* TO 'user_spider'@'%';
FLUSH PRIVILEGES;

DROP TABLE ym_events;
CREATE TABLE ticket_db.ym_events (
  `creation_time` datetime NOT NULL,
  `event_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `link` bigint(20) unsigned DEFAULT NULL,
  `category` varchar(256) NOT NULL,
  `type` varchar(256) NOT NULL,
  `start_time` datetime DEFAULT NULL,
  `duration` int(10) unsigned DEFAULT '0',
  `size` int(10) unsigned DEFAULT '0',
  `node_id` int(10) unsigned DEFAULT NULL,
  `user_id` int(10) unsigned DEFAULT NULL,
  `task_id` int(10) unsigned DEFAULT NULL,
  `database_id` int(10) unsigned DEFAULT NULL,
  `command` varchar(1024) DEFAULT NULL,
  `status` varchar(256) DEFAULT NULL,
  `summary` mediumblob,
  `comment` varchar(1024) DEFAULT NULL,
  PRIMARY KEY (`event_id`,`creation_time`),
  KEY `ymevents_database` (`database_id`),
  KEY `ymevents_node` (`node_id`),
  KEY `ymevents_user` (`user_id`),
  KEY `ymevents_task` (`task_id`),
  KEY `ymevents_status` (`status`),
  KEY `ymevents_link` (`link`),
  KEY `ymevents_category` (`category`),
  KEY `ymevents_type` (`type`),
  KEY `ymevents_starttime` (`start_time`)
) ENGINE=TokuDB AUTO_INCREMENT=1 DEFAULT CHARSET=latin1 `COMPRESSION`=TOKUDB_LZMA;