How to Set a Unique Constraint to a Table Field

From ElixirBlocks
Revision as of 15:55, 19 October 2023 by Admin (talk | contribs) (Created page with "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: <source> create unique_index(:table_name, [:field_name]) </source>")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

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])