1 class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
3 create_table :issues do |t|
4 t.string :reportable_type, :null => false
5 t.integer :reportable_id, :null => false
6 t.integer :reported_user_id, :null => false
9 t.datetime :resolved_at
10 t.integer :resolved_by
12 t.timestamps :null => false
15 add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey", :on_delete => :cascade
17 add_index :issues, :reported_user_id
18 add_index :issues, [:reportable_id, :reportable_type]
20 create_table :reports do |t|
22 t.integer :reporter_user_id
23 t.text :details, :null => false
24 t.timestamps :null => false
27 add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey", :on_delete => :cascade
28 add_foreign_key :reports, :users, :column => :reporter_user_id, :name => "reports_reporter_user_id_fkey", :on_delete => :cascade
30 add_index :reports, :reporter_user_id
31 add_index :reports, :issue_id