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

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



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

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



20
21
22
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 20

def self.find_by_name_in_current_schema(name)
  find_by("identifier = concat(current_schema(), '.', ?)", name)
end

Instance Method Details

#dynamic?Boolean

Returns:

  • (Boolean)


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

def dynamic?
  DYNAMIC_PARTITION_STRATEGIES.include?(strategy)
end

#static?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 35

def static?
  !dynamic?
end

#to_sObject



39
40
41
# File 'lib/gitlab/database/postgres_partitioned_table.rb', line 39

def to_s
  name
end