To prevent charging or discharging in either direction, I installed a lighted switch on the dash of the tow vehicle in line from the
battery to the trailer. As well I have a 15 amp fuse in the line.
I only charge when underway and shut it off before I stop. As a double check I always disconnect electrically from the tow vehicle even if I am not mechanically disconnecting from the tow vehicle.
A number of people on the site have installed a relay to perform this function. I like doing it myself.