diff options
Diffstat (limited to 'lib/gitlab/database/postgres_partitioned_table.rb')
-rw-r--r-- | lib/gitlab/database/postgres_partitioned_table.rb | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/lib/gitlab/database/postgres_partitioned_table.rb b/lib/gitlab/database/postgres_partitioned_table.rb index 3bd342f940f..fead7379e43 100644 --- a/lib/gitlab/database/postgres_partitioned_table.rb +++ b/lib/gitlab/database/postgres_partitioned_table.rb @@ -10,7 +10,9 @@ module Gitlab has_many :postgres_partitions, foreign_key: 'parent_identifier', primary_key: 'identifier' scope :by_identifier, ->(identifier) do - raise ArgumentError, "Table name is not fully qualified with a schema: #{identifier}" unless identifier =~ /^\w+\.\w+$/ + unless identifier =~ Gitlab::Database::FULLY_QUALIFIED_IDENTIFIER + raise ArgumentError, "Table name is not fully qualified with a schema: #{identifier}" + end find(identifier) end @@ -19,6 +21,13 @@ module Gitlab find_by("identifier = concat(current_schema(), '.', ?)", name) end + def self.each_partition(table_name, &block) + find_by_name_in_current_schema(table_name) + .postgres_partitions + .order(:name) + .each(&block) + end + def dynamic? DYNAMIC_PARTITION_STRATEGIES.include?(strategy) end |