]> git.openstreetmap.org Git - rails.git/commitdiff
Ensure that issue comments have associated issues and users.
authorAndy Allan <git@gravitystorm.co.uk>
Wed, 13 Sep 2017 14:01:36 +0000 (15:01 +0100)
committerAndy Allan <git@gravitystorm.co.uk>
Wed, 13 Sep 2017 14:01:36 +0000 (15:01 +0100)
app/models/issue_comment.rb
db/migrate/20160822153115_create_issue_comments.rb
db/structure.sql

index 2122a64892cbf8585e1dd9c967be1628b0fe938c..bbc6261640ab48d635d9256a87d754b24e0c31ed 100644 (file)
@@ -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
index e3c379bc1e2bf9ce92d73857028b963a9a0704c7..b41dde8a71a2d848dd13c79da14d7c445b2c8cfd 100644 (file)
@@ -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
index cdf4fb7dccaf1700e50a0a47624268d33c842972..7888d8a9cfde10976355e1862ae1f5b422fb9381 100644 (file)
@@ -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