think what you want is unique_index: Ecto.Migration — Ecto SQL v3.14.0
then you must also handle the conflict case..
additionally I would default the count to 0, and then I would do the increment on the DB side eg. something like this (ecto-fied)
UPDATE counts
SET count = count + 1
WHERE owner_id = X and date = Y;
you might just want to bring it all together in an upsert..






















