This week, military bases in Texas are pitching tents and preparing facilities to house thousands of Mexican and Central American migrants. They have done this before. In fact, the military has housed refugee populations multiple times over the past 60 years.

What is different is why these bases are gearing up to host another round of migrants.

During the Cold War, military bases sheltered Hungarians, Vietnamese and Cubans. The government viewed these refugees as assets to the United States, who should be shuttled into American communities as quickly as possible. Today, however, rather than waystations to resettlement, the bases will be used to detain and deter migrants. And while bases may well be preferable to private jails and family separation, holding migrants and families on U.S. bases will probably lead to increased trauma, separation from work, education and community and legal challenges for years to come.

During the Cold War, the U.S. military saw anti-communist refugees as valuable symbols in the ideological war with the Soviet Union. In 1956, the Soviets used military force to crush Hungarian resistance. President Dwight D. Eisenhower chose not to challenge the U.S.S.R. directly in Eastern Europe. Instead, he signed an exception to America’s restrictive immigration quotas and welcomed over 35,000 Hungarians. He framed the Hungarians as anti-communists who sought freedom in America.

The U.S. military played a prominent role in welcoming Hungarian refugees. On arrival, the federal government directed the vast majority to Camp Kilmer in New Jersey. It was the first time the military directed a major refugee camp within the United States.

According to contemporary reports, the Army was “trying to put its best foot forward” at this “bleak” camp. Reporters described the barbed wire, cinder block bunks and mandatory mug shots, but concluded there were few complaints from the Hungarians. The Army maintained the camp and nonprofit agencies, such as the Red Cross, helped match families with sponsors. The Hungarians remained in Camp Kilmer for less than six months, and in 1958, they were able to become permanent residents.

The U.S. government turned to military bases again in 1975 as South Vietnam collapsed and more than 100,000 Vietnamese fled the country. The U.S. military switched gears from fighting hostile Vietnamese forces to providing beds, meals and child care to its former South Vietnamese allies on bases in Guam, Arkansas, California, Pennsylvania and Florida.

This was not because the American public embraced the Vietnamese. In fact, quite the opposite. At least 49 percent of Americans opposed accepting the Vietnamese, and Gov. Jerry Brown (D) objected to California hosting them.

President Gerald Ford resisted such anti-Vietnamese sentiment. Like Eisenhower and the Hungarians, Ford believed America had a moral responsibility to help the Vietnamese, as allies fleeing communism. He offered them entry and a path to permanent residency.

The military’s prominent role did concern some in the armed forces. After all, they possessed neither the training nor the skills to provide the emotional and support services refugees needed. But government officials saw the military’s logistical capacity and secure perimeter as essential to the process.

The refugee operation also provided the opportunity for good press. The U.S. military was in desperate need of a public relations “win,” given the brutal and failed war in Vietnam. In this way, caring for Vietnamese at Fort Chaffee, Ark., or Camp Pendleton, Calif., worked to displace the violence of war with a humanitarian operation as the dominant image of the military. With the completion of the mission, Gen. John W. Vessey supported the creation of the Humanitarian Service Medal. He believed rewarding military personnel for humanitarian operations would be “a precedent worth setting.”

Once again, the government treated the Vietnamese as American citizens in the making. Most Vietnamese spent only a brief time on military bases, typically about a month. There were English classes, and nonprofit agencies offered basic assistance and help finding a sponsor. In just under eight months, every Vietnamese had been resettled in communities across the United States.

This reliance on the military to house refugees became problematic when migrants stopped being seen as Cold War assets. In 1980, Fidel Castro allowed thousands of Cubans to leave en masse, demonizing these men and women as scum, criminals and homosexuals in ways that prejudiced Americans against these nonwhite, working-class Cubans.

This time, when bases in Florida, Arkansas, Wisconsin and Pennsylvania were converted yet again into refugee camps, local communities resisted. In this hostile environment, many Cubans resented being restricted to the military bases and protested their confinement. Because many Cubans were single men or from more stigmatized populations, the waiting period for resettlement was longer, and the use of military bases became more fraught and akin to detention facilities.

This trend intensified during the 1990s, when over 30,000 Haitians and 30,000 Cubans sought refuge in the United States. In an effort to deter, rather than process, migrants, Presidents George H.W. Bush and Bill Clinton repurposed the U.S. naval base in Guantanamo Bay to avoid political tensions at home.

The U.S. military rapidly built tent cities and mobilized resources to feed and house tens of thousands of people at Guantanamo Bay. Haitians and Cubans were held behind barbed wire and had few legal avenues or rights. Many of these migrants experienced the base as a jail.

Legal activists took cases to court, and the Cuban and Haitian American communities lobbied for their compatriots. In the end, the crisis ultimately played out along familiar Cold War lines. The United States accepted the Cubans because they had left Castro and communism, while the vast majority of Haitians had their asylum claims rejected.

President Trump has turned to military bases as a “solution” to the crisis he created on the nation’s border. With a policy of detention rather than resettlement, Trump’s program builds on the shameful precedent set at Guantanamo during the 1990s. His recent tweets rejecting migrants’ rights to due process make this comparison even more acute.

The president’s goal is deterrence through cruelty, and he is willing to use the U.S. military to accomplish it. This is a far cry from the U.S. military leaders’ hopes their work in refugee resettlement would identify the military with humanitarian operations.

The result could be more Guantanamos — indefinite, militarized detention centers — in America.