summaryrefslogtreecommitdiff
path: root/db/migrate/20161130095245_fill_routes_table.rb
blob: 6754e58300052bdc9165b16cace5e6c454f68e02 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class FillRoutesTable < ActiveRecord::Migration
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = true
  DOWNTIME_REASON = 'No new namespaces should be created during data copy'

  def up
    execute <<-EOF
      INSERT INTO routes
      (source_id, source_type, path)
      (SELECT id, 'Namespace', path FROM namespaces)
    EOF
  end

  def down
    Route.delete_all(source_type: 'Namespace')
  end
end