summaryrefslogtreecommitdiff
path: root/db/migrate/20140407135544_fix_namespaces.rb
blob: 3d2ca5c13c4e6392aabab6d640af73728e8ac8d5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
class FixNamespaces < ActiveRecord::Migration
  DOWNTIME = false

  def up
    namespaces = exec_query('SELECT id, path FROM namespaces WHERE name <> path and type is null')

    namespaces.each do |row|
      id = row['id']
      path = row['path']
      exec_query("UPDATE namespaces SET name = '#{path}' WHERE id = #{id}")
    end
  end

  def down
  end
end