diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-04-20 11:20:43 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2018-04-24 11:07:37 +0200 |
commit | 3b04a3dc4ef9c9cd48d2706736d9fcd9903a5dd0 (patch) | |
tree | 798e53025711f778526a388ef601b7b9ec0eb0b2 /db | |
parent | dc89c1842a6817d75fc05f0ae8a1ffd2a00869c7 (diff) | |
download | gitlab-ce-3b04a3dc4ef9c9cd48d2706736d9fcd9903a5dd0.tar.gz |
Schedule pipeline stages index background migration
Diffstat (limited to 'db')
-rw-r--r-- | db/post_migrate/20180420080616_schedule_stages_index_migration.rb | 29 | ||||
-rw-r--r-- | db/schema.rb | 2 |
2 files changed, 30 insertions, 1 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..41c4a109f9c --- /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 = 2000 + + 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 diff --git a/db/schema.rb b/db/schema.rb index 59f37df2da2..bc9a1892b5c 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180418053107) do +ActiveRecord::Schema.define(version: 20180420080616) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |