The evolution of the mass—metallicity relation in SDSS galaxies uncovered by astropaleontology