From 70118fb136b1318843e7146ed2e31e575c884ce3 Mon Sep 17 00:00:00 2001 From: Eric Davis Date: Sat, 17 Oct 2009 22:23:29 +0000 Subject: [PATCH] Adding missing database indexes for foreign keys and STI fields. git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@2928 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- ...212227_add_missing_indexes_to_workflows.rb | 13 ++++++++++++ ...ssing_indexes_to_custom_fields_projects.rb | 9 ++++++++ ...7212644_add_missing_indexes_to_messages.rb | 11 ++++++++++ ...938_add_missing_indexes_to_repositories.rb | 9 ++++++++ ...7213027_add_missing_indexes_to_comments.rb | 11 ++++++++++ ...113_add_missing_indexes_to_enumerations.rb | 9 ++++++++ ...13151_add_missing_indexes_to_wiki_pages.rb | 11 ++++++++++ ...7213228_add_missing_indexes_to_watchers.rb | 11 ++++++++++ ...257_add_missing_indexes_to_auth_sources.rb | 9 ++++++++ ...213332_add_missing_indexes_to_documents.rb | 9 ++++++++ ...017213444_add_missing_indexes_to_tokens.rb | 9 ++++++++ ...13536_add_missing_indexes_to_changesets.rb | 11 ++++++++++ ...add_missing_indexes_to_issue_categories.rb | 9 ++++++++ ...716_add_missing_indexes_to_member_roles.rb | 11 ++++++++++ ...017213757_add_missing_indexes_to_boards.rb | 9 ++++++++ ...add_missing_indexes_to_user_preferences.rb | 9 ++++++++ ...017213910_add_missing_indexes_to_issues.rb | 21 +++++++++++++++++++ ...17214015_add_missing_indexes_to_members.rb | 11 ++++++++++ ...07_add_missing_indexes_to_custom_fields.rb | 9 ++++++++ ...17214136_add_missing_indexes_to_queries.rb | 11 ++++++++++ ...236_add_missing_indexes_to_time_entries.rb | 11 ++++++++++ ...91017214308_add_missing_indexes_to_news.rb | 9 ++++++++ ...1017214336_add_missing_indexes_to_users.rb | 11 ++++++++++ ...4406_add_missing_indexes_to_attachments.rb | 11 ++++++++++ ...40_add_missing_indexes_to_wiki_contents.rb | 9 ++++++++ ...19_add_missing_indexes_to_custom_values.rb | 9 ++++++++ ...7214611_add_missing_indexes_to_journals.rb | 11 ++++++++++ ..._add_missing_indexes_to_issue_relations.rb | 11 ++++++++++ ...0_add_missing_indexes_to_wiki_redirects.rb | 9 ++++++++ ...ssing_indexes_to_custom_fields_trackers.rb | 9 ++++++++ 30 files changed, 312 insertions(+) create mode 100644 db/migrate/20091017212227_add_missing_indexes_to_workflows.rb create mode 100644 db/migrate/20091017212457_add_missing_indexes_to_custom_fields_projects.rb create mode 100644 db/migrate/20091017212644_add_missing_indexes_to_messages.rb create mode 100644 db/migrate/20091017212938_add_missing_indexes_to_repositories.rb create mode 100644 db/migrate/20091017213027_add_missing_indexes_to_comments.rb create mode 100644 db/migrate/20091017213113_add_missing_indexes_to_enumerations.rb create mode 100644 db/migrate/20091017213151_add_missing_indexes_to_wiki_pages.rb create mode 100644 db/migrate/20091017213228_add_missing_indexes_to_watchers.rb create mode 100644 db/migrate/20091017213257_add_missing_indexes_to_auth_sources.rb create mode 100644 db/migrate/20091017213332_add_missing_indexes_to_documents.rb create mode 100644 db/migrate/20091017213444_add_missing_indexes_to_tokens.rb create mode 100644 db/migrate/20091017213536_add_missing_indexes_to_changesets.rb create mode 100644 db/migrate/20091017213642_add_missing_indexes_to_issue_categories.rb create mode 100644 db/migrate/20091017213716_add_missing_indexes_to_member_roles.rb create mode 100644 db/migrate/20091017213757_add_missing_indexes_to_boards.rb create mode 100644 db/migrate/20091017213835_add_missing_indexes_to_user_preferences.rb create mode 100644 db/migrate/20091017213910_add_missing_indexes_to_issues.rb create mode 100644 db/migrate/20091017214015_add_missing_indexes_to_members.rb create mode 100644 db/migrate/20091017214107_add_missing_indexes_to_custom_fields.rb create mode 100644 db/migrate/20091017214136_add_missing_indexes_to_queries.rb create mode 100644 db/migrate/20091017214236_add_missing_indexes_to_time_entries.rb create mode 100644 db/migrate/20091017214308_add_missing_indexes_to_news.rb create mode 100644 db/migrate/20091017214336_add_missing_indexes_to_users.rb create mode 100644 db/migrate/20091017214406_add_missing_indexes_to_attachments.rb create mode 100644 db/migrate/20091017214440_add_missing_indexes_to_wiki_contents.rb create mode 100644 db/migrate/20091017214519_add_missing_indexes_to_custom_values.rb create mode 100644 db/migrate/20091017214611_add_missing_indexes_to_journals.rb create mode 100644 db/migrate/20091017214644_add_missing_indexes_to_issue_relations.rb create mode 100644 db/migrate/20091017214720_add_missing_indexes_to_wiki_redirects.rb create mode 100644 db/migrate/20091017214750_add_missing_indexes_to_custom_fields_trackers.rb diff --git a/db/migrate/20091017212227_add_missing_indexes_to_workflows.rb b/db/migrate/20091017212227_add_missing_indexes_to_workflows.rb new file mode 100644 index 000000000..13fa0137e --- /dev/null +++ b/db/migrate/20091017212227_add_missing_indexes_to_workflows.rb @@ -0,0 +1,13 @@ +class AddMissingIndexesToWorkflows < ActiveRecord::Migration + def self.up + add_index :workflows, :old_status_id + add_index :workflows, :role_id + add_index :workflows, :new_status_id + end + + def self.down + remove_index :workflows, :old_status_id + remove_index :workflows, :role_id + remove_index :workflows, :new_status_id + end +end diff --git a/db/migrate/20091017212457_add_missing_indexes_to_custom_fields_projects.rb b/db/migrate/20091017212457_add_missing_indexes_to_custom_fields_projects.rb new file mode 100644 index 000000000..b95f54327 --- /dev/null +++ b/db/migrate/20091017212457_add_missing_indexes_to_custom_fields_projects.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToCustomFieldsProjects < ActiveRecord::Migration + def self.up + add_index :custom_fields_projects, [:custom_field_id, :project_id] + end + + def self.down + remove_index :custom_fields_projects, :column => [:custom_field_id, :project_id] + end +end diff --git a/db/migrate/20091017212644_add_missing_indexes_to_messages.rb b/db/migrate/20091017212644_add_missing_indexes_to_messages.rb new file mode 100644 index 000000000..23c272995 --- /dev/null +++ b/db/migrate/20091017212644_add_missing_indexes_to_messages.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToMessages < ActiveRecord::Migration + def self.up + add_index :messages, :last_reply_id + add_index :messages, :author_id + end + + def self.down + remove_index :messages, :last_reply_id + remove_index :messages, :author_id + end +end diff --git a/db/migrate/20091017212938_add_missing_indexes_to_repositories.rb b/db/migrate/20091017212938_add_missing_indexes_to_repositories.rb new file mode 100644 index 000000000..b9f43b6df --- /dev/null +++ b/db/migrate/20091017212938_add_missing_indexes_to_repositories.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToRepositories < ActiveRecord::Migration + def self.up + add_index :repositories, :project_id + end + + def self.down + remove_index :repositories, :project_id + end +end diff --git a/db/migrate/20091017213027_add_missing_indexes_to_comments.rb b/db/migrate/20091017213027_add_missing_indexes_to_comments.rb new file mode 100644 index 000000000..2a1ed27c0 --- /dev/null +++ b/db/migrate/20091017213027_add_missing_indexes_to_comments.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToComments < ActiveRecord::Migration + def self.up + add_index :comments, [:commented_id, :commented_type] + add_index :comments, :author_id + end + + def self.down + remove_index :comments, :column => [:commented_id, :commented_type] + remove_index :comments, :author_id + end +end diff --git a/db/migrate/20091017213113_add_missing_indexes_to_enumerations.rb b/db/migrate/20091017213113_add_missing_indexes_to_enumerations.rb new file mode 100644 index 000000000..85dedf816 --- /dev/null +++ b/db/migrate/20091017213113_add_missing_indexes_to_enumerations.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToEnumerations < ActiveRecord::Migration + def self.up + add_index :enumerations, [:id, :type] + end + + def self.down + remove_index :enumerations, :column => [:id, :type] + end +end diff --git a/db/migrate/20091017213151_add_missing_indexes_to_wiki_pages.rb b/db/migrate/20091017213151_add_missing_indexes_to_wiki_pages.rb new file mode 100644 index 000000000..7fab09e38 --- /dev/null +++ b/db/migrate/20091017213151_add_missing_indexes_to_wiki_pages.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToWikiPages < ActiveRecord::Migration + def self.up + add_index :wiki_pages, :wiki_id + add_index :wiki_pages, :parent_id + end + + def self.down + remove_index :wiki_pages, :wiki_id + remove_index :wiki_pages, :parent_id + end +end diff --git a/db/migrate/20091017213228_add_missing_indexes_to_watchers.rb b/db/migrate/20091017213228_add_missing_indexes_to_watchers.rb new file mode 100644 index 000000000..618e1cd94 --- /dev/null +++ b/db/migrate/20091017213228_add_missing_indexes_to_watchers.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToWatchers < ActiveRecord::Migration + def self.up + add_index :watchers, :user_id + add_index :watchers, [:watchable_id, :watchable_type] + end + + def self.down + remove_index :watchers, :user_id + remove_index :watchers, :column => [:watchable_id, :watchable_type] + end +end diff --git a/db/migrate/20091017213257_add_missing_indexes_to_auth_sources.rb b/db/migrate/20091017213257_add_missing_indexes_to_auth_sources.rb new file mode 100644 index 000000000..ccd4f0440 --- /dev/null +++ b/db/migrate/20091017213257_add_missing_indexes_to_auth_sources.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToAuthSources < ActiveRecord::Migration + def self.up + add_index :auth_sources, [:id, :type] + end + + def self.down + remove_index :auth_sources, :column => [:id, :type] + end +end diff --git a/db/migrate/20091017213332_add_missing_indexes_to_documents.rb b/db/migrate/20091017213332_add_missing_indexes_to_documents.rb new file mode 100644 index 000000000..f5190181e --- /dev/null +++ b/db/migrate/20091017213332_add_missing_indexes_to_documents.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToDocuments < ActiveRecord::Migration + def self.up + add_index :documents, :category_id + end + + def self.down + remove_index :documents, :category_id + end +end diff --git a/db/migrate/20091017213444_add_missing_indexes_to_tokens.rb b/db/migrate/20091017213444_add_missing_indexes_to_tokens.rb new file mode 100644 index 000000000..f0979f21c --- /dev/null +++ b/db/migrate/20091017213444_add_missing_indexes_to_tokens.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToTokens < ActiveRecord::Migration + def self.up + add_index :tokens, :user_id + end + + def self.down + remove_index :tokens, :user_id + end +end diff --git a/db/migrate/20091017213536_add_missing_indexes_to_changesets.rb b/db/migrate/20091017213536_add_missing_indexes_to_changesets.rb new file mode 100644 index 000000000..303be838d --- /dev/null +++ b/db/migrate/20091017213536_add_missing_indexes_to_changesets.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToChangesets < ActiveRecord::Migration + def self.up + add_index :changesets, :user_id + add_index :changesets, :repository_id + end + + def self.down + remove_index :changesets, :user_id + remove_index :changesets, :repository_id + end +end diff --git a/db/migrate/20091017213642_add_missing_indexes_to_issue_categories.rb b/db/migrate/20091017213642_add_missing_indexes_to_issue_categories.rb new file mode 100644 index 000000000..3f5b2b185 --- /dev/null +++ b/db/migrate/20091017213642_add_missing_indexes_to_issue_categories.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToIssueCategories < ActiveRecord::Migration + def self.up + add_index :issue_categories, :assigned_to_id + end + + def self.down + remove_index :issue_categories, :assigned_to_id + end +end diff --git a/db/migrate/20091017213716_add_missing_indexes_to_member_roles.rb b/db/migrate/20091017213716_add_missing_indexes_to_member_roles.rb new file mode 100644 index 000000000..e9ff62db9 --- /dev/null +++ b/db/migrate/20091017213716_add_missing_indexes_to_member_roles.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToMemberRoles < ActiveRecord::Migration + def self.up + add_index :member_roles, :member_id + add_index :member_roles, :role_id + end + + def self.down + remove_index :member_roles, :member_id + remove_index :member_roles, :role_id + end +end diff --git a/db/migrate/20091017213757_add_missing_indexes_to_boards.rb b/db/migrate/20091017213757_add_missing_indexes_to_boards.rb new file mode 100644 index 000000000..d3e94226a --- /dev/null +++ b/db/migrate/20091017213757_add_missing_indexes_to_boards.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToBoards < ActiveRecord::Migration + def self.up + add_index :boards, :last_message_id + end + + def self.down + remove_index :boards, :last_message_id + end +end diff --git a/db/migrate/20091017213835_add_missing_indexes_to_user_preferences.rb b/db/migrate/20091017213835_add_missing_indexes_to_user_preferences.rb new file mode 100644 index 000000000..f3a8ccbcb --- /dev/null +++ b/db/migrate/20091017213835_add_missing_indexes_to_user_preferences.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToUserPreferences < ActiveRecord::Migration + def self.up + add_index :user_preferences, :user_id + end + + def self.down + remove_index :user_preferences, :user_id + end +end diff --git a/db/migrate/20091017213910_add_missing_indexes_to_issues.rb b/db/migrate/20091017213910_add_missing_indexes_to_issues.rb new file mode 100644 index 000000000..d651a5463 --- /dev/null +++ b/db/migrate/20091017213910_add_missing_indexes_to_issues.rb @@ -0,0 +1,21 @@ +class AddMissingIndexesToIssues < ActiveRecord::Migration + def self.up + add_index :issues, :status_id + add_index :issues, :category_id + add_index :issues, :assigned_to_id + add_index :issues, :fixed_version_id + add_index :issues, :tracker_id + add_index :issues, :priority_id + add_index :issues, :author_id + end + + def self.down + remove_index :issues, :status_id + remove_index :issues, :category_id + remove_index :issues, :assigned_to_id + remove_index :issues, :fixed_version_id + remove_index :issues, :tracker_id + remove_index :issues, :priority_id + remove_index :issues, :author_id + end +end diff --git a/db/migrate/20091017214015_add_missing_indexes_to_members.rb b/db/migrate/20091017214015_add_missing_indexes_to_members.rb new file mode 100644 index 000000000..5fdf560fa --- /dev/null +++ b/db/migrate/20091017214015_add_missing_indexes_to_members.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToMembers < ActiveRecord::Migration + def self.up + add_index :members, :user_id + add_index :members, :project_id + end + + def self.down + remove_index :members, :user_id + remove_index :members, :project_id + end +end diff --git a/db/migrate/20091017214107_add_missing_indexes_to_custom_fields.rb b/db/migrate/20091017214107_add_missing_indexes_to_custom_fields.rb new file mode 100644 index 000000000..18be0b44b --- /dev/null +++ b/db/migrate/20091017214107_add_missing_indexes_to_custom_fields.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToCustomFields < ActiveRecord::Migration + def self.up + add_index :custom_fields, [:id, :type] + end + + def self.down + remove_index :custom_fields, :column => [:id, :type] + end +end diff --git a/db/migrate/20091017214136_add_missing_indexes_to_queries.rb b/db/migrate/20091017214136_add_missing_indexes_to_queries.rb new file mode 100644 index 000000000..414b1ad6b --- /dev/null +++ b/db/migrate/20091017214136_add_missing_indexes_to_queries.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToQueries < ActiveRecord::Migration + def self.up + add_index :queries, :project_id + add_index :queries, :user_id + end + + def self.down + remove_index :queries, :project_id + remove_index :queries, :user_id + end +end diff --git a/db/migrate/20091017214236_add_missing_indexes_to_time_entries.rb b/db/migrate/20091017214236_add_missing_indexes_to_time_entries.rb new file mode 100644 index 000000000..cffc528ea --- /dev/null +++ b/db/migrate/20091017214236_add_missing_indexes_to_time_entries.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToTimeEntries < ActiveRecord::Migration + def self.up + add_index :time_entries, :activity_id + add_index :time_entries, :user_id + end + + def self.down + remove_index :time_entries, :activity_id + remove_index :time_entries, :user_id + end +end diff --git a/db/migrate/20091017214308_add_missing_indexes_to_news.rb b/db/migrate/20091017214308_add_missing_indexes_to_news.rb new file mode 100644 index 000000000..808eb6294 --- /dev/null +++ b/db/migrate/20091017214308_add_missing_indexes_to_news.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToNews < ActiveRecord::Migration + def self.up + add_index :news, :author_id + end + + def self.down + remove_index :news, :author_id + end +end diff --git a/db/migrate/20091017214336_add_missing_indexes_to_users.rb b/db/migrate/20091017214336_add_missing_indexes_to_users.rb new file mode 100644 index 000000000..c5a509587 --- /dev/null +++ b/db/migrate/20091017214336_add_missing_indexes_to_users.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToUsers < ActiveRecord::Migration + def self.up + add_index :users, [:id, :type] + add_index :users, :auth_source_id + end + + def self.down + remove_index :users, :column => [:id, :type] + remove_index :users, :auth_source_id + end +end diff --git a/db/migrate/20091017214406_add_missing_indexes_to_attachments.rb b/db/migrate/20091017214406_add_missing_indexes_to_attachments.rb new file mode 100644 index 000000000..d22fc98ed --- /dev/null +++ b/db/migrate/20091017214406_add_missing_indexes_to_attachments.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToAttachments < ActiveRecord::Migration + def self.up + add_index :attachments, [:container_id, :container_type] + add_index :attachments, :author_id + end + + def self.down + remove_index :attachments, :column => [:container_id, :container_type] + remove_index :attachments, :author_id + end +end diff --git a/db/migrate/20091017214440_add_missing_indexes_to_wiki_contents.rb b/db/migrate/20091017214440_add_missing_indexes_to_wiki_contents.rb new file mode 100644 index 000000000..454e4c5d0 --- /dev/null +++ b/db/migrate/20091017214440_add_missing_indexes_to_wiki_contents.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToWikiContents < ActiveRecord::Migration + def self.up + add_index :wiki_contents, :author_id + end + + def self.down + remove_index :wiki_contents, :author_id + end +end diff --git a/db/migrate/20091017214519_add_missing_indexes_to_custom_values.rb b/db/migrate/20091017214519_add_missing_indexes_to_custom_values.rb new file mode 100644 index 000000000..b192a7e2a --- /dev/null +++ b/db/migrate/20091017214519_add_missing_indexes_to_custom_values.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToCustomValues < ActiveRecord::Migration + def self.up + add_index :custom_values, :custom_field_id + end + + def self.down + remove_index :custom_values, :custom_field_id + end +end diff --git a/db/migrate/20091017214611_add_missing_indexes_to_journals.rb b/db/migrate/20091017214611_add_missing_indexes_to_journals.rb new file mode 100644 index 000000000..2667f4034 --- /dev/null +++ b/db/migrate/20091017214611_add_missing_indexes_to_journals.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToJournals < ActiveRecord::Migration + def self.up + add_index :journals, :user_id + add_index :journals, :journalized_id + end + + def self.down + remove_index :journals, :user_id + remove_index :journals, :journalized_id + end +end diff --git a/db/migrate/20091017214644_add_missing_indexes_to_issue_relations.rb b/db/migrate/20091017214644_add_missing_indexes_to_issue_relations.rb new file mode 100644 index 000000000..fc57f18bf --- /dev/null +++ b/db/migrate/20091017214644_add_missing_indexes_to_issue_relations.rb @@ -0,0 +1,11 @@ +class AddMissingIndexesToIssueRelations < ActiveRecord::Migration + def self.up + add_index :issue_relations, :issue_from_id + add_index :issue_relations, :issue_to_id + end + + def self.down + remove_index :issue_relations, :issue_from_id + remove_index :issue_relations, :issue_to_id + end +end diff --git a/db/migrate/20091017214720_add_missing_indexes_to_wiki_redirects.rb b/db/migrate/20091017214720_add_missing_indexes_to_wiki_redirects.rb new file mode 100644 index 000000000..7442a544f --- /dev/null +++ b/db/migrate/20091017214720_add_missing_indexes_to_wiki_redirects.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToWikiRedirects < ActiveRecord::Migration + def self.up + add_index :wiki_redirects, :wiki_id + end + + def self.down + remove_index :wiki_redirects, :wiki_id + end +end diff --git a/db/migrate/20091017214750_add_missing_indexes_to_custom_fields_trackers.rb b/db/migrate/20091017214750_add_missing_indexes_to_custom_fields_trackers.rb new file mode 100644 index 000000000..c398b7931 --- /dev/null +++ b/db/migrate/20091017214750_add_missing_indexes_to_custom_fields_trackers.rb @@ -0,0 +1,9 @@ +class AddMissingIndexesToCustomFieldsTrackers < ActiveRecord::Migration + def self.up + add_index :custom_fields_trackers, [:custom_field_id, :tracker_id] + end + + def self.down + remove_index :custom_fields_trackers, :column => [:custom_field_id, :tracker_id] + end +end