Skip to content

Instantly share code, notes, and snippets.

@juanparati
Created June 10, 2024 07:25
Show Gist options
  • Save juanparati/3d387e98d8dd91bcda165f7f268536e6 to your computer and use it in GitHub Desktop.
Save juanparati/3d387e98d8dd91bcda165f7f268536e6 to your computer and use it in GitHub Desktop.
UUI7 partition generator
<?php
use Ramsey\Uuid\Uuid;
$date = now()->parse("2024-01-01 00:00:00");
while ($date->year < 2039) {
$dateProcess = (clone $date)
->endOfMonth()
->hour(23)
->minute(59)
->second(59);
$uuid = substr(Uuid::uuid7($dateProcess), 0, 13) . "-0000-0000-000000000000";
echo "PARTITION `p_{$date->year}_{$date->month}` VALUES LESS THAN ('$uuid'), -- < " .
$dateProcess->toDateTimeString() .
"\n";
$date->addMonth();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment