belongs_to :issue, :counter_cache => true
belongs_to :user
+ validates :issue, :presence => true
+ validates :user, :presence => true
validates :details, :presence => true
validates :category, :presence => true
add_index :issues, :updated_by
create_table :reports do |t|
- t.integer :issue_id
- t.integer :user_id
+ t.integer :issue_id, :null => false
+ t.integer :user_id, :null => false
t.text :details, :null => false
t.string :category, :null => false
t.timestamps :null => false
CREATE TABLE reports (
id integer NOT NULL,
- issue_id integer,
- user_id integer,
+ issue_id integer NOT NULL,
+ user_id integer NOT NULL,
details text NOT NULL,
category character varying NOT NULL,
created_at timestamp without time zone NOT NULL,