How to Set a Unique Constraint to a Table Field
From ElixirBlocks
If you already have a table and retroactively want to set a field to only allow unique values, you need to create a migration with:
create unique_index(:table_name, [:field_name])