Commit 434710d7 authored by edavis10's avatar edavis10

Adding missing database indexes for foreign keys and STI fields.

git-svn-id: https://svn.redmine.org/redmine/trunk@2928 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 97a5e78e
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
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
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
class AddMissingIndexesToRepositories < ActiveRecord::Migration
def self.up
add_index :repositories, :project_id
end
def self.down
remove_index :repositories, :project_id
end
end
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
class AddMissingIndexesToEnumerations < ActiveRecord::Migration
def self.up
add_index :enumerations, [:id, :type]
end
def self.down
remove_index :enumerations, :column => [:id, :type]
end
end
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
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
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
class AddMissingIndexesToDocuments < ActiveRecord::Migration
def self.up
add_index :documents, :category_id
end
def self.down
remove_index :documents, :category_id
end
end
class AddMissingIndexesToTokens < ActiveRecord::Migration
def self.up
add_index :tokens, :user_id
end
def self.down
remove_index :tokens, :user_id
end
end
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
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
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
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
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
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
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
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
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
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
class AddMissingIndexesToNews < ActiveRecord::Migration
def self.up
add_index :news, :author_id
end
def self.down
remove_index :news, :author_id
end
end
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
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
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
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
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
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
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
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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment