#!/bin/bash # ----------------------------------------------------------------------------- # # Runs sql scripts to update database from previous release. # # ----------------------------------------------------------------------------- # DB=$1 USER=$2 DB_HOST=$3 INSTITUTION=$4 echo Using host=$DB_HOST echo Using database: $DB echo Using user $USER: echo Institution: $INSTITUTION function execute() { if [ -z $3 ] then echo ---------------------------------------- $1 mysql -u$USER -f -h$DB_HOST --default-character-set=latin1 $DB < $2 echo else if [ "$INSTITUTION" == "$3" ] then echo ---------------------------------------- $1 specific for $3 mysql -u$USER -f -h$DB_HOST --default-character-set=latin1 $DB < $2 echo fi fi } function executeWithTempFile() { echo ---------------------------------------- $1 mysql -u$USER -f -h$DB_HOST --default-character-set=latin1 $DB < $2 > tmp.sql mysql -u$USER -f -h$DB_HOST --default-character-set=latin1 $DB < tmp.sql rm tmp.sql echo } execute "Alter table Country" AlterTableCountry.sql execute "Alter table Candidacy" AlterTableCandidacy.sql execute "Changing Degree codes" AlterDegreeCodes.sql IST execute "Add ojb concrete class column to EnrolmentLog table" alterTableEnrolmentLog.sql execute "Update EnrolmentLog ojb concrete class data" updateEnrolmentLogInformation.sql execute "Alter Table Country" alterTableCountry2.sql