Add initial stage_id background migration files
This commit is contained in:
parent
afd5c34d9f
commit
16ae7b7a49
3 changed files with 54 additions and 0 deletions
|
@ -0,0 +1,12 @@
|
|||
class MigrateStageIdReferenceInBackground < ActiveRecord::Migration
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
def up
|
||||
end
|
||||
|
||||
def down
|
||||
# noop
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
module Gitlab
|
||||
module BackgroundMigration
|
||||
class MigrateBuildStageIdReference
|
||||
class Build < ActiveRecord::Base
|
||||
self.table_name = 'ci_builds'
|
||||
end
|
||||
|
||||
class Stage < ActiveRecord::Base
|
||||
self.table_name = 'ci_stages'
|
||||
end
|
||||
|
||||
def perform(id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
require 'spec_helper'
|
||||
require Rails.root.join('db', 'post_migrate', '20170628080858_migrate_stage_id_reference_in_background')
|
||||
|
||||
describe MigrateStageIdReferenceInBackground, :migration, :redis do
|
||||
let(:jobs) { table(:ci_builds) }
|
||||
let(:stages) { table(:ci_stages) }
|
||||
let(:pipelines) { table(:ci_pipelines) }
|
||||
let(:projects) { table(:projects) }
|
||||
|
||||
before do
|
||||
projects.create!(id: 123, name: 'gitlab1', path: 'gitlab1')
|
||||
pipelines.create!(id: 1, project_id: 123, ref: 'master', sha: 'adf43c3a')
|
||||
|
||||
jobs.create!(id: 1, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
|
||||
jobs.create!(id: 2, commit_id: 1, project_id: 123, stage_idx: 2, stage: 'build')
|
||||
jobs.create!(id: 3, commit_id: 1, project_id: 123, stage_idx: 1, stage: 'test')
|
||||
jobs.create!(id: 4, commit_id: 1, project_id: 123, stage_idx: 3, stage: 'deploy')
|
||||
|
||||
stages.create(id: 101, pipeline_id: 1, project_id: 123, name: 'test')
|
||||
stages.create(id: 102, pipeline_id: 1, project_id: 123, name: 'build')
|
||||
stages.create(id: 103, pipeline_id: 1, project_id: 123, name: 'deploy')
|
||||
end
|
||||
|
||||
it 'schedules background migrations' do
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue