Closed jkva closed 4 years ago
There is not a uniqueness constraint, but I think there can be one.
SELECT
resources.id,
other.id AS duplicate_id,
resources.source_uri,
other.source_uri AS other_uri,
organizations.title
FROM
resources
JOIN organizations ON resources.organization_id = organizations.id
JOIN resources other ON other.id != resources.id
AND lower(other.source_uri) = lower(resources.source_uri)
WHERE
resources.source_uri IS NOT NULL
AND resources.source_uri != '';
returns 0 results on production. I will have to clear out, like, everything @jkva has done on staging - but hopefully that's okay.
Just a note that the constraint should be scoped to an org e.g. an org should only ever have 1 resource with a single URI, even if there are dozens of representations describing that resource, or so I feel.
Ah thanks for that @sinabahram - I'll ensure the uniqueness is scoped
This is finished and live
When I create a new resource via the API by posting
to
https://staging.coyote.pics/api/v1/organizations/1/resources
I can do this multiple times, each time receiving a
201 CREATED
with resource JSON response body. Even though thesource_uri
is each time the same. Is this by design?