Class: Gitlab::Database::PostgresPartition

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SharedModel

connection, #connection_db_config, connection_pool, using_connection

Class Method Details

.legacy_partition_exists?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


36
37
38
39
40
41
42
43
44
# File 'lib/gitlab/database/postgres_partition.rb', line 36

def self.legacy_partition_exists?(table_name)
  result = connection.select_value(<<~SQL)
    SELECT true FROM pg_class
    WHERE relname = '#{table_name}'
    AND relispartition = true;
  SQL

  !!result
end

.partition_exists?(table_name) ⇒ Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/gitlab/database/postgres_partition.rb', line 32

def self.partition_exists?(table_name)
  where("identifier = concat(current_schema(), '.', ?)", table_name).exists?
end

Instance Method Details

#to_sObject



46
47
48
# File 'lib/gitlab/database/postgres_partition.rb', line 46

def to_s
  name
end