Fix a regression in db building