Repairing database structure