diff options
author | Douwe Maan <douwe@gitlab.com> | 2016-11-18 19:42:17 +0000 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2016-11-18 19:42:17 +0000 |
commit | 130c8a51981268d53adb0000c6cd11ad65350b7c (patch) | |
tree | 455c3cf8e1fd68dd483a9fec32507331a3d406ad /db/migrate | |
parent | 596c305eab94dfacb302c3630f08d81636623d64 (diff) | |
parent | fd05e26618dd0c123ca476b6f5a3d85f1cfe397a (diff) | |
download | gitlab-ce-130c8a51981268d53adb0000c6cd11ad65350b7c.tar.gz |
Merge branch 'feature/precalculate-authorized-projects' into 'master'
Precalculate authorized projects in database
## What does this MR do?
It caches user's authorized projects in database instead of using multiple unions, which should simplify and speed-up things since this operation (getting authorized projects) is used a lot.
## Are there points in the code the reviewer needs to double check?
Did we miss a scenario where we need to refresh the list of projects?
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [ ] ~~[Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)~~
- [ ] ~~API support added~~
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [merge request performance guides](http://docs.gitlab.com/ce/development/merge_request_performance_guidelines.html)
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if it does - rebase it please)
- [x] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
## What are the relevant issue numbers?
#23150
See merge request !6839
Diffstat (limited to 'db/migrate')
-rw-r--r-- | db/migrate/20161010142410_create_project_authorizations.rb | 15 | ||||
-rw-r--r-- | db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb | 9 |
2 files changed, 24 insertions, 0 deletions
diff --git a/db/migrate/20161010142410_create_project_authorizations.rb b/db/migrate/20161010142410_create_project_authorizations.rb new file mode 100644 index 00000000000..e095ab969f8 --- /dev/null +++ b/db/migrate/20161010142410_create_project_authorizations.rb @@ -0,0 +1,15 @@ +class CreateProjectAuthorizations < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + create_table :project_authorizations do |t| + t.references :user, foreign_key: { on_delete: :cascade } + t.references :project, foreign_key: { on_delete: :cascade } + t.integer :access_level + + t.index [:user_id, :project_id, :access_level], unique: true, name: 'index_project_authorizations_on_user_id_project_id_access_level' + end + end +end diff --git a/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb b/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb new file mode 100644 index 00000000000..8f6be9dd677 --- /dev/null +++ b/db/migrate/20161017091941_add_authorized_projects_populated_to_users.rb @@ -0,0 +1,9 @@ +class AddAuthorizedProjectsPopulatedToUsers < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + DOWNTIME = false + + def change + add_column :users, :authorized_projects_populated, :boolean + end +end |