Move my 196 update to 198. Add conferences_id migration to users table

This commit is contained in:
dave 2010-07-13 03:30:04 +00:00
parent 68737a68b7
commit 514c1f12b9
2 changed files with 45 additions and 5 deletions

43
db/db.update.198.php Normal file
View File

@ -0,0 +1,43 @@
<?
function db_update_198_post()
{
echo "Migrating passwordset and oldpassword data...\n";
$q = mysql_query("SELECT * FROM accounts");
echo mysql_error();
while($a = mysql_fetch_assoc($q)) {
$aid = $a['id'];
$qq = mysql_query("SELECT * FROM users WHERE accounts_id=$aid ORDER BY year DESC LIMIT 1");
echo mysql_error();
if(mysql_num_rows($qq)) {
$u = mysql_fetch_assoc($qq);
$set = $u['passwordset'];
$old = mysql_escape_string($u['oldpassword']);
} else {
$set = '0000-00-00';
$old = '';
}
mysql_query("UPDATE accounts SET passwordset='$set',oldpassword='$old' WHERE id=$aid");
echo mysql_error();
}
echo "Migating conference ID from user_roles to users...\n";
$q = mysql_query("SELECT * FROM users");
echo mysql_error();
while($u = mysql_fetch_assoc($q)) {
$id = $u['id'];
$qq = mysql_query("SELECT * FROM user_roles WHERE users_id=$id LIMIT 1");
echo mysql_error();
if(mysql_num_rows($qq)) {
$r = mysql_fetch_assoc($qq);
mysql_query("UPDATE users SET conferences_id='{$r['conferences_id']}' WHERE id=$id");
echo mysql_error();
} else {
echo " No role data for user $id, skipping\n";
}
}
echo "Done.\n";
}

View File

@ -1,6 +1,3 @@
<<<<<<< Updated upstream
INSERT INTO `config` ( `var` , `val` , `category` , `type` , `type_values` , `ord` , `description` , `section`, `conferencetypes`, `conferences_id`, `year`) VALUES ( 'website', '', 'Global', 'text', '', '800', 'Your organization\'s website', 'conference', 'sciencefair,scienceolympics', '-1', '-1'), ( 'website_name', '', 'Global', 'text', '', '801', 'The name for your organization\'s website. This is only used if a website is entered.', 'conference', 'sciencefair,scienceolympics', '-1', '-1');
=======
-- Rename role columns, we know they're roles, we don't need a "role" prefix
ALTER TABLE `roles` CHANGE `roletype` `type` VARCHAR( 256 ) NOT NULL;
ALTER TABLE `roles` CHANGE `rolename` `name` VARCHAR( 256 ) NOT NULL;
@ -35,5 +32,5 @@ ALTER TABLE `users` CHANGE `grade` `grade` INT( 11 ) NULL DEFAULT NULL COMMENT '
-- Remove unneeded table, this linkage is in user_roles
DROP TABLE `users_conferences_link`;
>>>>>>> Stashed changes
-- Add conferences ID to users
ALTER TABLE `users` ADD `conferences_id` INT NOT NULL AFTER `accounts_id`;