debian-mirror-gitlab/app/models/concerns/partitioned_table.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

21 lines
628 B
Ruby
Raw Normal View History

2020-07-28 23:09:34 +05:30
# frozen_string_literal: true
module PartitionedTable
extend ActiveSupport::Concern
class_methods do
attr_reader :partitioning_strategy
PARTITIONING_STRATEGIES = {
2022-01-26 12:08:38 +05:30
monthly: Gitlab::Database::Partitioning::MonthlyStrategy,
sliding_list: Gitlab::Database::Partitioning::SlidingListStrategy
2020-07-28 23:09:34 +05:30
}.freeze
2021-09-30 23:02:18 +05:30
def partitioned_by(partitioning_key, strategy:, **kwargs)
2020-07-28 23:09:34 +05:30
strategy_class = PARTITIONING_STRATEGIES[strategy.to_sym] || raise(ArgumentError, "Unknown partitioning strategy: #{strategy}")
2021-09-30 23:02:18 +05:30
@partitioning_strategy = strategy_class.new(self, partitioning_key, **kwargs)
2020-07-28 23:09:34 +05:30
end
end
end