I've experienced gaslighting. Many of us in IT have experienced hostile work environments. There are many options for dealing with it. By far the easiest, fastest way is to simply leave. You're not leaving just for your own mental well being. Another reason to leave is to take their power away, gives them less room to maneuver when abusing your former colleagues.
Unfortunately, many employees don't position themselves to be able to do that without prohibitive loss. And employers encourage that! Ever have your boss suggest you should buy a new car and house? I have, more than once. I didn't understand why that was any of their business the 1st time. Now I know that's why. They think of you as a "flight risk", and like the idea of you feeling chained to your job by debt up to your eyeballs. Lose that job and your life blows up. You lose your house, spouse, car, the respect of your friends, your credit rating, etc. They have code phrases for this, stuff like "showing team spirit" and "commitment". There are sick managers out there who enjoy bullying and abusing hapless underlings.
If you are determined to hang on for financial reasons, pride in your successes, don't want to leave under a cloud of failure, don't want to be labeled a quitter and a wimp, feel like there are still worthy people you can help, or the environment isn't completely horrible and has its redeeming qualities, and whatever other reasons, there's still much else you can do. There will always be some crap to handle at any job, and it is impractical to walk out on every employer unless you're independently wealthy and can retire at the age of 30 or some such. Still improve your financial situation. Next, keeping records is huge. Get all the gaslighters' crap down in writing. Ask them to email or text you, not just give you verbal instructions which can be denied later. Do it smoothly too, don't be verbally demanding, just be firm and put your time to use on other duties until they give you written instruction. What may very well happen is that they get cold feet. They don't want a paper trail showing what scumbags they really are. They'll foam at the mouth with rage and frustration, but they will back down if they have any brains. They may not, they may indeed give it to you in writing. They may try to weasel around with their written instructions. If they threaten to fire you, call them on that. Tell them you're waiting, hurry up and fire you already. It usually is a bluff, but it may not be, and if so, that's okay too. Being fired is not the end of the world.
A big problem is assessing management demands. It can sometimes be very hard to tell if they really are asking for too much. Asking for perpetual motion is too much. Asking for the moon might not be. Likely they have no idea either. It's their job to work that out, not come up with a schedule out of thin air but get input from their experts and work it out. But sometimes managers are lazy on that and try to compensate by bullying their underlings. Ask you for a schedule, then behind your back alter it to cut the time way down, and throw in a few simple little extras that aren't so simple or little. In any case, it's not good to declare some demand is impossible and unreasonable and walk out, if it wasn't.
So there it is. Free yourself from your own desperation. Whichever way things work out, years later you'd like to be proud of the decisions you made and the manner you handled yourself. No job is worth breaking laws you respect and treacherously throwing colleagues under the bus. There are bigger things in life than that. No job is worth your self respect. Being unemployed is hard, but it is not The End.