Commit 1859b106 authored by Kamil Trzciński's avatar Kamil Trzciński

Merge branch 'fix-ci-project-migration' into 'master'

Fix CI project migration and 500 on runners page



See merge request !2093
parents 208f99ff cb4b4c57
...@@ -60,7 +60,7 @@ ...@@ -60,7 +60,7 @@
= project.name_with_namespace = project.name_with_namespace
%td %td
.pull-right .pull-right
= link_to 'Disable', [:admin, project.namespace, project, runner_project], method: :delete, class: 'btn btn-danger btn-xs' = link_to 'Disable', [:admin, project.namespace.becomes(Namespace), project, runner_project], method: :delete, class: 'btn btn-danger btn-xs'
%table.table %table.table
%thead %thead
......
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
- runner_project = @project.runner_projects.find_by(runner_id: runner) - runner_project = @project.runner_projects.find_by(runner_id: runner)
= link_to 'Disable for this project', namespace_project_runner_project_path(@project.namespace, @project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm' = link_to 'Disable for this project', namespace_project_runner_project_path(@project.namespace, @project, runner_project), data: { confirm: "Are you sure?" }, method: :delete, class: 'btn btn-danger btn-sm'
- elsif runner.specific? - elsif runner.specific?
= form_for [@project.namespace, @project, @project.runner_projects.new] do |f| = form_for [@project.namespace.becomes(Namespace), @project, @project.runner_projects.new] do |f|
= f.hidden_field :runner_id, value: runner.id = f.hidden_field :runner_id, value: runner.id
= f.submit 'Enable for this project', class: 'btn btn-sm' = f.submit 'Enable for this project', class: 'btn btn-sm'
.pull-right .pull-right
......
...@@ -27,11 +27,11 @@ class MigrateCiToProject < ActiveRecord::Migration ...@@ -27,11 +27,11 @@ class MigrateCiToProject < ActiveRecord::Migration
def migrate_project_column(column, new_column = nil) def migrate_project_column(column, new_column = nil)
new_column ||= column new_column ||= column
subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id" subquery = "SELECT ci_projects.#{column} FROM ci_projects WHERE projects.id = ci_projects.gitlab_id"
execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE #{new_column} IS NULL AND (#{subquery}) IS NOT NULL") execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL")
end end
def migrate_ci_service def migrate_ci_service
subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService'" subquery = "SELECT active FROM services WHERE projects.id = services.project_id AND type='GitlabCiService' LIMIT 1"
execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE builds_enabled IS NULL AND (#{subquery}) IS NOT NULL") execute("UPDATE projects SET builds_enabled=(#{subquery}) WHERE (#{subquery}) IS NOT NULL")
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