Commit 918c796d authored by Leigh B Stoller's avatar Leigh B Stoller

Bunch of DB changes to support nonlocal projects and experiments, for

Protogeni. There is also some nonlocal user stuff, but that stuff is
not in use yet. Might never be. Also add author_idx fields to news
table so we can do lookup using uid_idx. Add default_project to users
table.
parent bb5d05bf
......@@ -924,6 +924,9 @@ CREATE TABLE `experiment_stats` (
`archive_idx` int(10) unsigned default NULL,
`last_error` int(10) unsigned default NULL,
`dpdbname` varchar(64) default NULL,
`nonlocal_id` varchar(128) default NULL,
`nonlocal_user_id` varchar(128) default NULL,
`nonlocal_type` tinytext,
PRIMARY KEY (`exptidx`),
KEY `rsrcidx` (`rsrcidx`),
KEY `pideid` (`pid`,`eid`),
......@@ -1306,6 +1309,9 @@ CREATE TABLE `experiments` (
`dpdbname` varchar(64) default NULL,
`dpdbpassword` varchar(64) default NULL,
`geniflags` int(11) NOT NULL default '0',
`nonlocal_id` varchar(128) default NULL,
`nonlocal_user_id` varchar(128) default NULL,
`nonlocal_type` tinytext,
PRIMARY KEY (`idx`),
UNIQUE KEY `pideid` (`pid`,`eid`),
UNIQUE KEY `pididxeid` (`pid_idx`,`eid`),
......@@ -3297,6 +3303,7 @@ CREATE TABLE `projects` (
`control_node` varchar(10) default NULL,
`unix_gid` smallint(5) unsigned NOT NULL auto_increment,
`approved` tinyint(4) default '0',
`hidden` tinyint(1) default '0',
`inactive` tinyint(4) default '0',
`date_inactive` datetime default NULL,
`public` tinyint(4) NOT NULL default '0',
......@@ -3308,6 +3315,8 @@ CREATE TABLE `projects` (
`linked_to_us` tinyint(4) NOT NULL default '0',
`cvsrepo_public` tinyint(1) NOT NULL default '0',
`allow_workbench` tinyint(1) NOT NULL default '0',
`nonlocal_id` varchar(128) default NULL,
`nonlocal_type` tinytext,
PRIMARY KEY (`pid_idx`),
UNIQUE KEY `pid` (`pid`),
KEY `unix_gid` (`unix_gid`),
......@@ -3929,7 +3938,7 @@ CREATE TABLE `users` (
`usr_pswd` tinytext NOT NULL,
`usr_w_pswd` tinytext,
`unix_uid` smallint(5) unsigned NOT NULL default '0',
`status` enum('newuser','unapproved','unverified','active','frozen','archived','other') NOT NULL default 'newuser',
`status` enum('newuser','unapproved','unverified','active','frozen','archived','nonlocal','other') NOT NULL default 'newuser',
`admin` tinyint(4) default '0',
`foreign_admin` tinyint(4) default '0',
`dbedit` tinyint(4) default '0',
......@@ -3954,11 +3963,15 @@ CREATE TABLE `users` (
`wikiname` tinytext,
`wikionly` tinyint(1) default '0',
`mailman_password` tinytext,
`nonlocal_id` varchar(128) default NULL,
`nonlocal_type` tinytext,
`default_project` mediumint(8) unsigned default NULL,
`nocollabtools` tinyint(1) default '0',
PRIMARY KEY (`uid_idx`),
KEY `unix_uid` (`unix_uid`),
KEY `status` (`status`),
KEY `uid_uuid` (`uid_uuid`),
KEY `uid` (`uid`)
KEY `uid` (`uid`),
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
--
......@@ -4637,6 +4650,7 @@ CREATE TABLE `webnews` (
`subject` tinytext,
`date` datetime default NULL,
`author` varchar(32) default NULL,
`author_idx` mediumint(8) unsigned NOT NULL default '0',
`body` text,
`archived` tinyint(1) NOT NULL default '0',
`archived_date` datetime default NULL,
......@@ -4654,6 +4668,7 @@ CREATE TABLE `webnews_protogeni` (
`subject` tinytext,
`date` datetime default NULL,
`author` varchar(32) default NULL,
`author_idx` mediumint(8) unsigned NOT NULL default '0',
`body` text,
`archived` tinyint(1) NOT NULL default '0',
`archived_date` datetime default NULL,
......
......@@ -753,6 +753,8 @@ REPLACE INTO table_regex VALUES ('projects','default_user_interface','text','reg
REPLACE INTO table_regex VALUES ('projects','pid','text','regex','^[-\\w]+$',2,48,NULL);
REPLACE INTO table_regex VALUES ('projects','pid_idx','text','regex','^[\\d]+$',1,12,NULL);
REPLACE INTO table_regex VALUES ('projects','URL','text','redirect','default:tinytext',0,0,NULL);
REPLACE INTO table_regex VALUES ('projects','nonlocal_id','text','regex','^[-_\\w\\.\\/:+]*$',10,128,NULL);
REPLACE INTO table_regex VALUES ('projects','nonlocal_type','text','regex','^[-\\w]*$',1,64,NULL);
REPLACE INTO table_regex VALUES ('reserved','vname','text','redirect','virt_nodes:vname',1,32,NULL);
REPLACE INTO table_regex VALUES ('users','uid','text','regex','^[a-zA-Z][\\w]+$',2,8,NULL);
REPLACE INTO table_regex VALUES ('users','uid_idx','text','regex','^[\\d]+$',1,12,NULL);
......
#
# More uid_idx changes, in prep for nonlocal users.
#
use strict;
use libdb;
sub DoUpdate($$$)
{
my ($dbhandle, $dbname, $version) = @_;
if (!DBSlotExists("webnews", "author_idx")) {
DBQueryFatal("alter table webnews add ".
" `author_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after author");
}
if (!DBSlotExists("webnews_protogeni", "author_idx")) {
DBQueryFatal("alter table webnews_protogeni add ".
" `author_idx` mediumint(8) unsigned NOT NULL default '0' ".
" after author");
}
DBQueryFatal("update webnews as n left join users as u on ".
" n.author=u.uid ".
"set n.author_idx=u.uid_idx ".
"where u.status!='archived' and u.status!='frozen'");
DBQueryFatal("update webnews_protogeni as n left join users as u on ".
" n.author=u.uid ".
"set n.author_idx=u.uid_idx ".
"where u.status!='archived' and u.status!='frozen'");
my $type = DBSlotType("users", "status");
if (!$type) {
Fatal("Could not get type for 'status' in 'users'");
}
if (! ($type =~ /nonlocal/)) {
DBQueryFatal("alter table users modify `status` ".
"enum('newuser','unapproved','unverified','active', ".
" 'frozen','archived','nonlocal','other') ".
" NOT NULL default 'newuser'");
}
# Not actually using the nonlocal slots of the user table, but
# putting adding them in case I want to later.
if (!DBSlotExists("users", "nonlocal_id")) {
DBQueryFatal("alter table users add ".
" `nonlocal_id` varchar(128) default NULL");
}
if (!DBSlotExists("users", "nonlocal_type")) {
DBQueryFatal("alter table users add ".
" `nonlocal_type` tinytext");
}
if (!DBSlotExists("users", "default_project")) {
DBQueryFatal("alter table users add ".
"`default_project` mediumint(8) unsigned default NULL");
}
if (!DBSlotExists("users", "nocollabtools")) {
DBQueryFatal("alter table users add ".
"`nocollabtools` tinyint(1) default '0'");
DBQueryFatal("update users set nocollabtools=1 ".
"where uid='elabman' or uid='geniuser' or uid='elabckup'");
}
if (!DBSlotExists("projects", "nonlocal_id")) {
DBQueryFatal("alter table projects add ".
" `nonlocal_id` varchar(128) default NULL");
}
if (!DBSlotExists("projects", "nonlocal_type")) {
DBQueryFatal("alter table projects add ".
" `nonlocal_type` tinytext");
}
if (!DBSlotExists("projects", "hidden")) {
DBQueryFatal("alter table projects add ".
" `hidden` tinyint(1) default '0' after approved");
}
if (!DBSlotExists("experiments", "nonlocal_id")) {
DBQueryFatal("alter table experiments add ".
" `nonlocal_id` varchar(128) default NULL");
}
if (!DBSlotExists("experiments", "nonlocal_user_id")) {
DBQueryFatal("alter table experiments add ".
" `nonlocal_user_id` varchar(128) default NULL ".
" after nonlocal_id");
}
if (!DBSlotExists("experiments", "nonlocal_type")) {
DBQueryFatal("alter table experiments add ".
" `nonlocal_type` tinytext");
}
if (!DBSlotExists("experiment_stats", "nonlocal_id")) {
DBQueryFatal("alter table experiment_stats add ".
" `nonlocal_id` varchar(128) default NULL");
}
if (!DBSlotExists("experiment_stats", "nonlocal_user_id")) {
DBQueryFatal("alter table experiment_stats add ".
" `nonlocal_user_id` varchar(128) default NULL ".
" after nonlocal_id");
}
if (!DBSlotExists("experiment_stats", "nonlocal_type")) {
DBQueryFatal("alter table experiment_stats add ".
" `nonlocal_type` tinytext");
}
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('projects','nonlocal_id','text','regex', ".
" '^[-_\\\\w\\\\.\\\\/:+]*\$',10,128,NULL)");
DBQueryFatal("REPLACE INTO table_regex VALUES ".
"('projects','nonlocal_type','text','regex', ".
" '^[-\\\\w]*\$',1,64,NULL)");
return 0;
}
1;
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