parent
6191377f81
commit
514ceaf73e
@ -0,0 +1,12 @@
|
||||
class AddIndexToUserIdAndShixunIdForShixuns < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
shixun_members = ShixunMember.select("count(*) cnt, shixun_members.*").group(:user_id, :shixun_id).having("cnt > 1")
|
||||
puts "shixun_members: #{shixun_members.map{|sm| sm.id}}"
|
||||
shixun_members.each do |sm|
|
||||
ShixunModify.find_by(id: sm.id).delete
|
||||
end
|
||||
|
||||
add_index :shixun_members, [:user_id, :shixun_id], unique: true
|
||||
|
||||
end
|
||||
end
|
Loading…
Reference in new issue