Notes for upgrading from Dosis 1.x database to Dosis2.x database






-- prepare system 

##############################
#load d1_upgrade
cd /opt/dosis2/database/d1_upgrade
sudo ./db_setup_d1.sql

#############################
#load dosis 1.8.x database

mkdir -p /opt/dosis/1.8/dxxx
copy backup to /opt/dosis/1.8/dxxx

gunzip dbBackup.tar.gz

#dbname = dosis_dxxx
createdb -U dsuper -O dsuper dosis_dxxx
pg_restore -U dsuper -F t -v -d dosis_dxxx dbBackup.tar

DO for each dafe


#############################
#create dafe enteries 

psql -U dsuper -d dosis2 -c "SELECT equipment.add_dafe_l60 (xxx)"


list dafe id and serial numbers
psql -U dsuper -d dosis2 -c "SELECT id, dafe_sn FROM equipment.dafe"




#############################
#run the upgrade process 
#For each dafe
sudo ./step_1_composite_load.bash -i yy -d dosis_dxxx

where yy is teh dafe id from the queery above 


#Run just once
sudo ./step_2_instance.bash
sudo ./step_3_canister.bash
sudo ./step_4_workorder.bash


# clean up and reset seq
cd ../   or /opt/dosis2/database/

psql -U dsuper -d dosis2 -f db_sequence_reset.sql
psql -U dsuper -d dosis2 -c "DROP SCHEMA d1 CASCADE"

/usr/pgsql-9.2/bin/vacuumdb -e -z -v -f -U dsuper -d dosis2
/usr/pgsql-9.2/bin/reindexdb -U dsuper -e -d dosis2


#############################
# backup the database
cd /opt/dosis2/1.8/
/usr/pgsql-9.2/bin/pg_dump -F t -U dsuper -f DXXXX_INIT_2_dbbackup.tar dosis2



