diff options
author | Sean McGivern <sean@gitlab.com> | 2016-07-12 18:57:08 +0100 |
---|---|---|
committer | Sean McGivern <sean@gitlab.com> | 2016-07-12 19:07:39 +0100 |
commit | 144d22f7f87c270cb5192366c6e76dfad2a2c389 (patch) | |
tree | f13fb4764696dccd611717dc4638af10c991e81b | |
parent | d5c715c9cc23a403d908e4686db152d8316ac684 (diff) | |
download | gitlab-ce-19693-emoji-awards-aren-t-deleted-for-deleted-users.tar.gz |
Delete award emoji when deleting a user19693-emoji-awards-aren-t-deleted-for-deleted-users
-rw-r--r-- | CHANGELOG | 3 | ||||
-rw-r--r-- | app/models/user.rb | 2 | ||||
-rw-r--r-- | db/migrate/20160712171823_remove_award_emojis_with_no_user.rb | 21 | ||||
-rw-r--r-- | db/schema.rb | 2 |
4 files changed, 25 insertions, 3 deletions
diff --git a/CHANGELOG b/CHANGELOG index a50edf1a797..1a4d792ef84 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -8,6 +8,7 @@ v 8.10.0 (unreleased) - Refactor repository paths handling to allow multiple git mount points - Optimize system note visibility checking by memoizing the visible reference count !5070 - Add Application Setting to configure default Repository Path for new projects + - Delete award emoji when deleting a user - Remove pinTo from Flash and make inline flash messages look nicer !4854 (winniehell) - Wrap code blocks on Activies and Todos page. !4783 (winniehell) - Align flash messages with left side of page content !4959 (winniehell) @@ -73,7 +74,7 @@ v 8.10.0 (unreleased) - Allow '?', or '&' for label names - Fix importer for GitHub Pull Requests when a branch was reused across Pull Requests - Add date when user joined the team on the member page - - Fix 404 redirect after validation fails importing a GitLab project + - Fix 404 redirect after validation fails importing a GitLab project - Fix 404 redirect after validation fails importing a GitLab project - Added setting to set new users by default as external !4545 (Dravere) - Add min value for project limit field on user's form !3622 (jastkand) diff --git a/app/models/user.rb b/app/models/user.rb index 79c670cb35a..7a72c202150 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -87,7 +87,7 @@ class User < ActiveRecord::Base has_many :builds, dependent: :nullify, class_name: 'Ci::Build' has_many :todos, dependent: :destroy has_many :notification_settings, dependent: :destroy - has_many :award_emoji, as: :awardable, dependent: :destroy + has_many :award_emoji, dependent: :destroy # # Validations diff --git a/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb new file mode 100644 index 00000000000..668c22bb51c --- /dev/null +++ b/db/migrate/20160712171823_remove_award_emojis_with_no_user.rb @@ -0,0 +1,21 @@ +# See http://doc.gitlab.com/ce/development/migration_style_guide.html +# for more information on how to write migrations for GitLab. + +class RemoveAwardEmojisWithNoUser < ActiveRecord::Migration + include Gitlab::Database::MigrationHelpers + + # When using the methods "add_concurrent_index" or "add_column_with_default" + # you must disable the use of transactions as these methods can not run in an + # existing transaction. When using "add_concurrent_index" make sure that this + # method is the _only_ method called in the migration, any other changes + # should go in a separate migration. This ensures that upon failure _only_ the + # index creation fails and can be retried or reverted easily. + # + # To disable transactions uncomment the following line and remove these + # comments: + # disable_ddl_transaction! + + def up + AwardEmoji.joins('LEFT JOIN users ON users.id = user_id').where('users.id IS NULL').destroy_all + end +end diff --git a/db/schema.rb b/db/schema.rb index 9d31947d80f..f24e47b85b2 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20160707104333) do +ActiveRecord::Schema.define(version: 20160712171823) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" |