output pushnew $upgradeLogDir/upgradeTo2x.out only
!=========================================================================
! Copyright (C) VMware, Inc. 1986-2011.  All Rights Reserved.
!
! Name - upgradeTo20.topaz
!
! Purpose: 
!
!	Convert the image from a GemStone64 1.1 database to a
!       GemStone64 2.0 database.
!
!       Use upgradeImage.topaz instead of this file if upgrading from
!       one 2.x release to another.
!
! $Id: upgradeTo20.topaz,v 1.14 2008-01-09 22:50:20 stever Exp $
!
!=======================================================================

set gemstone $stoneName user SystemUser pass swordfish
!
display resultcheck
level 0
!
login
iferr 1 stk
iferr 2 stack

!  display topaz settings
status
time

!check the version of the current repository

! comment out following for debugging
iferror exit

expectvalue true
run
| imageRelease conversionStatus tmpFile |
imageRelease := ImageVersion at: #gsRelease.
(imageRelease matchPattern: #('1.1' $*)) ifFalse: [
  (imageRelease matchPattern: #('1.2' $*)) ifFalse: [
     ^ 'Release mismatch. This is an image release ' , imageRelease , ' image.'
  ].
].
tmpFile := GsFile openWrite: '$upgradeLogDir/oldVer.txt'.
tmpFile nextPutAll: imageRelease; flush.
^true
%
  
display oops
iferr 1 where
iferr 2 stack
! Put the repository in conversion mode.
run
  ConversionStatus size: 2.
  ConversionStatus at: 1 put: true.
  ConversionStatus at: 2 put: ('11To20 step0').
  ^true
%

expectvalue true
send System _commitPrintingDiagnostics

logout
login

!========================================================================
! filein methods for kernel classes
input $upgradeDir/upgrade_img.topaz


!========================================================================
!   Make a note in a log object
!========================================================================

expectvalue %String
run
| curHist tmpFile oldVer verNumStr |
curHist := (Globals at: #DbfHistory ifAbsent: ['']).
tmpFile := GsFile openRead: '$upgradeLogDir/oldVer.txt'.
oldVer := tmpFile contents.
GsFile removeClientFile: '$upgradeLogDir/oldVer.txt'.
verNumStr := System gemVersionAt:'gsRelease' .
Globals at: #DbfHistory put: curHist, 'GemStone ', oldVer, 
                             ' to Gemstone64 ', verNumStr, ' upgrade completed at ' ,
                             DateTime now asString , Character lf .
%
commit

!========================================================================
logout
output pop
exit
