From dbf414df33160b8ca15650c56bab9e9b3f2d0ccf Mon Sep 17 00:00:00 2001 From: Yorick Peterse Date: Tue, 31 Jan 2017 22:44:31 +0100 Subject: [PATCH] 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. --- .../refresh-permissions-recent-users.yml | 4 ++++ ...set_users_authorized_projects_populated.rb | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 changelogs/unreleased/refresh-permissions-recent-users.yml create mode 100644 db/post_migrate/20170131214021_reset_users_authorized_projects_populated.rb diff --git a/changelogs/unreleased/refresh-permissions-recent-users.yml b/changelogs/unreleased/refresh-permissions-recent-users.yml new file mode 100644 index 00000000000..4d08be6ed5c --- /dev/null +++ b/changelogs/unreleased/refresh-permissions-recent-users.yml @@ -0,0 +1,4 @@ +--- +title: Reset users.authorized_projects_populated to automatically refresh user permissions +merge_request: +author: 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