For Indian techies, 2017 was the stuff of nightmares.

One of the top employment generators until a few years ago, India’s $160 billion IT industry laid off more than 56,000 employees this year. Some analysts believe this spree was worse than the one during the 2008 financial crisis. Meanwhile, hiring plummeted, with entry-level openings having more than halved in 2017, according to experts.

Tata Consultancy Services and Infosys, two of India’s largest IT companies and once leaders in job creation, reduced their headcounts for the first time ever. Even mid-sized players like Tech Mahindra retrenched several employees.

“Digitisation and automation brought about disruption in traditional roles, which means that most of the IT firms found themselves reassessing the capability of the talent pool to stay market relevant,” Arun Paul, vice-president of human resources at Incedo, an IT service management company, told Quartz.

When hell broke loose

Compared to the normal rate of forced attrition (that is, asking non-performers to leave) of around 1% in earlier years, 2017 saw Indian IT companies letting go of between 2% and 6% of their employees, said Alka Dhingra, general manager of IT staffing at TeamLease Services.

Infosys cut 9,000 jobs in January. “Instead of 10 people, what if we have three people to work on [a project]. If we don’t have the software, then some others will take the advantage [away from us],” Vishal Sikka, the former CEO of the Bengaluru-headquartered company, said in February.

Meanwhile, around 6,000 Indian employees at Cognizant reportedly lost their jobs to automation. Mumbai-headquartered Tech Mahindra implemented a cost optimisation plan of increasing automation and reducing manpower. It turned ugly in July when the firm made headlines over a controversial audio clip that featured an HR personnel purportedly coercing an employee into quitting by 10 am the next day, or risk being fired.

Moreover, it wasn’t just about those at the bottom of the IT pyramid. Pink slips were doled out to even senior employees with outdated skills.

“There is a change in the trend where automation has taken the driver’s seat to propel cost efficiency and utilisation of human resources for less mundane and routine work,” N Shivakumar, business head of recruitment process outsourcing at TeamLease, said.

Slamming the brakes on hiring

On the hiring front, too, bad news abounded. In 2017, campus hiring by IT companies fell by a massive 50%-70%, Santanu Paul, CEO and managing director at skills training firm TalentSprint, told Quartz.

This was mainly because companies changed their hiring practice: while earlier they’d hire freshers in bulk in anticipation of future contracts, the strategy has now shifted to just-in-time contract hiring.

With revenue growth under stress, companies did not want to hold a bench – an employee pool on a company’s payroll, awaiting projects. “The focus shifted to increase in hiring of specialised talent or up-skilling existing [talent],” Incedo’s Paul said.

For several years now, Indian IT firms have anyway been moving away from labour-intensive projects towards more remote and technology-based solutions such as video conferencing, cloud computing, and artificial intelligence. This has resulted in hundreds of entry-level roles like data entry and server maintenance becoming obsolete.

“The IT job market is not as lucrative as it used to be and the dream run is over for the next few years,” DD Mishra, a research director at Gartner, said. “With IT service providers feeling the heat, the job market will remain under pressure for some more time.”

In the long run, automation may increase the number of jobs available for workers with niche skill sets. But lower-level workers will continue to suffer. Nearly one-third (700,000) of the low-skilled workers in India’s IT sector stand to lose their jobs by 2022, a recent report by market analysis firm HfS Research says. Less than 5% of Indian techies are equipped to handle high-skilled jobs.

This dearth of trained talent is especially worrying as, within the next few years, roughly 40% of the less sophisticated tech jobs will be replaced by high-paying ones like data scientist and data analyst, estimates Kris Lakshmikanth, founder of recruitment firm Head Hunters India.

In the meantime, the layoffs and lack of bankable employment prospects wreaked mental and emotional havoc on employees as they battled a cash-crunch, anxiety, depression, low self-esteem, and lack of motivation. “Most IT sector employees are migrants, with little social support in their adoptive cities,” Dr BN Gangadhar of the National Institute of Mental Health and Neuro Sciences, Bengaluru, told Time magazine. “Being young, they’re often single and lonely. If married, they have little time for their families. And when things go wrong, whether at work or at home, they have no one to turn to for help.”

Side effects of “America First”

Donald Trump’s arrival at the White House earlier this year hasn’t helped.

Since Trump took office, the fate of the H-1B, a six-year temporary work visa that Indian IT companies heavily depend on, has been hanging fire.

In March 2017, the US government stalled the premium processing of this visa category.

The criteria for computer programmers to apply for the H-1B visa became tougher. In April, Trump signed the “Buy American, Hire American” executive order, promising to bring jobs back to the country, putting migrant workers in jeopardy. In November, the judicial committee of the US House of Representatives gave its nod to the Protect and Grow American Jobs Act (titled HR 170) which classifies any company that has more 15% of its workforce working on-site as “visa-dependent.” With this, the pressure is mounting on Indian outsourcing giants which sometimes have over 50% of their manpower working on-site.

Even the current workers have cause for concern – to clamp down on visa fraud, the United States Customs and Immigration Services plans to double the number of visits to workplaces. “Indian IT companies, thus far champions of IT-based outsourcing, have been forced to go back to the drawing board in order to reposition themselves higher up in the value chain,” Anshul Prakash, a partner at Mumbai legal services firm Khaitan & Co, told Quartz.

In the trenches

IT companies have tried to make fixes as doors shut on Indian techies. “...there were concerted efforts on the part of larger IT companies to hire locally, and set up near-shore delivery centres,” said Sandeep Sharma, associate research manager of software and IT services at International Data Corporation India. Other have spent on acquisitions. These efforts may help stay afloat but job opportunities for Indians are still shrinking.

The trepidation is unlikely to end anytime soon. By next year, automation will put nearly 70% of the roles in the Indian IT workforce at risk, according to analysts.

“After years of job creation in developing economies, the shoe is now on the other foot. Developed economies will be creating jobs for their own citizens in the foreseeable future,” TalentSprint’s Paul said. “India, on the other hand, will see high-value jobs being created, but not in high volume.”

In the choice between skill versus scale, companies will continue to lean on the former.

“Much of the creative destruction will continue for a while and disruptions are inevitable over the next two to three years,” Mishra of Gartner said. “A positive shift will be visible from 2020 onwards and we expect to see new opportunities getting created out of the current disruptions.”

This article first appeared on Quartz.