fix db generation code