summaryrefslogtreecommitdiff
path: root/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
blob: 099814d75563547e78f7a4db8132003c7e1620a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# The default needs to be `[]`, but all existing access tokens need to have `scopes` set to `['api']`.
# It's easier to achieve this by adding the column with the `['api']` default (regular migration), and
# then changing the default to `[]` (in this post-migration).
#
# Details: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5951#note_19721973

class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migration[4.2]
  include Gitlab::Database::MigrationHelpers

  DOWNTIME = false

  def up
    change_column_default :personal_access_tokens, :scopes, [].to_yaml
  end

  def down
    change_column_default :personal_access_tokens, :scopes, ['api'].to_yaml
  end
end