summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2015-12-17 10:49:31 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2015-12-17 10:49:31 +0000
commit110a5f9c96457ac314f30630735dd827d9d96a4c (patch)
tree765b8860cf7a9b07ac51ff4f4d3e865d869d0ca9
parent61a1bdd7cc9fa01261e6bfc4630699b256b1f48b (diff)
parente136a976b6130f6e416cd7e281ae6033cc292082 (diff)
downloadgitlab-ce-110a5f9c96457ac314f30630735dd827d9d96a4c.tar.gz
Merge branch 'fix-migration' into 'master'
Fix ci_projects migration by using the value only from latest row [ci skip] This is needed, because for some projects we have duplicate ci_projects. This was introduced by lack of DB uniqueness on ci_projects.gitlab_id. The MR fixes edge case by selecting value from latest. /cc @yorickpeterse Fixes: gitlab-org/gitlab-ce#4123 See merge request !2133
-rw-r--r--db/migrate/20151210125930_migrate_ci_to_project.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/db/migrate/20151210125930_migrate_ci_to_project.rb b/db/migrate/20151210125930_migrate_ci_to_project.rb
index 7dfe05174ee..75278997862 100644
--- a/db/migrate/20151210125930_migrate_ci_to_project.rb
+++ b/db/migrate/20151210125930_migrate_ci_to_project.rb
@@ -26,7 +26,8 @@ class MigrateCiToProject < ActiveRecord::Migration
def migrate_project_column(column, new_column = nil)
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 " \
+ 'ORDER BY ci_projects.updated_at DESC LIMIT 1'
execute("UPDATE projects SET #{new_column}=(#{subquery}) WHERE (#{subquery}) IS NOT NULL")
end