CREATE TABLE `cqrs_event` (
  `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
  `event_id` char(36) COLLATE utf8_unicode_ci NOT NULL,
  `event_date` datetime NOT NULL,
  `event_date_u` int(10) unsigned NOT NULL,
  `aggregate_type` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `aggregate_id` varchar(64) CHARACTER SET utf8 DEFAULT NULL,
  `sequence_number` int(10) unsigned DEFAULT NULL,
  `payload_type` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
  `payload` longtext COLLATE utf8_unicode_ci NOT NULL,
  `metadata` longtext COLLATE utf8_unicode_ci NOT NULL,
  PRIMARY KEY (`id`,`event_date`),
  KEY `ix_cqrs_event_aggregate` (`aggregate_type`,`aggregate_id`,`sequence_number`),
  KEY `ix_cqrs_event_dates` (`event_date`,`event_date_u`),
  KEY `ix_cqrs_event_id` (`event_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci
 PARTITION BY RANGE (to_days(`event_date`))
(PARTITION `to_20190929` VALUES LESS THAN (737696) ENGINE = InnoDB,
 PARTITION `to_20191006` VALUES LESS THAN (737703) ENGINE = InnoDB,
 PARTITION `to_20191013` VALUES LESS THAN (737710) ENGINE = InnoDB,
 PARTITION `to_20191020` VALUES LESS THAN (737717) ENGINE = InnoDB,
 PARTITION `to_20191027` VALUES LESS THAN (737724) ENGINE = InnoDB,
 PARTITION `to_20191103` VALUES LESS THAN (737731) ENGINE = InnoDB,
 PARTITION `to_20191110` VALUES LESS THAN (737738) ENGINE = InnoDB,
 PARTITION `to_20191117` VALUES LESS THAN (737745) ENGINE = InnoDB,
 PARTITION `to_20191124` VALUES LESS THAN (737752) ENGINE = InnoDB,
 PARTITION `to_20191201` VALUES LESS THAN (737759) ENGINE = InnoDB,
 PARTITION `to_20191208` VALUES LESS THAN (737766) ENGINE = InnoDB,
 PARTITION `to_20191215` VALUES LESS THAN (737773) ENGINE = InnoDB,
 PARTITION `to_20191222` VALUES LESS THAN (737780) ENGINE = InnoDB,
 PARTITION `to_20191229` VALUES LESS THAN (737787) ENGINE = InnoDB,
 PARTITION `to_20200105` VALUES LESS THAN (737794) ENGINE = InnoDB,
 PARTITION `to_20200112` VALUES LESS THAN (737801) ENGINE = InnoDB,
 PARTITION `to_20200119` VALUES LESS THAN (737808) ENGINE = InnoDB,
 PARTITION `to_MAX` VALUES LESS THAN MAXVALUE ENGINE = InnoDB)
