Ensure that issue comments have associated issues and users.

This commit is contained in:
Andy Allan 2017-09-13 15:01:36 +01:00
parent a0b665faf7
commit 33c43ab0af
3 changed files with 8 additions and 6 deletions

View 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

View 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

View 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