From 1ccb16f76d8235e6ec29de8590aae3b4aa35c106 Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 11 Mar 2020 17:34:38 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=B4=A2=E5=BC=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...311092049_add_index_user_id_challenge_id_for_games.rb | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb diff --git a/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb b/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb new file mode 100644 index 000000000..c9fab49d4 --- /dev/null +++ b/db/migrate/20200311092049_add_index_user_id_challenge_id_for_games.rb @@ -0,0 +1,9 @@ +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