Conditional unique index with Ecto
I was going to create a conditional index using raw sql like this:
execute("""
create unique index posts_name_index on posts (name) where deleted_at is null;
""")
But then I learned that you can use the where
option with create unique_index
:
create unique_index(:posts, [:name], where: "deleted_at is null")
Tweet