Files
ubicloud/migrate/20250512_archived_record_maintenance.rb
Benjamin Satzger a10f141232 Partition management for archived_records
Drop partitions:
archived_record_2024_12
archived_record_2025_01
archived_record_2025_02
archived_record_2025_03

Create partitions:
archived_record_2026_02
archived_record_2026_03
archived_record_2026_04
archived_record_2026_05
2025-05-19 09:00:34 +02:00

17 lines
463 B
Ruby

# frozen_string_literal: true
Sequel.migration do
change do
Array.new(4) { |i| Date.new(2024, 12, 1).next_month(i) }.each do |month|
drop_table("archived_record_#{month.strftime("%Y_%m")}")
end
Array.new(4) { |i| Date.new(2026, 2, 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