From: Andy Allan Date: Wed, 13 Sep 2017 14:01:36 +0000 (+0100) Subject: Ensure that issue comments have associated issues and users. X-Git-Tag: live~2957^2~97 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/33c43ab0affe7317d7d136bc6ed934d6f6951585?hp=a0b665faf71b671eed57493a899f6ffc8b82ddc5 Ensure that issue comments have associated issues and users. --- diff --git a/app/models/issue_comment.rb b/app/models/issue_comment.rb index 2122a6489..bbc626164 100644 --- a/app/models/issue_comment.rb +++ b/app/models/issue_comment.rb @@ -3,4 +3,6 @@ class IssueComment < ActiveRecord::Base belongs_to :user, :class_name => "User", :foreign_key => :commenter_user_id validates :body, :presence => true + validates :user, :presence => true + validates :issue, :presence => true end diff --git a/db/migrate/20160822153115_create_issue_comments.rb b/db/migrate/20160822153115_create_issue_comments.rb index e3c379bc1..b41dde8a7 100644 --- a/db/migrate/20160822153115_create_issue_comments.rb +++ b/db/migrate/20160822153115_create_issue_comments.rb @@ -1,9 +1,9 @@ class CreateIssueComments < ActiveRecord::Migration def change create_table :issue_comments do |t| - t.integer :issue_id - t.integer :commenter_user_id - t.text :body + t.integer :issue_id, :null => false + t.integer :commenter_user_id, :null => false + t.text :body, :null => false t.boolean :reassign t.timestamps :null => false end diff --git a/db/structure.sql b/db/structure.sql index cdf4fb7dc..7888d8a9c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -691,9 +691,9 @@ ALTER SEQUENCE gpx_files_id_seq OWNED BY gpx_files.id; CREATE TABLE issue_comments ( id integer NOT NULL, - issue_id integer, - commenter_user_id integer, - body text, + issue_id integer NOT NULL, + commenter_user_id integer NOT NULL, + body text NOT NULL, reassign boolean, created_at timestamp without time zone NOT NULL, updated_at timestamp without time zone NOT NULL