summaryrefslogtreecommitdiff
path: root/lib/tasks/gitlab/db.rake
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tasks/gitlab/db.rake')
-rw-r--r--lib/tasks/gitlab/db.rake27
1 files changed, 23 insertions, 4 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index bbfdf598e42..ee986f4c503 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -129,16 +129,31 @@ namespace :gitlab do
end
# Inform Rake that custom tasks should be run every time rake db:structure:dump is run
+ #
+ # Rails 6.1 deprecates db:structure:dump in favor of db:schema:dump
Rake::Task['db:structure:dump'].enhance do
Rake::Task['gitlab:db:clean_structure_sql'].invoke
Rake::Task['gitlab:db:dump_custom_structure'].invoke
end
+ # Inform Rake that custom tasks should be run every time rake db:schema:dump is run
+ Rake::Task['db:schema:dump'].enhance do
+ Rake::Task['gitlab:db:clean_structure_sql'].invoke
+ Rake::Task['gitlab:db:dump_custom_structure'].invoke
+ end
+
# Inform Rake that custom tasks should be run every time rake db:structure:load is run
+ #
+ # Rails 6.1 deprecates db:structure:load in favor of db:schema:load
Rake::Task['db:structure:load'].enhance do
Rake::Task['gitlab:db:load_custom_structure'].invoke
end
+ # Inform Rake that custom tasks should be run every time rake db:schema:load is run
+ Rake::Task['db:schema:load'].enhance do
+ Rake::Task['gitlab:db:load_custom_structure'].invoke
+ end
+
desc 'Create missing dynamic database partitions'
task :create_dynamic_partitions do
Gitlab::Database::Partitioning::PartitionCreator.new.create_partitions
@@ -159,10 +174,16 @@ namespace :gitlab do
#
# Other than that it's helpful to create partitions early when bootstrapping
# a new installation.
+ #
+ # Rails 6.1 deprecates db:structure:load in favor of db:schema:load
Rake::Task['db:structure:load'].enhance do
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end
+ Rake::Task['db:schema:load'].enhance do
+ Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
+ end
+
# During testing, db:test:load restores the database schema from scratch
# which does not include dynamic partitions. We cannot rely on application
# initializers here as the application can continue to run while
@@ -188,7 +209,7 @@ namespace :gitlab do
raise "Index not found or not supported: #{args[:index_name]}" if indexes.empty?
end
- ActiveRecord::Base.logger = Logger.new(STDOUT) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false)
+ ActiveRecord::Base.logger = Logger.new($stdout) if Gitlab::Utils.to_boolean(ENV['LOG_QUERIES_TO_CONSOLE'], default: false)
Gitlab::Database::Reindexing.perform(indexes)
rescue StandardError => e
@@ -219,9 +240,7 @@ namespace :gitlab do
desc 'Run migrations with instrumentation'
task migration_testing: :environment do
result_dir = Gitlab::Database::Migrations::Instrumentation::RESULT_DIR
- raise "Directory exists already, won't overwrite: #{result_dir}" if File.exist?(result_dir)
-
- Dir.mkdir(result_dir)
+ FileUtils.mkdir_p(result_dir)
verbose_was = ActiveRecord::Migration.verbose
ActiveRecord::Migration.verbose = true