Class: Gitlab::Database::PostgresPartition
- Inherits:
-
SharedModel
- Object
- ActiveRecord::Base
- SharedModel
- Gitlab::Database::PostgresPartition
show all
- Defined in:
- lib/gitlab/database/postgres_partition.rb
Constant Summary
collapse
- LIST_PARTITION_PATTERN =
/FOR VALUES IN \(([^)]+)\)/
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, ensure_connection_set!, using_connection
Class Method Details
.legacy_partition_exists?(table_name) ⇒ Boolean
52
53
54
55
56
57
58
59
60
|
# File 'lib/gitlab/database/postgres_partition.rb', line 52
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
48
49
50
|
# File 'lib/gitlab/database/postgres_partition.rb', line 48
def self.partition_exists?(table_name)
where("identifier = concat(current_schema(), '.', ?)", table_name).exists?
end
|
Instance Method Details
#list_partition_ids ⇒ Object
66
67
68
69
70
71
72
73
|
# File 'lib/gitlab/database/postgres_partition.rb', line 66
def list_partition_ids
return [] if condition.blank?
match = condition.match(LIST_PARTITION_PATTERN)
return [] unless match
match[1].scan(/\d+/).map(&:to_i)
end
|
#to_s ⇒ Object
62
63
64
|
# File 'lib/gitlab/database/postgres_partition.rb', line 62
def to_s
name
end
|