The Deputy First Minister John Swinney did the honours at a topping out ceremony on Wednesday on the site of the new primary school and community facilities in Danderhall.
Mr Swinney MSP (SNP) marked the occasion of the roof being completed at the £16.8 million facility, due to open this autumn, by signing one of the steel girders.
He said: “This new school will give local children and young people a modern learning environment that they and their families can be proud of.
“The leisure facilities, library and café will also make it a hub for people in the surrounding area, in line with our vision for schools being the centre of their communities.
“My thanks to Midlothian Council for their ongoing commitment to improving school buildings and congratulations to them and the construction staff on reaching this terrific milestone.”
Main contractor Heron Bros is delivering the state-of-the-art building, which will be able to accommodate 640 pupils and 120 children in its three nursery spaces.
As well as a new primary school and early learning centre, the new build, on the site of the existing primary school, will have a library, leisure centre, cafe and sports pitches.
The multi-million investment is in addition to more than £150 million spent in the last ten years on building new or upgrading existing schools across Midlothian.
The £16.8m Danderhall project is partly funded by £6.2m of developer contributions, £1.1m of Scottish Government Early Years grant funding; and with the remainder being funded by the council.
Midlothian Council’s Cabinet Member for Education, Councillor Jim Muirhead (Lab) said: “I’m delighted to be here today to welcome Mr Swinney and mark this important milestone in this fantastic project.
“The new building at Danderhall will be a much-needed addition to our schools and community estate. We are all really looking forward to the opening in August and the building becoming a busy and well-used focal point for local people.”
The redevelopment of the site comes after extensive consultation with local people about preferences for the school and the building’s community facilities.
Pupils Hazel and Max (pictured), who also got to sign the girder, said they were excited to think their signatures would be on the building for as long as it was up, even though they will be in high school when it opens.