diff options
author | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-05-02 14:35:04 +0100 |
---|---|---|
committer | Tiago Botelho <tiagonbotelho@hotmail.com> | 2018-05-04 17:33:26 +0200 |
commit | bddbcaefc2389e4c61763472cecbea150f10cd75 (patch) | |
tree | 38ba599beed53505dfca09fce7a890bf3b125bb3 /db/post_migrate | |
parent | 7603beffc916d06039cac63b223d8e6234b5d666 (diff) | |
download | gitlab-ce-bddbcaefc2389e4c61763472cecbea150f10cd75.tar.gz |
Backports every CE related change from ee-44542 to CE
Diffstat (limited to 'db/post_migrate')
-rw-r--r-- | db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb new file mode 100644 index 00000000000..e39cd33c414 --- /dev/null +++ b/db/post_migrate/20180502134117_migrate_import_attributes_data_from_projects_to_project_mirror_data.rb @@ -0,0 +1,38 @@ +class MigrateImportAttributesDataFromProjectsToProjectMirrorData < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + UP_MIGRATION = 'PopulateImportState'.freeze + DOWN_MIGRATION = 'RollbackImportStateData'.freeze + + BATCH_SIZE = 1000 + DELAY_INTERVAL = 5.minutes + + disable_ddl_transaction! + + class Project < ActiveRecord::Base + include EachBatch + + self.table_name = 'projects' + end + + class ProjectImportState < ActiveRecord::Base + include EachBatch + + self.table_name = 'project_mirror_data' + end + + def up + projects = Project.where.not(import_status: :none) + + queue_background_migration_jobs_by_range_at_intervals(projects, UP_MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) + end + + def down + import_state = ProjectImportState.where.not(status: :none) + + queue_background_migration_jobs_by_range_at_intervals(import_state, DOWN_MIGRATION, DELAY_INTERVAL, batch_size: BATCH_SIZE) + end + +end |