A Tameside primary school plagued by structural issues will be demolished and rebuilt.