I've been working for my company a little over 5 years as a .NET / SQL developer. When I was first hired on, the rest of my department quit within the first three weeks.
During this time, I controlled the entire company's web application and was able to memorize the entire structure in about six months.
After about six months, the owner brought in her neighbor to run the IT Department. He's been the head of our department since then. We've never had a great rapport since we have personal conflicts, even though we went to the same school and got the same degree. Note that his degree is about twenty years older than mine. Even with this in mind, my manager has always given me good reviews and has said that I've had a solid mid-level understanding of my environments and languages.
Recently, I was relocated by our company to a regional office off-site from the IT department. This was allowed by the owner so that I could pursue my Microsoft Certifications. My manager made it very clear that he did not want me to move and that he was "jealous" that I was being relocated. Since I've relocated, he regularly calls me to yell at me about things I've been doing for the entire time I've worked at the company.
Additionally, he'll go on to discipline me for small time bugs through thousands of line of code. I created a menu that is about 7,000 lines of code. I forgot to fully name in a document section (ex. "Step 11a" instead of "Step 11a. TEST PHASE") of the code and so I was disciplined.
When I asked our HR director what to do with all of the added stress, she insisted that we go through a group call. On the call, my manager removed me from my coding responsibilities stating that my coding quality is "poor" and that it has gotten consistently worse over the years.
He then used examples where he had changed my code so that it would not function while on production (when I moved, he started implementing my work without telling me). When I told the HR director that these were his actions that broke the code, she couldn't really understand what had happened. His final statement was that I should likely look at a different career path. I'm really scared that I'll lose my job regarding his final statement.
Ever since this call occurred, I have no desire to work, no desire to code. I see my workload dwindling and he now takes credit for any scripts I give him. I have many personal projects that seem flavorless to me. Should I continue to program? What can I do to regain my confidence back? Are all IT departments out there like this?