Commit 57ec7c61 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fix/gb/reschedule-pipeline-stages-migration' into 'master'

Reschedule pipeline stages migration to run it again

See merge request gitlab-org/gitlab-ce!18191
parents 641bb13b 8d012198
class ScheduleBuildStageMigration < ActiveRecord::Migration class ScheduleBuildStageMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers ##
# This migration has been rescheduled to run again, see
DOWNTIME = false # `20180405101928_reschedule_builds_stages_migration.rb`
MIGRATION = 'MigrateBuildStage'.freeze #
BATCH_SIZE = 500
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_builds'
end
def up def up
disable_statement_timeout # noop
Build.where('stage_id IS NULL').tap do |relation|
queue_background_migration_jobs_by_range_at_intervals(relation,
MIGRATION,
5.minutes,
batch_size: BATCH_SIZE)
end
end end
def down def down
......
class RescheduleBuildsStagesMigration < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
##
# Rescheduled `20180212101928_schedule_build_stage_migration.rb`
#
DOWNTIME = false
MIGRATION = 'MigrateBuildStage'.freeze
BATCH_SIZE = 500
disable_ddl_transaction!
class Build < ActiveRecord::Base
include EachBatch
self.table_name = 'ci_builds'
end
def up
disable_statement_timeout
Build.where('stage_id IS NULL').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
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20180327101207) do ActiveRecord::Schema.define(version: 20180405101928) do
# These are extensions that must be enabled in order to support this database # These are extensions that must be enabled in order to support this database
enable_extension "plpgsql" enable_extension "plpgsql"
......
require 'spec_helper' require 'spec_helper'
require Rails.root.join('db', 'post_migrate', '20180212101928_schedule_build_stage_migration') require Rails.root.join('db', 'post_migrate', '20180405101928_reschedule_builds_stages_migration')
describe ScheduleBuildStageMigration, :sidekiq, :migration do describe RescheduleBuildsStagesMigration, :sidekiq, :migration do
let(:namespaces) { table(:namespaces) }
let(:projects) { table(:projects) } let(:projects) { table(:projects) }
let(:pipelines) { table(:ci_pipelines) } let(:pipelines) { table(:ci_pipelines) }
let(:stages) { table(:ci_stages) } let(:stages) { table(:ci_stages) }
...@@ -10,7 +11,8 @@ describe ScheduleBuildStageMigration, :sidekiq, :migration do ...@@ -10,7 +11,8 @@ describe ScheduleBuildStageMigration, :sidekiq, :migration do
before do before do
stub_const("#{described_class}::BATCH_SIZE", 1) stub_const("#{described_class}::BATCH_SIZE", 1)
projects.create!(id: 123, name: 'gitlab', path: 'gitlab-ce') namespaces.create(id: 12, name: 'gitlab-org', path: 'gitlab-org')
projects.create!(id: 123, namespace_id: 12, name: 'gitlab', path: 'gitlab')
pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a') pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test') stages.create!(id: 1, project_id: 123, pipeline_id: 1, name: 'test')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment