PageRenderTime 19ms CodeModel.GetById 15ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/db/post_migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb

https://gitlab.com/visay/gitlab-ce
Ruby | 19 lines | 10 code | 4 blank | 5 comment | 0 complexity | 49f72797452698a4523ae34656bdae7a MD5 | raw file
 1# The default needs to be `[]`, but all existing access tokens need to have `scopes` set to `['api']`.
 2# It's easier to achieve this by adding the column with the `['api']` default (regular migration), and
 3# then changing the default to `[]` (in this post-migration).
 4#
 5# Details: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5951#note_19721973
 6
 7class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migration
 8  include Gitlab::Database::MigrationHelpers
 9
10  DOWNTIME = false
11
12  def up
13    change_column_default :personal_access_tokens, :scopes, [].to_yaml
14  end
15
16  def down
17    change_column_default :personal_access_tokens, :scopes, ['api'].to_yaml
18  end
19end