Combine migrations into one
This makes it easier to review, rather than having a PR with migrations that correct each other.
This commit is contained in:
parent
2dd8f09395
commit
1d24228a3b
5 changed files with 20 additions and 29 deletions
|
@ -11,9 +11,9 @@
|
||||||
# resolved_at :datetime
|
# resolved_at :datetime
|
||||||
# resolved_by :integer
|
# resolved_by :integer
|
||||||
# updated_by :integer
|
# updated_by :integer
|
||||||
|
# reports_count :integer default(0)
|
||||||
# created_at :datetime not null
|
# created_at :datetime not null
|
||||||
# updated_at :datetime not null
|
# updated_at :datetime not null
|
||||||
# reports_count :integer default(0)
|
|
||||||
#
|
#
|
||||||
# Indexes
|
# Indexes
|
||||||
#
|
#
|
||||||
|
|
|
@ -9,13 +9,16 @@ class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
|
||||||
t.datetime :resolved_at
|
t.datetime :resolved_at
|
||||||
t.integer :resolved_by
|
t.integer :resolved_by
|
||||||
t.integer :updated_by
|
t.integer :updated_by
|
||||||
|
t.integer :reports_count, :default => 0
|
||||||
t.timestamps :null => false
|
t.timestamps :null => false
|
||||||
end
|
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 => :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_index :issues, :reported_user_id
|
add_index :issues, :reported_user_id
|
||||||
add_index :issues, [:reportable_id, :reportable_type]
|
add_index :issues, [:reportable_id, :reportable_type]
|
||||||
|
add_index :issues, :updated_by
|
||||||
|
|
||||||
create_table :reports do |t|
|
create_table :reports do |t|
|
||||||
t.integer :issue_id
|
t.integer :issue_id
|
||||||
|
@ -29,5 +32,18 @@ class CreateIssuesAndReports < ActiveRecord::Migration[5.0]
|
||||||
|
|
||||||
add_index :reports, :reporter_user_id
|
add_index :reports, :reporter_user_id
|
||||||
add_index :reports, :issue_id
|
add_index :reports, :issue_id
|
||||||
|
|
||||||
|
create_table :issue_comments do |t|
|
||||||
|
t.integer :issue_id, :null => false
|
||||||
|
t.integer :commenter_user_id, :null => false
|
||||||
|
t.text :body, :null => false
|
||||||
|
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 => :commenter_user_id, :name => "issue_comments_commenter_user_id", :on_delete => :cascade
|
||||||
|
|
||||||
|
add_index :issue_comments, :commenter_user_id
|
||||||
|
add_index :issue_comments, :issue_id
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,16 +0,0 @@
|
||||||
class CreateIssueComments < ActiveRecord::Migration[5.0]
|
|
||||||
def change
|
|
||||||
create_table :issue_comments do |t|
|
|
||||||
t.integer :issue_id, :null => false
|
|
||||||
t.integer :commenter_user_id, :null => false
|
|
||||||
t.text :body, :null => false
|
|
||||||
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 => :commenter_user_id, :name => "issue_comments_commenter_user_id", :on_delete => :cascade
|
|
||||||
|
|
||||||
add_index :issue_comments, :commenter_user_id
|
|
||||||
add_index :issue_comments, :issue_id
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -1,7 +0,0 @@
|
||||||
class AddReportsCountToIssues < ActiveRecord::Migration[5.0]
|
|
||||||
def change
|
|
||||||
add_column :issues, :reports_count, :integer, :default => 0
|
|
||||||
add_foreign_key :issues, :users, :column => :updated_by, :name => "issues_updated_by_fkey", :on_delete => :cascade
|
|
||||||
add_index :issues, :updated_by
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -732,9 +732,9 @@ CREATE TABLE issues (
|
||||||
resolved_at timestamp without time zone,
|
resolved_at timestamp without time zone,
|
||||||
resolved_by integer,
|
resolved_by integer,
|
||||||
updated_by integer,
|
updated_by integer,
|
||||||
|
reports_count integer DEFAULT 0,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL,
|
updated_at timestamp without time zone NOT NULL
|
||||||
reports_count integer DEFAULT 0
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
@ -1066,7 +1066,7 @@ CREATE TABLE reports (
|
||||||
id integer NOT NULL,
|
id integer NOT NULL,
|
||||||
issue_id integer,
|
issue_id integer,
|
||||||
reporter_user_id integer,
|
reporter_user_id integer,
|
||||||
details text,
|
details text NOT NULL,
|
||||||
created_at timestamp without time zone NOT NULL,
|
created_at timestamp without time zone NOT NULL,
|
||||||
updated_at timestamp without time zone NOT NULL
|
updated_at timestamp without time zone NOT NULL
|
||||||
);
|
);
|
||||||
|
@ -2830,8 +2830,6 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20150222101847'),
|
('20150222101847'),
|
||||||
('20150818224516'),
|
('20150818224516'),
|
||||||
('20160822153055'),
|
('20160822153055'),
|
||||||
('20160822153115'),
|
|
||||||
('20160822153153'),
|
|
||||||
('20161002153425'),
|
('20161002153425'),
|
||||||
('20161011010929'),
|
('20161011010929'),
|
||||||
('20170222134109'),
|
('20170222134109'),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue