I can't quite follow your question, so I'm proceeding under the following assumptions:
- You paid £31,000
- Your partner paid £4,242
- You have at least one mortgage, which you both pay equally.
If the relationship terminates, sell the property. You are reimbursed £31,000 and your partner is reimbursed £4,242. Any remaining proceeds from the sale are split 50-50. If the result is a net loss (i.e. you are underwater on your mortgage), you split the debt 50-50. If you are not both paying the same toward the mortgage, I'd split the profit or loss according to how much you each pay toward the mortgage.
Of course, this is not the only possible way you can split things up. You can use pretty much any way you both think is fair. For example, maybe you should get more benefits from a profit because you contributed more up-front. The key thing, though, is that you must both agree in writing, in advance. This is reasonable; this is what I did, for example.
Note that if the relationship ends, one or the other of you may wish to keep the property. I'd suggest including a clause in your written agreement simply disallowing this; specify criteria to force a sale. But I know lots of people are happy to allow this. They treat that situation as a forced sale from both people to one person. For example, if your partner chooses to stay in the house, he or she must buy the property from you at prevailing market rates.