BigW Consortium Gitlab

Commit f88d9cee by Kamil Trzcinski

Fix migrations

parent 0e338147
class AddCiFieldsToProjectsTable < ActiveRecord::Migration class AddProjectIdToCiCommit < ActiveRecord::Migration
def up def up
add_column :projects, :shared_runners_enabled, :boolean, default: false add_column :ci_commits, :gl_project_id, :integer
end end
end end
class AddProjectIdToCiTables < ActiveRecord::Migration
def up
add_column :ci_builds, :gl_project_id, :integer
add_column :ci_commits, :gl_project_id, :integer
add_column :ci_events, :gl_project_id, :integer
add_column :ci_runner_projects, :gl_project_id, :integer
add_column :ci_services, :gl_project_id, :integer
add_column :ci_triggers, :gl_project_id, :integer
add_column :ci_variables, :gl_project_id, :integer
add_column :ci_web_hooks, :gl_project_id, :integer
end
end
class MigrateProjectIdForCiTables < ActiveRecord::Migration class MigrateProjectIdForCiCommits < ActiveRecord::Migration
TABLES = %w(ci_builds ci_commits ci_events ci_runner_projects
ci_services ci_triggers ci_variables ci_web_hooks)
def up def up
TABLES.each do |table| execute(
execute( "UPDATE ci_commits " +
"UPDATE #{table} " + "JOIN ci_projects ON ci_projects.id = ci_commits.project_id " +
"JOIN ci_projects ON ci_projects.id = #{table}.project_id " + "SET gl_project_id=ci_projects.gitlab_id " +
"SET gl_project_id=ci_projects.gitlab_id " + "WHERE gl_project_id IS NULL"
"WHERE gl_project_id IS NULL" )
)
end
end end
end end
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