[database] fix duplicate ids