The best solution to purify the karma of having depression is to do the purification practice of Vajrasattva. As long as the karma isn't purified, you'll continue to suffer from depression again in future lives.
Maybe you wake up in the morning feeling depressed for no particular reason. If you can't solve this problem through meditation it might help to just go to sleep, or go somewhere to rest, or take a nice drive somewhere. Otherwise you'll get upset, disturbing the people around you as well. When you're angry, all sorts of bad, uncontrolled thoughts can come into your mind.
If you're depressed due to a certain situation then you can apply the meditation techniques that relate to that particular set of conditions. But if you just feel sad for no particular reason, it's best to practice bodhicitta.
You can recite the verse from the Guru Puja, "Please bless me to realize that the disease of the self cherishing thought is the door to unwanted suffering." Blame the demon, the self-cherishing thought, for your problem of depression. Then recite the next verse, 'Bless me to realize that cherishing others, bodhicitta, the attitude that leads all mother living beings to happiness, is the door to every excellent quality."
Another quote from Guru Puja is, "Even if all living beings become my enemy, may I cherish them more than my life." It's very good if you can recite these verses daily, especially when you feel depressed. Then you'll be using your depression to practice the meaning of these two verses; that all problems and suffering come from cherishing the 'I', therefore the I is the object to be renounced, to be given up. All your own and others' happiness, including all the realizations up to enlightenment—all perfections and happiness come from cherishing others—bodhicitta.
Because all these good things come from the attitude of cherishing others, they depend on other living beings. Therefore living beings are to be cherished forever. You need to repay the kindness of all these precious beings, to help them however you can. How best to do this? They've been millionaires countless times, they've even been universal kings but none of this power or wealth has freed them from the sufferings of samsara. The best way to repay their kindness is to practice Lam-rim, to transform the mind from ignorance, attachment and self-cherishing into wholesome, pure thoughts. By actualizing the path to enlightenment you can easily liberate other beings. Therefore the best way to repay their kindness is to meditate on and develop bodhicitta in your own mind.
Every living being is the source of all your past, present, future happiness. Generate compassion by thinking, "I'll take all their suffering and its causes (afflictive emotions and negative karmic imprints) including the fires of the hot hells, the ice of the cold hells and the unpleasant, unhealthy, ugly, unpeaceful and polluted environments of human beings into my heart." This eliminates the self-cherishing attitude. Once the self-cherishing attitude has been destroyed do a short meditation on emptiness.
After the self-cherishing has been destroyed, generate love by giving your own happiness, your merit, all the good things you have, including your body, wealth and possessions. All their wishes are fulfilled as if they had a wish-granting jewel. By giving them all these things you create unbelievable amounts of merit. You can recite mantra while they're receiving everything they want and need. Actually they don't know what they really need. What they need is to meet the Dharma. But if they don't understand the benefits of the Dharma, they want something other than Dharma.
Receiving all these good things causes them to actualize the spiritual path, to purify the two obscurations (to liberation and enlightenment). They achieve the rupakaya (the form bodies of a buddha) and become enlightened. Think, "How wonderful it is that I can do all this for others! I've died many times in past lives while working for my own happiness, but it didn't accomplish anything. I'm still in samsara. I've never died while working for others. Even if I have to die for the benefit of others, for them to stop creating negative karma, to not be reborn in the lower realms and for their minds to become the dharmakaya and rupakaya and enlightened, it would be immensely worthwhile.
Meditate on the extensive kindness and preciousness of all beings. "Every living being is the source of all my past, present, future hap. My own future Buddha, Dharma and Sangha come from purifying my negative karma enabling me to attain all the realizations and to achieve enlightenment. All this happens on the basis of other beings. Therefore every sentient being is the most precious thing in my life. Anything other than working for living beings is totally meaningless." This includes experiencing depression for them. There's nothing to work for other than sentient beings. Anything else is totally meaningless. Experience depression on their behalf by thinking this isn't my depression but the depression of numberless beings, this is their depression, their suffering. To give them every happiness; including freedom from all the sufferings of cyclic existence and the bliss of full enlightenment is fantastic!
Feel the joy of it! This is their depression, so the most wonderful thing would be to experience it for them and allow all those suffering from depression to have every happiness. Then rejoice that you have this opportunity to experience this problem of depression on their behalf. "How fantastic it is that I'm experiencing this depression on behalf of all beings!"
Do this practice of tonglen (taking and giving) in the morning, afternoon and evening.
Think again and again, 'How lucky I am that I can experience this depression for them. I've made many prayers to take others' suffering onto myself, so now those prayers are being actualized. How fantastic this is! It makes my life so rich, so meaningful! How fortunate I am to experience this depression on behalf of all living beings."
Think about the meaning of your life, a psychological method that makes a huge difference because much of the problem comes from your exaggerated concept of pain. It's possible to reduce or completely eliminate pain with the mind. "The purpose of my life isn't just to be healthy, wealthy, to have a good reputation, to be popular and have lots of friends. Even if I had all these things, it isn't the actual purpose of my life. Even if I live for 1,000 years or am perfectly healthy for eons, if I don't have love and compassion in my heart my life is meaningless and useless because my life isn't benefiting others. Leading such a life would be empty. Therefore it doesn't matter what happens; if in my life there's health or no health; depression or no depression; cancer or no cancer, wealth or no wealth. The real purpose of my life is to make my death beneficial for others. Even if I have cancer, I'll make that experience beneficial for all beings by using it to develop compassion and bodhicitta, to achieve realizations and enlightenment." In this way the cancer becomes the cause of happiness. Depression can also be used to achieve enlightenment to benefit all beings in this and future lives, especially all those who suffer from depression—just like using snake venom to produce it's own anti-venom.
You're using your depression to achieve enlightenment. In this way it becomes the cause of happiness for all sentient beings experiencing depression. Think, "The main purpose of life is to benefit all living beings, to free them from suffering and bring them happiness in this and future lives. Even if I have cancer, aids, depression or whatever, the purpose of my life is to bring happiness to all sentient beings by experiencing these problems on their behalf. " In this way depression becomes a quick way to achieve enlightenment. The same with cancer. Use it to quickly achieve enlightenment. If it's experienced for the benefit of others it becomes the quick path to enlightenment because experiencing suffering for others is incredible, unbelievable purification. This is excellent!
There was one monk in Thailand who was walking around the country. He came across a big river. On the banks of the river was a woman with leprosy, with pus oozing out of her sores. She begged the monk to carry her across the river. He refused, on the basis that his monk's vows prevented him from touching women. After some time one of the monk's disciples came along and when he saw the poor woman, unbelievable compassion arose in his mind. Without hesitation he picked her up and carried her across the river, even though her body was covered with open wounds. When he reached the middle of the river the woman transformed into Vajrayogini and took him—not just his consciousness, but also his body, to Vajrayogini's pure land. This means that by now this monk has attained full enlightenment, because anyone who goes to Vajrayogini's pure land is enlightened there. Being in a pure land is a quick way to achieve enlightenment if it hasn't yet happened in your present life. In this case Vajrayogini took the aspect of an ordinary, pitiful woman with leprosy in order to stimulate compassion in the disciple's mind. This compassion quickly purified the heavy negative karma blocking him from seeing Vajrayogini.
In the case of the great Tibetan yogi, Milarepa, the karmic blocks preventing him to see Vajrayogini were purified by his pure service to his holy guru, Marpa.
It's the same for you. If on the basis of feeling strong compassion you experience depression on behalf of all beings, this meditation of taking and experiencing the suffering for others is a quick path to enlightenment, just like the example of the monk. It's a quick way to achieve enlightenment because experiencing cancer, depression or any suffering for the benefit of living beings is unbelievably purifying.
Suffering from depression can be a good thing because it allows you to easily see the pain of other people. By using your own experience of depression you can clearly feel the unbearable pain of many, many other people. There are so many people who are depressed and many others creating karma for future bouts of depression. Experiencing depression on their behalf might be even more powerful than practising tantra because if tantra isn't done correctly, on the basis of the three principal paths, it's not a quick path to enlightenment.
When feeling depressed you can think, "I'm exhausting so much of my negative karma to have depression that I've accumulated throughout countless past lives." Rejoice! You should feel great joy about finishing the karma instead of seeing the depression as something bad.
As it's said in Guru Puja, living beings and their environments are filled with unbelievable problems and sufferings, coming one after another like rainfall, sufferings that are the results of negative karma. "Please grant me blessings to see my depression as exhausting the results of my negative karmic imprints, and bless me to be able to always transform bad conditions into the path to enlightenment." You can recite mantra while doing this meditation.
For example when you wash a dirty piece of cloth, the water becomes black with dirt. You don't see the black dirt as a negative thing since it means the cloth is getting clean. In the same way, when you practice Dharma negative karmas can ripen causing you to get sick because you're purifying so much negative karma by practicing Dharma. So you should rejoice when you get depressed!
Depression happens in the first place due to being under the control of the ego, self-cherishing, attachment, anger, broken vows and pledges and having disturbed the minds of holy beings and your spiritual teachers in past lives. This depression is caused by the ego, the self-cherishing attitude and the self-existent "I". So rather than accepting the depression, give it back to the self-cherishing attitude. Use the depression like a bomb to destroy the wrong conception of the I. Then meditate on the emptiness of the self-existent I.
These are some ways to use depression to achieve enlightenment as quickly as possible. By using it to develop compassion and bodhicitta you collect merit as vast as limitless space and purify unbelievable amounts of negative karma. It's being used like a powerful bomb to destroy the wrong conception of the inherently existent I, the thing that caused the depression in the first place. It's the demon that has prevented your enlightenment, your liberation from samsara, all the realizations, and is the door to all your problems.
You can also do some preliminary practices such as Vajrasattva to purify the negative karma that causes depression.