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
17 lines
463 B
Ruby
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
|