For anyone who reads the news, the term “hostile environment” has become ubiquitous in recent days.

The scandal of the Home Office’s treatment of the Windrush generation of migrants has seen both Theresa May’s tenure at the Home Office and her policy of open hostility to those who would seek a new life in our country thrust into the spotlight.

Back in December 2016, I read the term hostile environment in a government document for the first time. I’d read about it in the news, I knew the policy existed, but there was something quite chilling about seeing it on Home Office-headed paper and in the context of education.

The document in question was a memorandum of understanding between the Home Office and Department for Education governing information sharing between the two departments.

The memo described the need to “create a hostile environment for those who seek to benefit from the abuse of immigration control”, and set out how the DfE shares information from the National Pupil Database with the Home Office.

This document arrived on my desk after a three-month freedom of information battle with the Department for Education, which refused time and time again to hand over details of its data-sharing practices.

Our investigation was prompted by unanswered questions about the government’s move to have schools collect data on school pupils’ nationality and country of birth, a policy which has just been unceremoniously scrapped.

Schools are expected to get letters from the DfE this week, setting out the department’s plans to remove the controversial questions about nationality and birthplace from the school census. The sorry mess is finally over, less than two years after it began. But at what cost?

Since the extra categories were introduced in 2016, the school census has been carried out five times. That’s five times children and parents will have been asked humiliating questions about where they come from.

It’s no surprise that many schools and parents refused to play ball. Data published in December shows schools failed to obtain nationality data for a quarter of pupils last year. Information for 22.5 per cent of pupils – around 1.8 million children – was “not obtained” – meaning it had not been collected by schools when the census took place.

In a further 2.1 per cent of cases, parents or pupils pointedly refused to provide the data.

The success of the census boycott, orchestrated by human rights and digital privacy groups, is no doubt one of the main reasons the government has now scrapped the collection. Threats of legal action will also have played their part.

However, another important factor is that, even if the data had been collected on a wider scale, it would still not have served its original purpose: immigration control.

In December 2016, having denied for months that pupil nationality and country of birth data had ever been bound for the Home Office, the DfE was forced to admit that it did have an agreement to share the information.

The agreement was amended, it emerged, in early October 2016, around the same time as the autumn census in schools and following a series of damning articles in the press, to prevent nationality and birthplace data from being shared with the Home Office.

This was the second time the government had been forced to water down the policy. The collection itself was a compromise won by the DfE to curb stricter proposals from Theresa May’s Home Office, which wanted teachers to carry out immigration checks and schools to “deprioritise” places for the children of illegal immigrants.

The government could have ended the collection back in 2016, before a single school had been forced to ask the question, but it didn’t. It decided to press on for almost two years with a policy that enraged parents and saw schools directly disobey orders from the government to collect data on their pupils.

The impact on the trust between parents, schools and the government when it comes to pupil data collection has been severe, and will take some rebuilding.

And the worst thing about all this? It never needed to happen in the first place.

The collection’s cancellation is tantamount to an admission by the DfE that a policy which saw pupils targeted purely based on the colour of their skin, which saw children face demands to show their passports at school and which aimed to extend May’s toxic hostile environment to our schools, was unnecessary all along.

Otherwise, why would they scrap it now?

Parents and teachers won’t soon forget that Theresa May tried to create a hostile environment in our schools, and the Department for Education tried to cover it up.

In this case, their efforts failed because of the sheer weight of public opinion and the power of protest. But as long as the hostile environment policy exists, it’s only a matter of time before schools are in the government’s sights again.

We can only hope that the next time ministers try to use schools as immigration centres, their efforts are met with the same resistance.

This is a huge victory for every school that took part in the boycott, and for the tireless campaigners at Schools Against Borders for Children, Defend Digital Me and Liberty, who never once stopped fighting for what was right.

Whatever the immigration policy of the government of the day, schools must never become a hostile environment for anyone.