Here is a link to a topic re. rats, which contains links to several others. https://www.hedgehogstreet.org/forums/topic/rat-probelm/
Re. sonic rat repellers. There is no evidence that they don’t deter hedgehogs, but also they tend not to work well on rats outside. The rats just get used to them. In fact I was told by a maker of them that they couldn’t do tests to prove they didn’t upset hogs and if I ever bought one that I should ask for a money back guarantee that they would keep rats away outside – because he didn’t believe that they would. But I did try one once, years ago, just in the daytime and one night a hog turned up early before it was taken in and I saw it visibly flinch when it went past the repeller. So I would not use them with hogs around.
I recently had a rat here and so started putting out kitten biscuits instead of the mix of hog food and kitten biscuits I normally use. The rat approached within about a foot of the food and retreated – it did that several times but after a couple of nights it gave up – no food for it. It hasn’t been seen again since – probably a couple of weks – and I am now feeding their usual food again. But you do need to make absolutely sure (if you feed the birds) that there is no bird food dropped which a rat can eat.