Skip to content

Commit

Permalink
[api][webui] fix migration again
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrolfe committed Mar 17, 2017
1 parent ca026f8 commit 6d99320
Showing 1 changed file with 14 additions and 12 deletions.
Expand Up @@ -13,20 +13,22 @@ def up

repos_with_duplicates = Repository.find_by_sql(sql)

sql = <<-SQL
SELECT b.*
FROM repositories a
LEFT JOIN repositories AS b
ON a.db_project_id = b.db_project_id
AND a.name = b.name
WHERE a.id != b.id
AND a.id IN (#{repos_with_duplicates.map(&:id).join(', ')})
SQL
if repos_with_duplicates.any?
sql = <<-SQL
SELECT b.*
FROM repositories a
LEFT JOIN repositories AS b
ON a.db_project_id = b.db_project_id
AND a.name = b.name
WHERE a.id != b.id
AND a.id IN (#{repos_with_duplicates.map(&:id).join(', ')})
SQL

duplicate_repos = Repository.find_by_sql(sql)
duplicate_repos = Repository.find_by_sql(sql)

# must be a ruby loop for the path_elements and reference cleanup
duplicate_repos.each(&:destroy)
# must be a ruby loop for the path_elements and reference cleanup
duplicate_repos.each(&:destroy)
end

execute 'UPDATE repositories SET remote_project_name = "" WHERE remote_project_name is null'

Expand Down

0 comments on commit 6d99320

Please sign in to comment.