Section 51. In all civil proceedings, the court may at any time, allow amendments adding a party, discontinuing as to a party or changing the form of the action, and may allow any other amendment in matter of form or substance in any process, pleading or proceeding, which may enable the plaintiff to sustain the action for the cause or for recovery for the injury for which the action was intended to be brought, or enable the defendant to make a legal defense. Any amendment allowed pursuant to this section or pursuant to the Massachusetts Rules of Civil Procedure shall relate to the original pleading.