summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorYorick Peterse <yorickpeterse@gmail.com>2018-02-05 17:50:07 +0000
committerYorick Peterse <yorickpeterse@gmail.com>2018-02-05 17:50:07 +0000
commitcf9e29672ce0df9647eecd94d099d15dc1bdac0e (patch)
tree89114aa9f73588176b44fe4a28312475211bdb0b /app/models
parentdf176fe747cad64fd86f8b91fe94f8b40bbd8a04 (diff)
parent24a11c957a34d2f22c0276fa8dcc3e2c23d1f164 (diff)
downloadgitlab-ce-cf9e29672ce0df9647eecd94d099d15dc1bdac0e.tar.gz
Merge branch '32282-add-foreign-keys-to-todos' into 'master'
Add missing foreign key and NOT NULL constraints to todos table. Closes #32282 See merge request gitlab-org/gitlab-ce!16849
Diffstat (limited to 'app/models')
-rw-r--r--app/models/note.rb2
-rw-r--r--app/models/todo.rb1
-rw-r--r--app/models/user.rb2
3 files changed, 3 insertions, 2 deletions
diff --git a/app/models/note.rb b/app/models/note.rb
index 01a778a7424..cac60845a49 100644
--- a/app/models/note.rb
+++ b/app/models/note.rb
@@ -60,7 +60,7 @@ class Note < ActiveRecord::Base
belongs_to :updated_by, class_name: "User"
belongs_to :last_edited_by, class_name: 'User'
- has_many :todos, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_many :todos
has_many :events, as: :target, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_one :system_note_metadata
diff --git a/app/models/todo.rb b/app/models/todo.rb
index 7af54b2beb2..bb5965e20eb 100644
--- a/app/models/todo.rb
+++ b/app/models/todo.rb
@@ -28,6 +28,7 @@ class Todo < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true, allow_nil: true
validates :action, :project, :target_type, :user, presence: true
+ validates :author, presence: true
validates :target_id, presence: true, unless: :for_commit?
validates :commit_id, presence: true, if: :for_commit?
diff --git a/app/models/user.rb b/app/models/user.rb
index a57ba3740c9..4b44e9bb7eb 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -125,7 +125,7 @@ class User < ActiveRecord::Base
has_many :spam_logs, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :builds, dependent: :nullify, class_name: 'Ci::Build' # rubocop:disable Cop/ActiveRecordDependent
has_many :pipelines, dependent: :nullify, class_name: 'Ci::Pipeline' # rubocop:disable Cop/ActiveRecordDependent
- has_many :todos, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
+ has_many :todos
has_many :notification_settings, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :award_emoji, dependent: :destroy # rubocop:disable Cop/ActiveRecordDependent
has_many :triggers, dependent: :destroy, class_name: 'Ci::Trigger', foreign_key: :owner_id # rubocop:disable Cop/ActiveRecordDependent