summaryrefslogtreecommitdiff
path: root/db/migrate/20150924125436_migrate_project_id_for_ci_tables.rb
blob: 28d63c8c8401d5599585bbdaa712c3fb2328a658 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
class MigrateProjectIdForCiTables < ActiveRecord::Migration
  TABLES = %w(ci_builds ci_commits ci_events ci_runner_projects
    ci_services ci_triggers ci_variables ci_web_hooks)

  def up
    TABLES.each do |table|
      execute(
        "UPDATE #{table} " +
          "JOIN ci_projects ON ci_projects.id = #{table}.project_id " +
          "SET gl_project_id=ci_projects.gitlab_id " +
          "WHERE gl_project_id IS NULL"
      )
    end
  end
end