##// END OF EJS Templates
Adding missing database indexes for foreign keys and STI fields....
Eric Davis -
r2814:70118fb136b1
parent child
Show More
@@ -0,0 +1,13
1 class AddMissingIndexesToWorkflows < ActiveRecord::Migration
2 def self.up
3 add_index :workflows, :old_status_id
4 add_index :workflows, :role_id
5 add_index :workflows, :new_status_id
6 end
7
8 def self.down
9 remove_index :workflows, :old_status_id
10 remove_index :workflows, :role_id
11 remove_index :workflows, :new_status_id
12 end
13 end
@@ -0,0 +1,9
1 class AddMissingIndexesToCustomFieldsProjects < ActiveRecord::Migration
2 def self.up
3 add_index :custom_fields_projects, [:custom_field_id, :project_id]
4 end
5
6 def self.down
7 remove_index :custom_fields_projects, :column => [:custom_field_id, :project_id]
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToMessages < ActiveRecord::Migration
2 def self.up
3 add_index :messages, :last_reply_id
4 add_index :messages, :author_id
5 end
6
7 def self.down
8 remove_index :messages, :last_reply_id
9 remove_index :messages, :author_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToRepositories < ActiveRecord::Migration
2 def self.up
3 add_index :repositories, :project_id
4 end
5
6 def self.down
7 remove_index :repositories, :project_id
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToComments < ActiveRecord::Migration
2 def self.up
3 add_index :comments, [:commented_id, :commented_type]
4 add_index :comments, :author_id
5 end
6
7 def self.down
8 remove_index :comments, :column => [:commented_id, :commented_type]
9 remove_index :comments, :author_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToEnumerations < ActiveRecord::Migration
2 def self.up
3 add_index :enumerations, [:id, :type]
4 end
5
6 def self.down
7 remove_index :enumerations, :column => [:id, :type]
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToWikiPages < ActiveRecord::Migration
2 def self.up
3 add_index :wiki_pages, :wiki_id
4 add_index :wiki_pages, :parent_id
5 end
6
7 def self.down
8 remove_index :wiki_pages, :wiki_id
9 remove_index :wiki_pages, :parent_id
10 end
11 end
@@ -0,0 +1,11
1 class AddMissingIndexesToWatchers < ActiveRecord::Migration
2 def self.up
3 add_index :watchers, :user_id
4 add_index :watchers, [:watchable_id, :watchable_type]
5 end
6
7 def self.down
8 remove_index :watchers, :user_id
9 remove_index :watchers, :column => [:watchable_id, :watchable_type]
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToAuthSources < ActiveRecord::Migration
2 def self.up
3 add_index :auth_sources, [:id, :type]
4 end
5
6 def self.down
7 remove_index :auth_sources, :column => [:id, :type]
8 end
9 end
@@ -0,0 +1,9
1 class AddMissingIndexesToDocuments < ActiveRecord::Migration
2 def self.up
3 add_index :documents, :category_id
4 end
5
6 def self.down
7 remove_index :documents, :category_id
8 end
9 end
@@ -0,0 +1,9
1 class AddMissingIndexesToTokens < ActiveRecord::Migration
2 def self.up
3 add_index :tokens, :user_id
4 end
5
6 def self.down
7 remove_index :tokens, :user_id
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToChangesets < ActiveRecord::Migration
2 def self.up
3 add_index :changesets, :user_id
4 add_index :changesets, :repository_id
5 end
6
7 def self.down
8 remove_index :changesets, :user_id
9 remove_index :changesets, :repository_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToIssueCategories < ActiveRecord::Migration
2 def self.up
3 add_index :issue_categories, :assigned_to_id
4 end
5
6 def self.down
7 remove_index :issue_categories, :assigned_to_id
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToMemberRoles < ActiveRecord::Migration
2 def self.up
3 add_index :member_roles, :member_id
4 add_index :member_roles, :role_id
5 end
6
7 def self.down
8 remove_index :member_roles, :member_id
9 remove_index :member_roles, :role_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToBoards < ActiveRecord::Migration
2 def self.up
3 add_index :boards, :last_message_id
4 end
5
6 def self.down
7 remove_index :boards, :last_message_id
8 end
9 end
@@ -0,0 +1,9
1 class AddMissingIndexesToUserPreferences < ActiveRecord::Migration
2 def self.up
3 add_index :user_preferences, :user_id
4 end
5
6 def self.down
7 remove_index :user_preferences, :user_id
8 end
9 end
@@ -0,0 +1,21
1 class AddMissingIndexesToIssues < ActiveRecord::Migration
2 def self.up
3 add_index :issues, :status_id
4 add_index :issues, :category_id
5 add_index :issues, :assigned_to_id
6 add_index :issues, :fixed_version_id
7 add_index :issues, :tracker_id
8 add_index :issues, :priority_id
9 add_index :issues, :author_id
10 end
11
12 def self.down
13 remove_index :issues, :status_id
14 remove_index :issues, :category_id
15 remove_index :issues, :assigned_to_id
16 remove_index :issues, :fixed_version_id
17 remove_index :issues, :tracker_id
18 remove_index :issues, :priority_id
19 remove_index :issues, :author_id
20 end
21 end
@@ -0,0 +1,11
1 class AddMissingIndexesToMembers < ActiveRecord::Migration
2 def self.up
3 add_index :members, :user_id
4 add_index :members, :project_id
5 end
6
7 def self.down
8 remove_index :members, :user_id
9 remove_index :members, :project_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToCustomFields < ActiveRecord::Migration
2 def self.up
3 add_index :custom_fields, [:id, :type]
4 end
5
6 def self.down
7 remove_index :custom_fields, :column => [:id, :type]
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToQueries < ActiveRecord::Migration
2 def self.up
3 add_index :queries, :project_id
4 add_index :queries, :user_id
5 end
6
7 def self.down
8 remove_index :queries, :project_id
9 remove_index :queries, :user_id
10 end
11 end
@@ -0,0 +1,11
1 class AddMissingIndexesToTimeEntries < ActiveRecord::Migration
2 def self.up
3 add_index :time_entries, :activity_id
4 add_index :time_entries, :user_id
5 end
6
7 def self.down
8 remove_index :time_entries, :activity_id
9 remove_index :time_entries, :user_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToNews < ActiveRecord::Migration
2 def self.up
3 add_index :news, :author_id
4 end
5
6 def self.down
7 remove_index :news, :author_id
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToUsers < ActiveRecord::Migration
2 def self.up
3 add_index :users, [:id, :type]
4 add_index :users, :auth_source_id
5 end
6
7 def self.down
8 remove_index :users, :column => [:id, :type]
9 remove_index :users, :auth_source_id
10 end
11 end
@@ -0,0 +1,11
1 class AddMissingIndexesToAttachments < ActiveRecord::Migration
2 def self.up
3 add_index :attachments, [:container_id, :container_type]
4 add_index :attachments, :author_id
5 end
6
7 def self.down
8 remove_index :attachments, :column => [:container_id, :container_type]
9 remove_index :attachments, :author_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToWikiContents < ActiveRecord::Migration
2 def self.up
3 add_index :wiki_contents, :author_id
4 end
5
6 def self.down
7 remove_index :wiki_contents, :author_id
8 end
9 end
@@ -0,0 +1,9
1 class AddMissingIndexesToCustomValues < ActiveRecord::Migration
2 def self.up
3 add_index :custom_values, :custom_field_id
4 end
5
6 def self.down
7 remove_index :custom_values, :custom_field_id
8 end
9 end
@@ -0,0 +1,11
1 class AddMissingIndexesToJournals < ActiveRecord::Migration
2 def self.up
3 add_index :journals, :user_id
4 add_index :journals, :journalized_id
5 end
6
7 def self.down
8 remove_index :journals, :user_id
9 remove_index :journals, :journalized_id
10 end
11 end
@@ -0,0 +1,11
1 class AddMissingIndexesToIssueRelations < ActiveRecord::Migration
2 def self.up
3 add_index :issue_relations, :issue_from_id
4 add_index :issue_relations, :issue_to_id
5 end
6
7 def self.down
8 remove_index :issue_relations, :issue_from_id
9 remove_index :issue_relations, :issue_to_id
10 end
11 end
@@ -0,0 +1,9
1 class AddMissingIndexesToWikiRedirects < ActiveRecord::Migration
2 def self.up
3 add_index :wiki_redirects, :wiki_id
4 end
5
6 def self.down
7 remove_index :wiki_redirects, :wiki_id
8 end
9 end
@@ -0,0 +1,9
1 class AddMissingIndexesToCustomFieldsTrackers < ActiveRecord::Migration
2 def self.up
3 add_index :custom_fields_trackers, [:custom_field_id, :tracker_id]
4 end
5
6 def self.down
7 remove_index :custom_fields_trackers, :column => [:custom_field_id, :tracker_id]
8 end
9 end
General Comments 0
You need to be logged in to leave comments. Login now