Fixed tests + Altered migration file + Added reporting strings + Added update method
This commit is contained in:
parent
faf4c5aa7a
commit
d5f02968f6
14 changed files with 157 additions and 63 deletions
|
@ -1,6 +1,6 @@
|
|||
require "migrate"
|
||||
|
||||
class CreateIssues < ActiveRecord::Migration
|
||||
class CreateIssuesAndReports < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :issues do |t|
|
||||
t.string :reportable_type, :null => false
|
||||
|
@ -19,6 +19,22 @@ class CreateIssues < ActiveRecord::Migration
|
|||
|
||||
add_index :issues, :reported_user_id
|
||||
add_index :issues, [:reportable_id, :reportable_type]
|
||||
|
||||
create_table :reports do |t|
|
||||
t.integer :issue_id
|
||||
t.integer :reporter_user_id
|
||||
t.text :details
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
|
||||
add_foreign_key :reports, :users,:column => :reporter_user_id, :name => "reports_reporter_user_id_fkey"
|
||||
|
||||
add_index :reports, :reporter_user_id
|
||||
add_index :reports, :issue_id
|
||||
|
||||
end
|
||||
end
|
|
@ -1,20 +0,0 @@
|
|||
class CreateReports < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :reports do |t|
|
||||
t.integer :issue_id
|
||||
t.integer :user_id
|
||||
t.text :details
|
||||
t.datetime :created_at
|
||||
t.datetime :updated_at
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
|
||||
add_foreign_key :reports, :users, :name => "reports_user_id_fkey"
|
||||
|
||||
add_index :reports, :issue_id
|
||||
add_index :reports, :user_id
|
||||
|
||||
end
|
||||
end
|
|
@ -2,7 +2,7 @@ class CreateIssueComments < ActiveRecord::Migration
|
|||
def change
|
||||
create_table :issue_comments do |t|
|
||||
t.integer :issue_id
|
||||
t.integer :user_id
|
||||
t.integer :commenter_user_id
|
||||
t.text :body
|
||||
t.datetime :created_at
|
||||
|
||||
|
@ -10,9 +10,9 @@ class CreateIssueComments < ActiveRecord::Migration
|
|||
end
|
||||
|
||||
add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
|
||||
add_foreign_key :issue_comments, :users, :name => "issue_comments_user_id"
|
||||
add_foreign_key :issue_comments, :users,:column => :commenter_user_id, :name => "issue_comments_commenter_user_id"
|
||||
|
||||
add_index :issue_comments, :user_id
|
||||
add_index :issue_comments, :commenter_user_id
|
||||
add_index :issue_comments, :issue_id
|
||||
|
||||
end
|
||||
|
|
|
@ -670,7 +670,7 @@ ALTER SEQUENCE gpx_files_id_seq OWNED BY gpx_files.id;
|
|||
CREATE TABLE issue_comments (
|
||||
id integer NOT NULL,
|
||||
issue_id integer,
|
||||
user_id integer,
|
||||
commenter_user_id integer,
|
||||
body text,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
|
@ -1040,7 +1040,7 @@ CREATE TABLE relations (
|
|||
CREATE TABLE reports (
|
||||
id integer NOT NULL,
|
||||
issue_id integer,
|
||||
user_id integer,
|
||||
reporter_user_id integer,
|
||||
details text,
|
||||
created_at timestamp without time zone NOT NULL,
|
||||
updated_at timestamp without time zone NOT NULL
|
||||
|
@ -1975,6 +1975,13 @@ CREATE UNIQUE INDEX index_changesets_subscribers_on_subscriber_id_and_changeset_
|
|||
CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USING btree (key);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_issue_comments_on_commenter_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_issue_comments_on_commenter_user_id ON issue_comments USING btree (commenter_user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_issue_comments_on_issue_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
@ -1982,13 +1989,6 @@ CREATE UNIQUE INDEX index_client_applications_on_key ON client_applications USIN
|
|||
CREATE INDEX index_issue_comments_on_issue_id ON issue_comments USING btree (issue_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_issue_comments_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_issue_comments_on_user_id ON issue_comments USING btree (user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_issues_on_reportable_id_and_reportable_type; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
@ -2039,10 +2039,10 @@ CREATE INDEX index_reports_on_issue_id ON reports USING btree (issue_id);
|
|||
|
||||
|
||||
--
|
||||
-- Name: index_reports_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
-- Name: index_reports_on_reporter_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_reports_on_user_id ON reports USING btree (user_id);
|
||||
CREATE INDEX index_reports_on_reporter_user_id ON reports USING btree (reporter_user_id);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2441,6 +2441,14 @@ ALTER TABLE ONLY gpx_files
|
|||
ADD CONSTRAINT gpx_files_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: issue_comments_commenter_user_id; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY issue_comments
|
||||
ADD CONSTRAINT issue_comments_commenter_user_id FOREIGN KEY (commenter_user_id) REFERENCES users(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: issue_comments_issue_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2449,14 +2457,6 @@ ALTER TABLE ONLY issue_comments
|
|||
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: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY issue_comments
|
||||
ADD CONSTRAINT issue_comments_user_id FOREIGN KEY (user_id) REFERENCES users(id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: issues_reported_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2586,11 +2586,11 @@ ALTER TABLE ONLY reports
|
|||
|
||||
|
||||
--
|
||||
-- Name: reports_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
-- Name: reports_reporter_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY reports
|
||||
ADD CONSTRAINT reports_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
|
||||
ADD CONSTRAINT reports_reporter_user_id_fkey FOREIGN KEY (reporter_user_id) REFERENCES users(id);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2785,8 +2785,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150222101847');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150516073616');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150516075620');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150526130032');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('21');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue