WIll filing bankruptcy ruin my credit score forever?

I've heard that bankruptcy stays on your credit report for decades. Is it possible to repair your credit if you're forced to file for bankruptcy?