Created
June 10, 2024 07:25
-
-
Save juanparati/3d387e98d8dd91bcda165f7f268536e6 to your computer and use it in GitHub Desktop.
UUI7 partition generator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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