When work has to be done on the railways nowadays it seems to take forever and cause massive problems.

Witness the chaos on the West Coast line over the New Year because Network Rail's maintenance project overran. The Victorians did things rather differently, as the Apperley Viaduct experience of 1866 showed.

Take a train from Bradford to Leeds via Shipley (a much pleasanter route than the alternative via New Pudsey) and you will emerge from the 1,500-yard-long Thackley Tunnel into the leafy open countryside around Apperley Bridge and travel across the river on a viaduct.

Rail passengers have been enjoying that experience since 1846, when the Leeds and Bradford Railway Company officially opened its 13-mile link between the two cities. However, just 20 years after that opening - in mid-November, 1866 - the Aire Valley experienced the sort of torrential rainfall which in 2007 would have prompted speculation about the effects of global warming.

The railway viaduct was washed away. Historian John C Jackson researched the incident in 1982. What follows is based on the feature he wrote at the time for the Bradford and Calderdale Chamber of Commerce Journal.

As the rain poured down, "rivers and streams in the locality very quickly became swollen and, being quite unable to cope with the unprecedented volume of water, soon overflowed their confines. On Friday, November 16, the scene between Apperley Bridge and Esholt was that of one long lake moving in a torrent above which only the crowns of tall trees were visible. Between those two localities, striding majestically some 156 yards across the open landscape, stood the ten-arch Apperley Viaduct.

"The central arch rested on a lofty embankment rising from an island in the river, the bed of which passed through the second and third arches. The bridge each day carried almost 200 trains, many of which were heavily laden with all manner of goods.

"By the late afternoon the path of the river had become completely indiscernible and the broiling maelstrom' swept with unparalleled force against the buttresses of the viaduct. This alone would not have given rise to any concern, but the bed on which the buttresses had been placed was of a soft and light nature, and consequently the force of the water enabled it to percolate into the foundations and undermine them. No great danger was anticipated, however, and the trains continued to run as usual.

"At about five o'clock the guard on a passenger train from Bradford felt that the viaduct was insecure, and he at once alerted the stationmaster at Apperley Bridge. The danger signal was immediately put on and the stationmaster boldly ran across the viaduct to warn the driver of an approaching luggage train.

"Unfortunately his heroic action was in vain for at that very moment the doomed train emerged from the Thackley Tunnel at such speed that it could not be brought to a standstill until it was on the third arch of the viaduct."

The train wasn't a long one, just an engine, tender, two wagons and a guard's van. However, its weight was enough to cause the section of the bridge on which it came to a halt to sink about 18 inches. It could go neither forward nor back, so the driver and guard abandoned it and headed for safety.

The train stood where it was for about a quarter of an hour. Then, according to an eye witness, "we heard a crack as if something was breaking, and looking, we saw the red lights of the guard's van disappear and then the whole mass of stonework fell into the water below with a deafening crash."

John C Jackson's account continues: "The progress of the raging torrent beneath was temporarily halted as the great pile of masonry lay like a huge dam athwart the river. Such was the force of the current, however, that within minutes it had wrenched free of the debris the remains of the wagons and guard's van, leaving the engine and severely damaged tender firmly embedded in the ruins of the viaduct."

The following day the weather had improved. Did the Midland Railway Company close the line for weeks and weeks? They did not! This was Victorian times, not the wussy present.

Trains ran from Bradford to the remains of the viaduct where passengers alighted and crossed the river on a hastily-erected footbridge (which was lit up at night) and boarded another train to continue on to Leeds.

A gang of up to 400 men was set on and a replacement viaduct was built within seven weeks. The stone piers were reconstructed and the iron-girder bridge (which had been destined for India, but was diverted) was fixed within a month. Normal service was resumed on the line on January 3, 1867.

John C Jackson reports that the same line was again affected by extreme weather just over five years later, on June 18, 1872.

During a violent thunderstorm Thackley Tunnel was flooded to a depth of almost two feet all along its length. Then the parapet at the Apperley end was struck by a bolt of lightning and a massive section of stonework crashed down, blocking the entrance to the tunnel.

Mr Jackson continues: "Happily, on this occasion no great catastrophe ensued and a gang of 100 workmen, quickly drafted in from Leeds, was able to ensure the resumption of the train service before midnight of the same day."

The postscript to this story is that, because of a big increase in demand on that route, a second line was laid alongside the first, completed in 1900 and necessitating the blasting of a second tunnel and construction of another viaduct.

The older line was discontinued in 1972 and its viaduct decommissioned. But it remains standing, a lasting tribute to the initiative and industry of those Victorians who built it at such speed yet so solidly.