summaryrefslogtreecommitdiff
path: root/db/post_migrate
diff options
context:
space:
mode:
authorDylan Griffith <dyl.griffith@gmail.com>2018-05-03 09:54:12 +0200
committerDylan Griffith <dyl.griffith@gmail.com>2018-05-03 09:54:12 +0200
commitd39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd (patch)
treee8f2fac760b252928ff23074dea9d1f209838a33 /db/post_migrate
parentdcb67951a817db262ddcd3b777fafc4e1995fc04 (diff)
parent2c9568edeea7d95b6e4ec3c23cdc1c027bf86d5f (diff)
downloadgitlab-ce-d39b3d4b8d2d4c5ded46182a5353c68a8f5bb5cd.tar.gz
Merge branch 'master' into feature/runner-per-group
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20180420080616_schedule_stages_index_migration.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/db/post_migrate/20180420080616_schedule_stages_index_migration.rb b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb
new file mode 100644
index 00000000000..1d0daad002f
--- /dev/null
+++ b/db/post_migrate/20180420080616_schedule_stages_index_migration.rb
@@ -0,0 +1,29 @@
+class ScheduleStagesIndexMigration < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+ MIGRATION = 'MigrateStageIndex'.freeze
+ BATCH_SIZE = 10000
+
+ disable_ddl_transaction!
+
+ class Stage < ActiveRecord::Base
+ include EachBatch
+ self.table_name = 'ci_stages'
+ end
+
+ def up
+ disable_statement_timeout
+
+ Stage.all.tap do |relation|
+ queue_background_migration_jobs_by_range_at_intervals(relation,
+ MIGRATION,
+ 5.minutes,
+ batch_size: BATCH_SIZE)
+ end
+ end
+
+ def down
+ # noop
+ end
+end