summaryrefslogtreecommitdiff
path: root/db/migrate/20190604184643_fix_pool_repository_source_project_id.rb
blob: 30244760e6b38ab0cebf1e5a7e84c299c61eebd9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class FixPoolRepositorySourceProjectId < ActiveRecord::Migration[5.1]
  include Gitlab::Database::MigrationHelpers

  # Set this constant to true if this migration requires downtime.
  DOWNTIME = false

  def up
    execute "UPDATE pool_repositories SET source_project_id = (SELECT MIN(id) FROM projects WHERE pool_repository_id = pool_repositories.id) WHERE pool_repositories.source_project_id IS NULL"
  end

  def down
    # nothing to do her
  end
end