Ensure reports have an issue id and a user id

This commit is contained in:
Andy Allan 2018-03-14 15:24:16 +08:00
parent 5e7abf67fb
commit 3e5a4a14df
3 changed files with 6 additions and 4 deletions

View file

@ -25,6 +25,8 @@ class Report < ActiveRecord::Base
belongs_to :issue, :counter_cache => true belongs_to :issue, :counter_cache => true
belongs_to :user belongs_to :user
validates :issue, :presence => true
validates :user, :presence => true
validates :details, :presence => true validates :details, :presence => true
validates :category, :presence => true validates :category, :presence => true

View file

@ -21,8 +21,8 @@ class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
add_index :issues, :updated_by add_index :issues, :updated_by
create_table :reports do |t| create_table :reports do |t|
t.integer :issue_id t.integer :issue_id, :null => false
t.integer :user_id t.integer :user_id, :null => false
t.text :details, :null => false t.text :details, :null => false
t.string :category, :null => false t.string :category, :null => false
t.timestamps :null => false t.timestamps :null => false

View file

@ -1064,8 +1064,8 @@ CREATE TABLE relations (
CREATE TABLE reports ( CREATE TABLE reports (
id integer NOT NULL, id integer NOT NULL,
issue_id integer, issue_id integer NOT NULL,
user_id integer, user_id integer NOT NULL,
details text NOT NULL, details text NOT NULL,
category character varying NOT NULL, category character varying NOT NULL,
created_at timestamp without time zone NOT NULL, created_at timestamp without time zone NOT NULL,