Added new database fields: elder->email and appointment->location
[eq/.git] / bin / upgrade_2_0_to_3_0
diff --git a/bin/upgrade_2_0_to_3_0 b/bin/upgrade_2_0_to_3_0
new file mode 100755 (executable)
index 0000000..265699f
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/perl
+
+use DBI;
+use Getopt::Std;
+
+$mydir = `cd \$(dirname $0) 2>/dev/null; pwd`; chomp($mydir);
+unshift @INC,("$mydir/../setup");
+if( -f "$mydir/../setup/db_config.local") { require "db_config.local"; }
+else { require "db_config"; }
+
+###################################################
+# Connect to the database
+$dbh=DBI->connect("dbi:mysql:dbname=$dbname:host=$dbhost:port=$dbport",$dbuser,$dbpass,{
+    AutoCommit=>0,
+    PrintError=>0}) or print "Connect Failure:".$DBI::errstr."\n" and exit 2;
+###################################################
+
+# Add a new 'email' field to the eq_elder table
+$sth = $dbh->prepare("ALTER TABLE `eq_elder` ADD `email` VARCHAR( 120 ) NULL AFTER `phone`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+# Add a new 'location' field to the eq_appointment table
+$sth = $dbh->prepare("ALTER TABLE `eq_appointment` ADD `location` VARCHAR( 120 ) NULL AFTER `time`");
+$sth->execute or die "-E- DB error: $DBI::errstr\n";
+
+print "-> Done!\n";
+
+###################################################
+# Disconnect from the database
+$dbh->disconnect();
+###################################################
+
+