fix bugs in manage db scripts