output pushnew $upgradeLogDir/upgrade61To2x.out only
!=========================================================================
! Copyright (C) VMware, Inc. 1986-2011.  All Rights Reserved.
!
! Name - upgrade61To20
!
! Purpose: 
!
!	Convert the image from a GemStone 6.1 database to a
!       GemStone64 2.0 database.
!
! $Id: upgrade61To20.topaz,v 1.11 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
expectvalue true
run
| imageRelease conversionStatus tmpFile |
imageRelease := ImageVersion at: #gsRelease.
tmpFile := GsFile openWrite: '$upgradeLogDir/oldVer.txt'.
tmpFile nextPutAll: imageRelease; close.
^true
%
  

! comment out following for debugging
iferror exit

display oops
iferr 1 stk
iferr 2 stack
! Put the repository in conversion mode.
run
  ConversionStatus at: 1 put: true.
  ConversionStatus at: 2 put: ('61To20 step0').
  ^true
%

expectvalue true
send System _commitPrintingDiagnostics

logout
login

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

!========================================================================
!   Dereference all old index structures
!========================================================================
expectvalue true
run
SharedDependencyLists initialize.
System _commitPrintingDiagnostics.
%

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


expectvalue %String
run
| curHist tmpFile oldVer verString |

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

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