defmodule Carbon.Repo.Migrations.AddForeignKeyIndexes do
  use Ecto.Migration

  def change do
    create index :accounts, [ :billing_address_id ]
    create index :accounts, [ :owner_id ]
    create index :accounts, [ :shipping_address_id ]
    create index :accounts, [ :status_id ]
    create index :activities, [ :user_id ]
    create index :attachments, [ :account_id ]
    create index :attachments, [ :user_id ]
    create index :contacts, [ :account_id ]
    create index :deals, [ :account_id ]
    create index :deals, [ :owner_id ]
    create index :events, [ :account_id ]
    create index :events, [ :user_id ]
    create index :j_accounts_tags, [ :account_id ]
    create index :j_accounts_tags, [ :account_tag_id ]
    create index :j_contacts_tags, [ :contact_id ]
    create index :j_contacts_tags, [ :contact_tag_id ]
    create index :j_deals_tags, [ :deal_id ]
    create index :j_deals_tags, [ :deal_tag_id ]
    create index :j_events_tags, [ :event_id ]
    create index :j_events_tags, [ :event_tag_id ]
    create index :j_projects_tags, [ :project_id ]
    create index :j_projects_tags, [ :project_tag_id ]
    create index :j_timesheet_entries_tags, [ :timesheet_entry_id ]
    create index :j_timesheet_entries_tags, [ :timesheet_entry_tag_id ]
    create index :j_users_roles, [ :role_id ]
    create index :j_users_roles, [ :user_id ]
    create index :projects, [ :account_id ]
    create index :projects, [ :phase_id ]
    create index :reminders, [ :event_id ]
    create index :reminders, [ :user_id ]
    create index :rules, [ :user_id ]
    create index :rules, [ :workflow_id ]
    create index :timesheet_entries, [ :account_id ]
    create index :timesheet_entries, [ :project_id ]
    create index :timesheet_entries, [ :timesheet_id ]
    create index :timesheets, [ :status_id ]
    create index :timesheets, [ :user_id ]
    create index :workflow_field_enums, [ :field_id ]
    create index :workflow_field_values, [ :field_id ]
    create index :workflow_field_values, [ :instance_id ]
    create index :workflow_fields, [ :section_id ]
    create index :workflow_instances, [ :state_id ]
    create index :workflow_instances, [ :workflow_id ]
    create index :workflow_sections, [ :workflow_id ]
    create index :workflow_states, [ :workflow_id ]
  end
end
