2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2019-04-22 22:51:30 -04:00
|
|
|
class AddUniqueIndexToGroupRequests < ActiveRecord::Migration[5.2]
|
|
|
|
def change
|
|
|
|
execute "DELETE FROM group_requests WHERE id NOT IN (SELECT MIN(id) FROM group_requests GROUP BY group_id, user_id)"
|
|
|
|
add_index :group_requests, %i[group_id user_id], unique: true
|
|
|
|
end
|
|
|
|
end
|