All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 6c285ab0 authored by Leigh B Stoller's avatar Leigh B Stoller

Companion script to update 49; this one renames card,port in the

interfaces and interface_state table to card_saved,port_saved. The
primary keys are dropped and new ones added for node_id,iface.
parent 2b1d4c3c
#
# DB schema changes that have to run after script 49, but since sql updates
# run before update scripts, we have to do these schema changes here to
# make sure they run afer script 49.
#
use strict;
use libinstall;
use installvars;
use emdb;
sub InstallUpdate($$)
{
my ($version, $phase) = @_;
#
# If something should run in the pre-install phase.
#
if ($phase eq "pre") {
Phase "dropprimary", "Dropping old primary keys", sub {
if (DBKeyExists("interfaces", "PRIMARY")) {
DBQueryWarn("alter table interfaces drop primary key")
or PhaseFail("DB Failure interfaces");
}
if (DBKeyExists("interface_state", "PRIMARY")) {
DBQueryWarn("alter table interface_state drop primary key")
or PhaseFail("DB Failure interface state");
}
if (DBKeyExists("interface_state", "nodeiface")) {
DBQueryFatal("alter table interface_state ".
" drop key `nodeiface`");
}
};
Phase "rename1", "Renaming card,port in interfaces", sub {
if (DBSlotExists("interfaces", "card_saved")) {
PhaseSkip("already done");
}
DBQueryWarn("alter table interfaces ".
" change card card_saved ".
" tinyint(3) unsigned NOT NULL default '0',".
" change port port_saved ".
" smallint(5) unsigned NOT NULL default '0'")
or PhaseFail("DB Failure interfaces");
};
Phase "rename2", "Renaming card,port in interface_state", sub {
if (DBSlotExists("interface_state", "card_saved")) {
PhaseSkip("already done");
}
DBQueryWarn("alter table interface_state ".
" change card card_saved ".
" tinyint(3) unsigned NOT NULL default '0',".
" change port port_saved ".
" smallint(5) unsigned NOT NULL default '0'")
or PhaseFail("DB Failure interface_state");
};
Phase "addprimary", "Adding new primary keys", sub {
if (!DBKeyExists("interfaces", "PRIMARY")) {
DBQueryWarn("alter table interfaces add primary key ".
" (`node_id`,`iface`(128))")
or PhaseFail("DB Failure interfaces");
}
if (!DBKeyExists("interface_state", "PRIMARY")) {
DBQueryWarn("alter table interface_state add primary key ".
" (`node_id`,`iface`)")
or PhaseFail("DB Failure interface state");
}
};
}
#
# If something should run in the post-install phase.
#
if ($phase eq "post") {
}
return 0;
}
1;
# Local Variables:
# mode:perl
# End:
......@@ -2635,14 +2635,13 @@ CREATE TABLE `interface_settings` (
DROP TABLE IF EXISTS `interface_state`;
CREATE TABLE `interface_state` (
`node_id` varchar(32) NOT NULL default '',
`card` tinyint(3) unsigned NOT NULL default '0',
`port` smallint(5) unsigned NOT NULL default '0',
`card_saved` tinyint(3) unsigned NOT NULL default '0',
`port_saved` smallint(5) unsigned NOT NULL default '0',
`iface` varchar(32) NOT NULL,
`enabled` tinyint(1) default '1',
`tagged` tinyint(1) default '0',
`remaining_bandwidth` int(11) NOT NULL default '0',
PRIMARY KEY (`node_id`,`card`,`port`),
KEY `nodeiface` (`node_id`,`iface`)
PRIMARY KEY (`node_id`,`iface`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
......@@ -2668,8 +2667,8 @@ CREATE TABLE `interface_types` (
DROP TABLE IF EXISTS `interfaces`;
CREATE TABLE `interfaces` (
`node_id` varchar(32) NOT NULL default '',
`card` tinyint(3) unsigned NOT NULL default '0',
`port` smallint(5) unsigned NOT NULL default '0',
`card_saved` tinyint(3) unsigned NOT NULL default '0',
`port_saved` smallint(5) unsigned NOT NULL default '0',
`mac` varchar(12) NOT NULL default '000000000000',
`guid` varchar(16) default NULL,
`IP` varchar(15) default NULL,
......@@ -2689,7 +2688,7 @@ CREATE TABLE `interfaces` (
`uuid` varchar(40) NOT NULL default '',
`logical` tinyint(1) unsigned NOT NULL default '0',
`autocreated` tinyint(1) unsigned NOT NULL default '0',
PRIMARY KEY (`node_id`,`card`,`port`),
PRIMARY KEY (`node_id`,`iface`(128)),
KEY `mac` (`mac`),
KEY `IP` (`IP`),
KEY `uuid` (`uuid`),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment