diff --git a/perl-lib/OESS/share/nddi.sql b/perl-lib/OESS/share/nddi.sql index 4af8c1388..f6eab20c4 100755 --- a/perl-lib/OESS/share/nddi.sql +++ b/perl-lib/OESS/share/nddi.sql @@ -632,7 +632,7 @@ CREATE TABLE `oess_version` ( LOCK TABLES `oess_version` WRITE; /*!40000 ALTER TABLE `oess_version` DISABLE KEYS */; -INSERT INTO `oess_version` VALUES ('1.2.1'); +INSERT INTO `oess_version` VALUES ('1.2.2'); /*!40000 ALTER TABLE `oess_version` ENABLE KEYS */; UNLOCK TABLES; diff --git a/perl-lib/OESS/share/upgrade/oess-1.2.1-1.2.2 b/perl-lib/OESS/share/upgrade/oess-1.2.1-1.2.2 new file mode 100755 index 000000000..716e5048e --- /dev/null +++ b/perl-lib/OESS/share/upgrade/oess-1.2.1-1.2.2 @@ -0,0 +1,84 @@ +#!/usr/bin/perl +#------------------------------------------------------------------- +#----- OESS 1.0.12 - 1.1.0 upgrade module +#----- +#----- Copyright(C) 2010 The Trustees of Indiana University +#-------------------------------------------------------------------- +#----- $HeadURL: $ +#----- $Id: $ +#----- +#----- This is run when upgrading the database from +#----- version 1.2.1 to version 1.2.2 +#-------------------------------------------------------------------- + +use strict; +use warnings; +use OESS::Database; + +my $prev_version = "1.2.1"; +my $version = "1.2.2"; + +sub main{ + print "*******************************************************************\n"; + print "********* OESS DB UPGRADE ************\n"; + print "*******************************************************************\n"; + print "********* This will upgrade from $prev_version to $version **********\n"; + print "********* of the OESS DB any other version will not work ************\n"; + + continue_parameter("Do you wish to continue"); + + my $dbq = new OESS::Database(); + my $current_version = $dbq->get_oess_schema_version(); + if($current_version eq $prev_version){ + $dbq->{'dbh'}->begin_work(); + upgrade($dbq); + $dbq->{'dbh'}->commit(); + } else{ + print "Wrong version of OESS DB\n"; + print "This script only upgrades from version $prev_version to $version\n"; + exit; + } + + print STDERR "Upgrade Successful!!\n"; +} + + +sub upgrade{ + my $dbq = shift; + my $term = shift; + my $dbh = $dbq->{'dbh'}; + my $str; + my $sth; + + + # Done with the rest of the upgrade update our version + $str = "update oess_version set version = '$version'"; + $sth = $dbh->prepare($str) or die "Unable to prepare version update \n"; + $sth->execute() or die "Unable to update version\n"; +} + +main(); + +sub continue_parameter { + my $name = shift; + + print "$name [y/n]: "; + my $yes_or_no = <>; + chomp($yes_or_no); + + exit(0) if ($yes_or_no !~ /y/i || $yes_or_no =~ /n/i); +} + +sub required_parameter { + my $name = shift; + + while (1) { + print "$name (required): "; + my $response = <>; + chomp($response); + + return $response if ($response); + + print "\nThis option is required!\n\n"; + } +}