Depression is caused by a near infinite number of factors. For some it is one hundred percent diet related and it is diet related for multiple reasons. Some of these reasons include, but not limited to, poor nutrition, gut flora, genetic factors affecting absorption, storage, utilization and conversion of needed vitamin/minerals/amino acids/etc and for some indirect reasons that I am briefly touch on later. For others depression is caused by environmental reasons, trauma, being mentally idle, chemical imbalances, lack of support, loneliness, lack of exercise, various mental illnesses, genetic disposition, and many more too numerous to mention. Then you have the combination of these near infinite factors working together where any by themselves would not had affected the individual as greatly. It isn't a simple topic in the least and would take many books to fully explore just a small fraction of it. This is also partly why advancements here are slow. Even with some of the drugs that do work for a certain percentage of the population it is unknown why, only hypothesized.
We have to understand how uniquely different each of us are on many levels and how tackling this issue must be custom to the individual and not generic to the crowd. With that said what works for you, or didn't work for you, in no way determines what it will do for others. Even with that, what you thought did or didn't work for you may not be an accurate assessment on your part as some other variable you are not thinking about took place around the same time period. Once again, complexity here is through the roof, if one is to responsibility access the data.
But let us explore an indirect way diet affects current depression, potential future worsening of depression and future causes of depression. This is what most overlook as we all tend to think in the short term. Indirect comes from damage caused by a poor diet overtime. A poor, or inefficient diet for you, may weaken your immune system allowing a current condition to worsen or allow a later infection to damage you. Your diet may cause the damaging of your teeth over time far quicker than normal. These are simple examples but hopefully it shows how diet affects depression in the long run. This is also how depression can perpetuate itself.
On the topic of sugar, keep in mind that not all sugars are the same in how they are processed by the body, where they are stored in the body and how they affect the body. Then you must consider that products containing various forms of sugar also often contain other additives which in themselves may be causing issues with you. Fructose as an example is process by and stored only in the liver, which has limited compacity, while glucose will be stored all throughout the body. High fructose corn syrup in still used in some products and you have additives like Carrageenan that is used as a thickening agent in some sweet products, among others, that data shows possible negatives with consuming. Once again it isn't as simple as I eat or don't eat sugar. What kind of sugar and what were the other ingredients?
In short, life is complicated. Do consider eating as well as you can. The odds are far greater in your favor of a benefit now and in the long run by doing so. With that, to clarify for the sticklers out there, it is your choice. I am not a doctor but instead a professional online idiot so only use my words as inspiration to do your own thorough research or consult a professional. I am too tired to proofread the above so hopefully mistakes are at a minimum. DM me or tag me in a way that gets an alert if I need to respond to something. I almost never revisit threads.