Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'spec/support/helpers/migrations_helpers.rb')
-rw-r--r--spec/support/helpers/migrations_helpers.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/support/helpers/migrations_helpers.rb b/spec/support/helpers/migrations_helpers.rb
index fa50b234bd5..ef212938af5 100644
--- a/spec/support/helpers/migrations_helpers.rb
+++ b/spec/support/helpers/migrations_helpers.rb
@@ -16,6 +16,23 @@ module MigrationsHelpers
end
end
+ def partitioned_table(name, by: :created_at, strategy: :monthly)
+ klass = Class.new(active_record_base) do
+ include PartitionedTable
+
+ self.table_name = name
+ self.primary_key = :id
+
+ partitioned_by by, strategy: strategy
+
+ def self.name
+ table_name.singularize.camelcase
+ end
+ end
+
+ klass.tap { Gitlab::Database::Partitioning::PartitionManager.new.sync_partitions }
+ end
+
def migrations_paths
ActiveRecord::Migrator.migrations_paths
end