I am using Hasura on top of Postgres to store companies and other information. The source data has the same spelling of records, but in differing cases - for example:
name | country |
---|---|
Reckitt Benckiser (Aust) Pty Ltd | US |
RECKITT BENCKISER (AUST) PTY LTD | AU |
I have an index on the name of the company:
CREATE UNIQUE INDEX name_company_unique_idx on company (LOWER(name));
When I "upsert" the second record, it throws a uniqueness error, so the index is working correctly. However what I want is for the second record to realise the first record is the same thing, and update the country to AU. If I don't have the index, I get two records for the same entity, in differing cases.
I don't want to store everything in upper or lower case, but am happy for it to take whatever case the first record that was inserted is.
How can I make the upsert process case agnostic?