summaryrefslogtreecommitdiff
path: root/db/migrate
diff options
context:
space:
mode:
authorTimothy Andrew <mail@timothyandrew.net>2016-12-16 14:57:09 +0530
committerTimothy Andrew <mail@timothyandrew.net>2016-12-16 16:29:33 +0530
commiteb434b15ebbc7d0b7ed79bb2daa45601e3c918ca (patch)
treea330170c76712062822eaa33dee87658370dbe00 /db/migrate
parent5becbe2495850923604c71b4c807666ea94819b3 (diff)
downloadgitlab-ce-eb434b15ebbc7d0b7ed79bb2daa45601e3c918ca.tar.gz
Make `ChangePersonalAccessTokensDefaultBackToEmptyArray` a "post" migration.20492-access-token-scopes
If we leave this as a regular migration, we could have the following flow: 1. Application knows nothing about scopes. 2. First migration runs, all existing personal access tokens have `api` scope 3. Application still knows nothing about scopes. 4. Second migration runs, all tokens created after this point have no scope 5. Application still knows nothing about scopes. 6. Tokens created at this time _should have the API scope, but instead have no scope_ 7. Application code is reloaded, application knows about scopes 8. Tokens created after this point only have no scope if the user deliberately chooses to have no scopes. Point #6 is the problem here. To avoid this, we move the second migration to a "post" migration, which runs after the application code is deployed/reloaded.
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb17
1 files changed, 0 insertions, 17 deletions
diff --git a/db/migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb b/db/migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
deleted file mode 100644
index c8ceb116b8a..00000000000
--- a/db/migrate/20160824121037_change_personal_access_tokens_default_back_to_empty_array.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-# 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, and then changing the default to
-# `[]`.
-
-class ChangePersonalAccessTokensDefaultBackToEmptyArray < ActiveRecord::Migration
- 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