Added IssueComments + ForeignKeys + Indexes
This commit is contained in:
parent
d49922eb63
commit
683722ed5c
16 changed files with 285 additions and 18 deletions
12
db/migrate/20150526130032_create_issue_comments.rb
Normal file
12
db/migrate/20150526130032_create_issue_comments.rb
Normal file
|
@ -0,0 +1,12 @@
|
|||
class CreateIssueComments < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :issue_comments do |t|
|
||||
t.integer :issue_id
|
||||
t.integer :user_id
|
||||
t.text :body
|
||||
t.datetime :created_at
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
11
db/migrate/20150528113100_add_foreign_keys_for_issues.rb
Normal file
11
db/migrate/20150528113100_add_foreign_keys_for_issues.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
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
|
19
db/migrate/20150528114520_add_indexes_for_issues.rb
Normal file
19
db/migrate/20150528114520_add_indexes_for_issues.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
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
|
Loading…
Add table
Add a link
Reference in a new issue