/**
* Creates partitions
*/
public function create()
{
$db = $this->entity->db();
$dt = new \DateTime('tomorrow');
$end = new \DateTime('+1 month');
$interval = new \DateInterval("P1D");
$patritionSet = '';
while ($dt <= $end) {
$patritionSet .= "PARTITION p" . $dt->format('Ymd') . " VALUES LESS THAN (UNIX_TIMESTAMP('" . $dt->format('Y-m-d') . " 00:00:00')),";
$dt->add($interval);
}
$this->_disableChecks();
try {
$this->entity->db()->Execute("\n ALTER TABLE " . $this->entity->table() . "\n PARTITION BY RANGE(UNIX_TIMESTAMP(" . $this->field->getColumnName() . ")) (" . rtrim($patritionSet, ',') . ")\n ");
} catch (\Exception $e) {
$this->_enableChecks();
throw $e;
}
$this->_enableChecks();
}