ubicloud/migrate/20250922_archived_record_maintenance.rb
Benjamin Satzger ea78c7ddea Partition management for archived_records
Drop partitions:
archived_record_2025_07
archived_record_2025_08

Create partitions:
archived_record_2026_09
archived_record_2026_10
2025-09-22 12:17:17 +02:00

16 lines
462 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
Array.new(2) { |i| Date.new(2025, 7, 1).next_month(i) }.each do |month|
drop_table("archived_record_#{month.strftime("%Y_%m")}")
end
Array.new(2) { |i| Date.new(2026, 9, 1).next_month(i) }.each do |month|
create_table("archived_record_#{month.strftime("%Y_%m")}", partition_of: :archived_record) do
from month
to month.next_month
end
end
end
end