0
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2026-08-06 13:08:40 +08:00
discourse/db/migrate/20190418113814_add_unique_index_to_group_requests.rb
2023-01-09 11:59:41 +00:00

8 lines
308 B
Ruby
Vendored

# frozen_string_literal: true
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