DB changes + Related issues added
This commit is contained in:
parent
bdc6adddbf
commit
d1d4f8192d
19 changed files with 120 additions and 83 deletions
|
@ -1,9 +1,11 @@
|
|||
require "migrate"
|
||||
|
||||
class CreateIssues < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :issues do |t|
|
||||
t.string :reportable_type
|
||||
t.integer :reportable_id
|
||||
t.integer :user_id
|
||||
t.string :reportable_type, :null => false
|
||||
t.integer :reportable_id, :null => false
|
||||
t.integer :reported_user_id, :null => false
|
||||
t.integer :status
|
||||
t.datetime :resolved_at
|
||||
t.integer :resolved_by
|
||||
|
@ -12,5 +14,11 @@ class CreateIssues < ActiveRecord::Migration
|
|||
|
||||
t.timestamps null: false
|
||||
end
|
||||
|
||||
add_foreign_key :issues, :users, :column => :reported_user_id,:name => "issues_reported_user_id_fkey"
|
||||
|
||||
add_index :issues, :reported_user_id,
|
||||
add_index :issues, [:reportable_id, :reportable_type]
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,5 +9,12 @@ class CreateReports < ActiveRecord::Migration
|
|||
|
||||
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
|
||||
|
|
|
@ -8,5 +8,12 @@ class CreateIssueComments < ActiveRecord::Migration
|
|||
|
||||
t.timestamps null: false
|
||||
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_index :issue_comments, :user_id
|
||||
add_index :issue_comments, :issue_id
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,11 +0,0 @@
|
|||
require "migrate"
|
||||
|
||||
class AddForeignKeysForIssues < ActiveRecord::Migration
|
||||
def change
|
||||
add_foreign_key :issues, :users, :name => "issues_user_id_fkey"
|
||||
add_foreign_key :reports, :issues, :name => "reports_issue_id_fkey"
|
||||
add_foreign_key :reports, :users, :name => "reports_user_id_fkey"
|
||||
add_foreign_key :issue_comments, :issues, :name => "issue_comments_issue_id_fkey"
|
||||
add_foreign_key :issue_comments, :users, :name => "issue_comments_user_id"
|
||||
end
|
||||
end
|
|
@ -1,19 +0,0 @@
|
|||
class AddIndexesForIssues < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_index :issues, :user_id
|
||||
add_index :issues, [:reportable_id, :reportable_type]
|
||||
add_index :reports, :issue_id
|
||||
add_index :reports, :user_id
|
||||
add_index :issue_comments, :user_id
|
||||
add_index :issue_comments, :issue_id
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_index :issues, :user_id
|
||||
remove_index :issues, [:reportable_id, :reportable_type]
|
||||
remove_index :reports, :issue_id
|
||||
remove_index :reports, :user_id
|
||||
remove_index :issue_comments, :user_id
|
||||
remove_index :issue_comments, :issue_id
|
||||
end
|
||||
end
|
|
@ -702,9 +702,9 @@ ALTER SEQUENCE issue_comments_id_seq OWNED BY issue_comments.id;
|
|||
|
||||
CREATE TABLE issues (
|
||||
id integer NOT NULL,
|
||||
reportable_type character varying,
|
||||
reportable_id integer,
|
||||
user_id integer,
|
||||
reportable_type character varying NOT NULL,
|
||||
reportable_id integer NOT NULL,
|
||||
reported_user_id integer NOT NULL,
|
||||
status integer,
|
||||
resolved_at timestamp without time zone,
|
||||
resolved_by integer,
|
||||
|
@ -1989,20 +1989,6 @@ CREATE INDEX index_issue_comments_on_issue_id ON issue_comments USING btree (iss
|
|||
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:
|
||||
--
|
||||
|
||||
CREATE INDEX index_issues_on_reportable_id_and_reportable_type ON issues USING btree (reportable_id, reportable_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_issues_on_user_id; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX index_issues_on_user_id ON issues USING btree (user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: index_note_comments_on_body; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2150,6 +2136,20 @@ CREATE INDEX relations_changeset_id_idx ON relations USING btree (changeset_id);
|
|||
CREATE INDEX relations_timestamp_idx ON relations USING btree ("timestamp");
|
||||
|
||||
|
||||
--
|
||||
-- Name: reportable_object_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX reportable_object_idx ON issues USING btree (reportable_id, reportable_type);
|
||||
|
||||
|
||||
--
|
||||
-- Name: reported_user_id_idx; Type: INDEX; Schema: public; Owner: -; Tablespace:
|
||||
--
|
||||
|
||||
CREATE INDEX reported_user_id_idx ON issues USING btree (reported_user_id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: unique_schema_migrations; Type: INDEX; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -2458,11 +2458,11 @@ ALTER TABLE ONLY issue_comments
|
|||
|
||||
|
||||
--
|
||||
-- Name: issues_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
-- Name: issues_reported_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY issues
|
||||
ADD CONSTRAINT issues_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(id);
|
||||
ADD CONSTRAINT issues_reported_user_id_fkey FOREIGN KEY (reported_user_id) REFERENCES users(id);
|
||||
|
||||
|
||||
--
|
||||
|
@ -2789,10 +2789,6 @@ INSERT INTO schema_migrations (version) VALUES ('20150516075620');
|
|||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150526130032');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150528113100');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('20150528114520');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('21');
|
||||
|
||||
INSERT INTO schema_migrations (version) VALUES ('22');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue