fix problems with rename db and detaching already deleted db