904133d92afd622feaabd529268be7abff6a338d
[eq/.git] / bin / upgrade_1_1_0_to_1_1_1
1 #!/usr/bin/perl
2
3 use DBI;
4 use Getopt::Std;
5
6 $mydir = `cd \$(dirname $0) 2>/dev/null; pwd`; chomp($mydir);
7 unshift @INC,("$mydir/../setup");
8
9 if( -f "$mydir/../setup/db_config.local") { require "db_config.local"; }
10 else { require "db_config"; }
11
12 ###################################################
13 # Connect to the database
14 $dbh=DBI->connect("dbi:mysql:dbname=$dbname:host=$dbhost:port=$dbport",$dbuser,$dbpass,{
15     AutoCommit=>0,
16     PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
17 ###################################################
18
19 # Change interview_type field in tc_interview table to type, change enum to use 'H','P'
20 $sth = $dbh->prepare("ALTER TABLE `tc_interview` ADD `type` ENUM( 'H', 'P' ) NOT NULL AFTER `interview_type`");
21 $sth->execute or die "-E- DB error: $DBI::errstr\n";
22 $sth = $dbh->prepare("UPDATE tc_interview SET type='H' WHERE interview_type='hti'");
23 $sth->execute or die "-E- DB error: $DBI::errstr\n";
24 $sth = $dbh->prepare("UPDATE tc_interview SET type='P' WHERE interview_type='ppi'");
25 $sth->execute or die "-E- DB error: $DBI::errstr\n";
26 $sth = $dbh->prepare("ALTER TABLE `tc_interview` DROP `interview_type` ");
27 $sth->execute or die "-E- DB error: $DBI::errstr\n";
28
29 print "-> Done!\n";
30
31 ###################################################
32 # Disconnect from the database
33 $dbh->disconnect();
34 ###################################################