MDL-35851: Add page validation for multiple first and last page.
Modify upgrading db script