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:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2021-07-20 12:55:51 +0300
commite8d2c2579383897a1dd7f9debd359abe8ae8373d (patch)
treec42be41678c2586d49a75cabce89322082698334 /lib/tasks/gitlab/db.rake
parentfc845b37ec3a90aaa719975f607740c22ba6a113 (diff)
Add latest changes from gitlab-org/gitlab@14-1-stable-eev14.1.0-rc42
Diffstat (limited to 'lib/tasks/gitlab/db.rake')
-rw-r--r--lib/tasks/gitlab/db.rake58
1 files changed, 10 insertions, 48 deletions
diff --git a/lib/tasks/gitlab/db.rake b/lib/tasks/gitlab/db.rake
index ee986f4c503..2b508b341dd 100644
--- a/lib/tasks/gitlab/db.rake
+++ b/lib/tasks/gitlab/db.rake
@@ -90,73 +90,35 @@ namespace :gitlab do
desc 'This adjusts and cleans db/structure.sql - it runs after db:structure:dump'
task :clean_structure_sql do |task_name|
- structure_file = 'db/structure.sql'
- schema = File.read(structure_file)
+ ActiveRecord::Base.configurations.configs_for(env_name: ActiveRecord::Tasks::DatabaseTasks.env).each do |db_config|
+ structure_file = ActiveRecord::Tasks::DatabaseTasks.dump_filename(db_config.name)
- File.open(structure_file, 'wb+') do |io|
- Gitlab::Database::SchemaCleaner.new(schema).clean(io)
- end
-
- # Allow this task to be called multiple times, as happens when running db:migrate:redo
- Rake::Task[task_name].reenable
- end
+ schema = File.read(structure_file)
- desc 'This dumps GitLab specific database details - it runs after db:structure:dump'
- task :dump_custom_structure do |task_name|
- Gitlab::Database::CustomStructure.new.dump
+ File.open(structure_file, 'wb+') do |io|
+ Gitlab::Database::SchemaCleaner.new(schema).clean(io)
+ end
+ end
# Allow this task to be called multiple times, as happens when running db:migrate:redo
Rake::Task[task_name].reenable
end
- desc 'This loads GitLab specific database details - runs after db:structure:dump'
- task :load_custom_structure do
- configuration = Rails.application.config_for(:database)
-
- ENV['PGHOST'] = configuration['host'] if configuration['host']
- ENV['PGPORT'] = configuration['port'].to_s if configuration['port']
- ENV['PGPASSWORD'] = configuration['password'].to_s if configuration['password']
- ENV['PGUSER'] = configuration['username'].to_s if configuration['username']
-
- command = 'psql'
- dump_filepath = Gitlab::Database::CustomStructure.custom_dump_filepath.to_path
- args = ['-v', 'ON_ERROR_STOP=1', '-q', '-X', '-f', dump_filepath, configuration['database']]
-
- unless Kernel.system(command, *args)
- raise "failed to execute:\n#{command} #{args.join(' ')}\n\n" \
- "Please ensure `#{command}` is installed in your PATH and has proper permissions.\n\n"
- end
- 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
+ task create_dynamic_partitions: :environment do
+ Gitlab::Database::Partitioning::PartitionManager.new.sync_partitions
end
# This is targeted towards deploys and upgrades of GitLab.
@@ -192,7 +154,7 @@ namespace :gitlab do
Rake::Task['gitlab:db:create_dynamic_partitions'].invoke
end
- desc 'reindex a regular (non-unique) index without downtime to eliminate bloat'
+ desc 'reindex a regular index without downtime to eliminate bloat'
task :reindex, [:index_name] => :environment do |_, args|
unless Feature.enabled?(:database_reindexing, type: :ops)
puts "This feature (database_reindexing) is currently disabled.".color(:yellow)