#
# Indexes
#
-# index_issues_on_reportable_id_and_reportable_type (reportable_id,reportable_type)
+# index_issues_on_reportable_type_and_reportable_id (reportable_type,reportable_id)
# index_issues_on_reported_user_id (reported_user_id)
# index_issues_on_updated_by (updated_by)
#
# Foreign Keys
#
-# issues_reported_user_id_fkey (reported_user_id => users.id) ON DELETE => cascade
-# issues_updated_by_fkey (updated_by => users.id) ON DELETE => cascade
+# issues_reported_user_id_fkey (reported_user_id => users.id)
+# issues_resolved_by_fkey (resolved_by => users.id)
+# issues_updated_by_fkey (updated_by => users.id)
#
class Issue < ActiveRecord::Base
belongs_to :reportable, :polymorphic => true
belongs_to :reported_user, :class_name => "User", :foreign_key => :reported_user_id
+ belongs_to :user_resolved, :class_name => "User", :foreign_key => :resolved_by
belongs_to :user_updated, :class_name => "User", :foreign_key => :updated_by
has_many :reports, :dependent => :destroy
#
# Foreign Keys
#
-# issue_comments_issue_id_fkey (issue_id => issues.id) ON DELETE => cascade
-# issue_comments_user_id (user_id => users.id) ON DELETE => cascade
+# issue_comments_issue_id_fkey (issue_id => issues.id)
+# issue_comments_user_id_fkey (user_id => users.id)
#
class IssueComment < ActiveRecord::Base
# Table name: reports
#
# id :integer not null, primary key
-# issue_id :integer
-# user_id :integer
+# issue_id :integer not null
+# user_id :integer not null
# details :text not null
# category :string not null
# created_at :datetime not null
#
# Foreign Keys
#
-# reports_issue_id_fkey (issue_id => issues.id) ON DELETE => cascade
-# reports_user_id_fkey (user_id => users.id) ON DELETE => cascade
+# reports_issue_id_fkey (issue_id => issues.id)
+# reports_user_id_fkey (user_id => users.id)
#
class Report < ActiveRecord::Base
t.timestamps :null => false
end
- add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey", :on_delete => :cascade
- add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", :on_delete => :cascade
+ add_foreign_key :issues, :users, :column => :reported_user_id, :name => "issues_reported_user_id_fkey"
+ add_foreign_key :issues, :users, :column => :resolved_by, :name => "issues_resolved_by_fkey"
+ add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey"
add_index :issues, :reported_user_id
- add_index :issues, [:reportable_id, :reportable_type]
+ add_index :issues, [:reportable_type, :reportable_id]
add_index :issues, :updated_by
create_table :reports do |t|
t.timestamps :null => false
end
- add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey", :on_delete => :cascade
- add_foreign_key :reports, :users, :column => :user_id, :name => "reports_user_id_fkey", :on_delete => :cascade
+ add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
+ add_foreign_key :reports, :users, :column => :user_id, :name => "reports_user_id_fkey"
add_index :reports, :user_id
add_index :reports, :issue_id
t.timestamps :null => false
end
- add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey", :on_delete => :cascade
- add_foreign_key :issue_comments, :users, :column => :user_id, :name => "issue_comments_user_id", :on_delete => :cascade
+ add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
+ add_foreign_key :issue_comments, :users, :column => :user_id, :name => "issue_comments_user_id_fkey"
add_index :issue_comments, :user_id
add_index :issue_comments, :issue_id
--
--- Name: index_issues_on_reportable_id_and_reportable_type; Type: INDEX; Schema: public; Owner: -
+-- Name: index_issues_on_reportable_type_and_reportable_id; Type: INDEX; Schema: public; Owner: -
--
-CREATE INDEX index_issues_on_reportable_id_and_reportable_type ON issues USING btree (reportable_id, reportable_type);
+CREATE INDEX index_issues_on_reportable_type_and_reportable_id ON issues USING btree (reportable_type, reportable_id);
--
--
ALTER TABLE ONLY issue_comments
- ADD CONSTRAINT issue_comments_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+ ADD CONSTRAINT issue_comments_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id);
--
--- Name: issue_comments_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
+-- Name: issue_comments_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY issue_comments
- ADD CONSTRAINT issue_comments_user_id FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ ADD CONSTRAINT issue_comments_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
--
--
ALTER TABLE ONLY issues
- ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id) ON DELETE CASCADE;
+ ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id);
+
+
+--
+-- Name: issues_resolved_by_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
+--
+
+ALTER TABLE ONLY issues
+ ADD CONSTRAINT issues_resolved_by_fkey FOREIGN KEY (resolved_by) REFERENCES users(id);
--
--
ALTER TABLE ONLY issues
- ADD CONSTRAINT issues_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES users(id) ON DELETE CASCADE;
+ ADD CONSTRAINT issues_updated_by_fkey FOREIGN KEY (updated_by) REFERENCES users(id);
--
--
ALTER TABLE ONLY reports
- ADD CONSTRAINT reports_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id) ON DELETE CASCADE;
+ ADD CONSTRAINT reports_issue_id_fkey FOREIGN KEY (issue_id) REFERENCES issues(id);
--
--
ALTER TABLE ONLY reports
- ADD CONSTRAINT reports_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE;
+ ADD CONSTRAINT reports_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
--