Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2017-02-01 00:44:31 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2017-03-13 15:28:26 +0300
commitdbf414df33160b8ca15650c56bab9e9b3f2d0ccf (patch)
tree00d1d287fe9a43d1ea3120c93953afdc61a61068 /db/post_migrate
parent32da7602686f2b8161175d82b121deb9e01b2db5 (diff)
Trigger refreshing of permissions in a migration
This migration resets `users.authorized_projects_populated` (in batches) so that active users' permissions are refreshed on the next request. This ensures that their permissions are properly stored.
Diffstat (limited to 'db/post_migrate')
-rw-r--r--db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb19
1 files changed, 19 insertions, 0 deletions
diff --git a/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb b/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb
new file mode 100644
index 00000000000..b518038e93a
--- /dev/null
+++ b/db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb
@@ -0,0 +1,19 @@
+# See http://doc.gitlab.com/ce/development/migration_style_guide.html
+# for more information on how to write migrations for GitLab.
+
+class ResetUsersAuthorizedProjectsPopulated < ActiveRecord::Migration
+ include Gitlab::Database::MigrationHelpers
+
+ DOWNTIME = false
+
+ disable_ddl_transaction!
+
+ def up
+ # This ensures we don't lock all users for the duration of the migration.
+ update_column_in_batches(:users, :authorized_projects_populated, nil)
+ end
+
+ def down
+ # noop
+ end
+end