Class: Gitlab::Database::PostgresPartitionedTable

Inherits:
SharedModel
  • Object
show all
Defined in:
lib/gitlab/database/postgres_partitioned_table.rb

Constant Summary collapse

DYNAMIC_PARTITION_STRATEGIES =
%w[range list].freeze

Constants inherited from SharedModel

SharedModel::SHARED_SCHEMAS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SharedModel

connection, #connection_db_config, connection_pool, using_connection

Class Method Details

.each_partition(table_name, &block) ⇒ Object



30
31
32
33
34
35
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 30

def self.each_partition(table_name, &block)
  find_by_name_in_current_schema(table_name)
  .postgres_partitions
  .order(:name)
  .each(&block)
end

.find_by_name_in_current_schema(name) ⇒ Object



26
27
28
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 26

def self.find_by_name_in_current_schema(name)
  by_name_in_current_schema(name).take
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 37

def dynamic?
  DYNAMIC_PARTITION_STRATEGIES.include?(strategy)
end

#static?Boolean

Returns:

  • (Boolean)


41
42
43
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 41

def static?
  !dynamic?
end

#to_sObject



45
46
47
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 45

def to_s
  name
end