162 791 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
use strict;
use libdb;

sub DoUpdate($$$)
{
    my ($dbhandle, $dbname, $version) = @_;

    if (!DBTableExists("widearea_switches")) {
	DBQueryFatal("CREATE TABLE `widearea_switches` ( ".
		     "  `hrn` varchar(255) NOT NULL default '', ".
		     "  `node_id` varchar(32) NOT NULL default '', ".
		     "  PRIMARY KEY  (`hrn`) ".
		     ") ENGINE=MyISAM DEFAULT CHARSET=latin1");
    }
    my $type = DBSlotType("nodes", "role");
    if (!$type) {
	Fatal("No 'role' slot in 'nodes' table");
    }
    if (! ($type =~ /widearea_switch/)) {
	DBQueryFatal("alter table nodes change `role` `role` ".
		     "  enum('testnode','virtnode','ctrlnode','testswitch', ".
		     "  'ctrlswitch','powerctrl','widearea_switch','unused') ".
		     "NOT NULL default 'unused'");
    }
    return 0;
}
1;