Repairing the database