2 ms·
This is not always a bad thing. Consider the following: my $current_month = Month->new(); my $end_month = Month->new()->plus_months(4); while ($curre
by pyre 15y ago
This is not always a bad thing. Consider the following:
my $current_month = Month->new();
my $end_month = Month->new()->plus_months(4);
while ($current_month <= $end_month) {
$yyyymm = $current_month->strftme("%Y%m");
$last_day = $current_month->last_date()->strftime("%Y%m%d");
$first_day = $current_month->first_date()->strftime("%Y%m%d");
$dbh->do("create table my_partitioned_table_$yyyymm
() inherits from my_partitioned_table");
$dbh->do("alter table my_partitioned_table_$yyyymm
add constraint ck_my_partitioned_table_$yyyymm
check (date between '$first_day'::Date and '$last_day'::Date)");
$current_month->next_month();
}
This makes sure that my_partitioned_table has month-based partitions 4 months into the future (so long as you keep it on cron).