2am leg cramp

As title states, basically at 2am I woke in agony with a cramp in my calf. Woke my partner up in my pain/panic asking him what I do. I've never really had a cramp before. It was horrible.

I'm taking magnesium before bed, and I drink a lot of water throughout the day. Anything else I can do? Because I do not want that to happen again.