One city was made wealthy by Americans' love of the car and dragged into ruin by that industry's collapse. Another got rich by being a hub for companies that provide fuel for those cars, and its economy is still booming. Yet Dallas could be the next major American city to follow Detroit into the throes of bankruptcy.

Dallas Mayor Michael S. Rawlings said in November that he believes the city is "walking into the fan blades," in large part because of unsustainable pension promises made to the city's police officers and firefighters. The fund that is supposed to pay for retired cops and firemen is more than $5 billion in the red. Credit rating agency Moody's believes the fund will be out of money within 20 years, and recent retirees have taken notice: Many have started pulling their money out of the system by the millions (an ill-advised provision in the plan allows this), which is hastening the coming default.

Municipal bankruptcies, though rare, are bound to happen from time to time. But they are not supposed to happen in places like Dallas, where the population and the economy are both growing. If poorly designed pension plans are capable of wrecking an otherwise thriving city, it's time to revise our view of what places are exposed to these risks.

It's well understood that in Detroit, which filed for Chapter 9 bankruptcy in July 2013 and became the largest American city to ever do so, the problems were systemic. The city's public sector failed to shrink as the population of what was once America's fourth largest city dwindled away. Because pension costs are always deferred—you're promising to pay employees later for work they're doing now—they tend to lag behind demographic changes. A sharp decline in the number of taxpayers means promises made years ago must be borne by a smaller group of people. Unless the pensions are properly funded for decades in advance, that's going to cause serious problems.

In some ways, the Detroit bankruptcy was a unique event. With the collapse of the domestic auto industry, the city's population eroded at a rate that's practically without equal outside places that were bombed or beset by a natural disaster.

The underlying story in Dallas couldn't be more different. Over the same 60 years that saw Detroit's population diminish by more than a million people, the Texas city's population almost tripled, going from 434,000 in 1950 to nearly 1.2 million at the last census. With more people than ever paying into the system, Dallas should be sitting pretty.

Yet here we are. The city contributed just $115 million to the public safety pension fund in 2015, while paying out $283 million in benefits. And that's nothing new—the government has been shortchanging the fund for years.

The other killer for Dallas is a special loophole that lets people withdraw the money they've contributed when they retire. One officer took out more than $1 million in September. All together, panicked retirees pulled more than $230 million out of the fund in just six weeks in 2016. It's been widely described as a "run on the bank."

The fund asked for a one-time bailout of $1.1 billion—equal to the entire city budget for a year—to staunch the bleeding. When that didn't come through, officials asked retirees to vote on whether they'd be willing to accept reduced benefits, a solution that seems equally unlikely to pan out.

As in Detroit, elements of Dallas' problems are unique. But other cities can, and have, made similar mistakes. Houston, another place where the recession supposedly never happened, has the fourth-worst pension debt of any municipality in the country, according to a Moody's report published in November. That should be impossible: Houston has been growing by leaps and bounds in recent decades. But not even a rising population and a booming economy have made up for poor planning and bad financial decisions.

Officials around the country should watch closely and learn well from these mistakes: The mismanagement of public retirement programs can wreck a city, even in places that aren't already suffering from larger budgetary issues that go beyond their pension funds.