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.
This commit is contained in:
parent
8dc4c7b4c7
commit
e136a976b6
1 changed files with 2 additions and 1 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue