summaryrefslogtreecommitdiff
path: root/db/post_migrate/20170525140254_rename_all_reserved_paths_again.rb
blob: 59b8daaffdff7059864d767e654ddefd0a27cfc8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
# See http://doc.gitlab.com/ce/development/migration_style_guide.html
# for more information on how to write migrations for GitLab.

class RenameAllReservedPathsAgain < ActiveRecord::Migration[4.2]
  include Gitlab::Database::RenameReservedPathsMigration::V1

  DOWNTIME = false

  disable_ddl_transaction!

  TOP_LEVEL_ROUTES = %w[
      -
      .well-known
      abuse_reports
      admin
      api
      assets
      autocomplete
      ci
      dashboard
      explore
      files
      groups
      health_check
      help
      import
      invites
      jwt
      koding
      notification_settings
      oauth
      profile
      projects
      public
      robots.txt
      s
      search
      sent_notifications
      snippets
      u
      unicorn_test
      unsubscribes
      uploads
      users
  ].freeze

  PROJECT_WILDCARD_ROUTES = %w[
      badges
      blame
      blob
      builds
      commits
      create
      create_dir
      edit
      environments/folders
      files
      find_file
      gitlab-lfs/objects
      info/lfs/objects
      new
      preview
      raw
      refs
      tree
      update
      wikis
    ].freeze

  GROUP_ROUTES = %w[
      activity
      analytics
      audit_events
      avatar
      edit
      group_members
      hooks
      issues
      labels
      ldap
      ldap_group_links
      merge_requests
      milestones
      notification_setting
      pipeline_quota
      projects
  ].freeze

  def up
    disable_statement_timeout do
      TOP_LEVEL_ROUTES.each { |route| rename_root_paths(route) }
      PROJECT_WILDCARD_ROUTES.each { |route| rename_wildcard_paths(route) }
      GROUP_ROUTES.each { |route| rename_child_paths(route) }
    end
  end

  def down
    disable_statement_timeout do
      revert_renames
    end
  end
end