Normalise text to NFC before you compare or store it
"Ömer" === "Ömer" is false when one side spells Ö as a single code point and the other as O plus a combining diaeresis. Filenames from macOS arrive decomposed, most other sources composed, so a uniqueness check lets through two rows that look identical on screen.
const name = raw.normalize("NFC").trim();Normalise at the edge, next to the rest of the validation, and store that form. Postgres can audit what is already there with WHERE name IS NOT NFC NORMALIZED.
javascripti18nvalidation