Unique constraint migration

Thanks! Once I started implementing it, I realized I also needed to exclude rows in which position is ‘Unassigned’ which is the default value. Here is what I finally used:

  def up do
    create unique_index(:roster_positions, [:position, :fantasy_team_id],
      where: "status LIKE 'active' AND position != 'Unassigned'")
  end

  def down do
    drop unique_index(:roster_positions, [:position, :fantasy_team_id],
      where: "status LIKE 'active' AND position != 'Unassigned'")
  end

Thanks for the help!!