class AddIndexUserIdChallengeIdForGames < ActiveRecord::Migration[5.2]
  def change
    delete_games = Game.where.not(myshixun_id: Myshixun.all).reorder(nil)
    puts "delete_games: #{delete_games.pluck(:id)}"
    delete_games.destroy_all

    add_index :games, [:user_id, :challenge_id], unique: true
  end
end
