Commit f88d9cee authored by Kamil Trzcinski's avatar Kamil Trzcinski

Fix migrations

parent 0e338147
class AddProjectIdToCiCommit < ActiveRecord::Migration
def up
add_column :ci_commits, :gl_project_id, :integer
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 MigrateProjectIdForCiCommits < ActiveRecord::Migration
def up
execute(
"UPDATE ci_commits " +
"JOIN ci_projects ON ci_projects.id = ci_commits.project_id " +
"SET gl_project_id=ci_projects.gitlab_id " +
"WHERE gl_project_id IS NULL"
)
end
end
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
class AddCiFieldsToProjectsTable < ActiveRecord::Migration
def up
add_column :projects, :shared_runners_enabled, :boolean, default: false
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