discourse/db/migrate/20210308195916_add_unique_i...

16 lines
380 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, [:group_id, :invite_id], unique: true
end
end