discourse/db/migrate/20210308195916_add_unique_index_to_invited_groups.rb
2023-01-09 11:59:41 +00:00

16 lines
379 B
Ruby

# frozen_string_literal: true
class AddUniqueIndexToInvitedGroups < ActiveRecord::Migration[6.0]
def change
execute <<~SQL
DELETE FROM invited_groups a
USING invited_groups b
WHERE a.id < b.id
AND a.invite_id = b.invite_id
AND a.group_id = b.group_id
SQL
add_index :invited_groups, %i[group_id invite_id], unique: true
end
end