class AlterEducoderIndexs < ActiveRecord::Migration[5.2]
  def change

    add_index :onclick_times, :user_id if !index_exists?(:onclick_times, :user_id)
    remove_index :courses, :syllabus_id
    add_index :courses, :tea_id
    add_index :course_modules, [:course_id, :module_type]
    remove_index :homework_commons, :course_homework_category_id
    add_index :exercises, :course_id
    remove_index :teacher_course_groups, :member_id
    remove_index :student_works, :created_at
    remove_index :student_works, :user_id
    remove_index :student_works, :myshixun_id
    remove_index :homework_challenge_settings, :shixun_id
    remove_index :exercise_users, :exercise_id
    add_index :exercise_users, [:exercise_id, :user_id]
    add_index :homework_banks, :user_id
    remove_index :exercise_answers, :exercise_choice_id
    remove_index :exercise_answers, :exercise_question_id
    add_index :exercise_answers, [:exercise_question_id, :user_id]
    remove_index :exercise_shixun_challenges, :shixun_id
    remove_index :exercise_shixun_answers, :exercise_shixun_challenge_id
    remove_index :exercise_shixun_answers, :exercise_question_id
    add_index :exercise_shixun_answers, [:exercise_question_id, :user_id], name: "exercise_question_id_user_id"
    remove_index :student_works_evaluation_distributions, :student_work_id
    add_index :student_works_evaluation_distributions, :user_id
    remove_index :challenge_work_scores, :user_id
    add_index :poll_questions, :poll_id
    add_index :poll_users, [:poll_id, :user_id]
    add_index :poll_answers, :poll_question_id
    add_index :poll_votes, [:poll_question_id, :user_id], name: "poll_question_id_user_id"
    remove_index :graduation_tasks, :user_id
    remove_index :graduation_work_comment_assignations, :graduation_group_id
    remove_index :graduation_works, :course_id
    remove_index :graduation_works, :project_id
    remove_index :graduation_works, :graduation_task_id
    remove_index :graduation_works, :user_id
    add_index :graduation_works, [:graduation_task_id, :user_id], name: "graduation_task_id_user_id"

    remove_index :graduation_work_scores, :graduation_task_id
    remove_index :graduation_topics, :user_id
    remove_index :graduation_topics, :tea_id
    remove_index :student_graduation_topics, :member_id
    remove_index :student_graduation_topics, :course_member_id
    add_index :boards, :course_id
    remove_index :messages, :author_id
    remove_index :messages, :is_hidden
    remove_index :messages, :root_id
    remove_index :messages, :created_on
    remove_index :attachments, :quotes
    remove_index :attachments, :is_public
    remove_index :attachments, :course_second_category_id
    remove_index :course_members, :graduation_group_id
    add_index :student_works_scores_appeals, :student_works_score_id
    add_index :challenges, :shixun_id
    add_index :challenge_chooses, :challenge_id
    add_index :challenge_questions, :challenge_choose_id
    add_index :challenge_tags, :challenge_id
    remove_index :games, :user_id
    add_index :shixun_members, :shixun_id
    add_index :shixun_tag_repertoires, [:shixun_id, :tag_repertoire_id], name: "shixun_id_tag_repertoire_id"
    add_index :shixun_schools, :shixun_id
    add_index :shixun_mirror_repositories, :shixun_id
    add_index :shixun_modifies, [:shixun_id, :myshixun_id], name: "shixun_id_myshixun_id"
    remove_index :myshixuns, :user_id
    remove_index :outputs, :created_at
    remove_index :outputs, :test_set_position
    remove_index :stages, :user_id
  end
end
