MDL-41093 qtype match: unique index upgrade problem.

Eliminate duplicate rows before we try to add a unique index. We
arbitrarily keep the duplicate row with the lowest id.