alter table app_log_Test drop PRIMARY KEY, add primary key (`id`, `dateCreated`);
Next, I can re-run my alter table to add the partitions I care about.
ALTER TABLE app_log_Test
PARTITION BY RANGE (TO_DAYS(dateCreated))
(PARTITION p_invalid_date VALUES LESS THAN (0) ENGINE = TokuDB,
PARTITION p_201809 VALUES LESS THAN (TO_DAYS('2018-09-01 00:00:00')),
PARTITION p_201810 VALUES LESS THAN (TO_DAYS('2018-10-01 00:00:00')),
PARTITION p_max_future_dates VALUES LESS THAN MAXVALUE);
If I need to add more partitions after that. I don't have to specify the partition scheme again I can just add the partition and its constraints.
ALTER TABLE app_log_Test
REORGANIZE PARTITION p_max_future_dates INTO (
PARTITION p_201811 VALUES LESS THAN (TO_DAYS('2018-11-01 00:00:00')),
PARTITION p_201812 VALUES LESS THAN (TO_DAYS('2018-12-01 00:00:00')),
PARTITION p_max_future_dates VALUES LESS THAN MAXVALUE);
My table now looks like this.
show create table app_log_Test;
Create Table: CREATE TABLE `app_log_Test` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`dateCreated` datetime NOT NULL,
`host` varchar(512) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`label` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`event` varchar(32) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`level` varchar(8) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
`message` text COLLATE utf8mb4_unicode_ci,
`version` bigint(20) NOT NULL DEFAULT '0',
PRIMARY KEY (`id`,`dateCreated`),
KEY `app_log_dateCreated` (`dateCreated`),
KEY `app_log_label` (`label`),
KEY `app_log_event` (`event`),
KEY `app_log_level` (`level`)
) ENGINE=TokuDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci `COMPRESSION`=tokudb_zlib