#!/usr/bin/perl

###
### Updates the GiantDisc database to the newest available version
###

use Getopt::Std;
use DBI;
use lib '/home/music/bin';
use gdupdate;



if (!getopts ('h:')){
  print <<ENDOFTEXT;
Usage: 
  gdstream.pl [options] audiofile

Options:
  -h host        database host  (default is localhost)
ENDOFTEXT
  exit 0;
}

my ($dbhost, $dbh);


if (!defined $opt_h){
  $dbhost   = `hostname -i`;	# IP address of database server
  chop($dbhost);
}

print("### close database connection to $dbhost\n");

$dbh = DBI->connect("DBI:mysql:GiantDisc:".$dbhost, "music", undef)
    or die "unable to connect to GiantDisc db";

### fix records (bug in recording routines prior to version 0.92)
#gdupdate::fix_leading_slash_bug($dbh);

### UPDATE DATABASE to new versions
#print "\nUpdate to version 0.94\n";
#gdupdate::db_update_094($dbh);
#print "\nUpdate to version 0.95\n";
#gdupdate::db_update_095($dbh);
#print "\nUpdate to version 0.96\n";
#gdupdate::db_update_096($dbh);
#print "\nUpdate to version 0.97\n";
#gdupdate::db_update_097($dbh);
print "\nUpdate to version 1.11\n";
gdupdate::db_update_111($dbh);
print "\nUpdate to version 1.12\n";
gdupdate::db_update_112($dbh);
print "\nUpdate to version 1.14\n";
gdupdate::db_update_114($dbh);
print "\nUpdate to version 1.31\n";
gdupdate::db_update_131($dbh);
print "\nUpdate to version 1.32\n";
gdupdate::db_update_132($dbh);
print "\nUpdate to version 1.33\n";
gdupdate::db_update_133($dbh);

print("### close database connection\n");
$dbh->disconnect;


####################################################################################
