- convert the registrations_id in the question answers to the new users_id (it's really the users id anyway)

- add a 117 script to cleanup all the post 116 stuff, deleting unneeded tables and whatnot
- these are NOT THE FINAL scripts, more will be added to these.
This commit is contained in:
dave 2008-10-17 20:38:01 +00:00
parent b021805246
commit 87c845c048
4 changed files with 51 additions and 5 deletions

View File

@ -171,7 +171,7 @@ function db_update_116_post()
$q = mysql_query("INSERT INTO users_judge ($fields) VALUES ($vals)");
echo mysql_error();
/* FIXUP all the judging tables (bit don't write back yet, we don't want to
/* FIXUP all the judging tables (but don't write back yet, we don't want to
* accidentally create a duplicate judges_id and overwrite it later) */
/* judges_teams_link */
@ -185,8 +185,12 @@ function db_update_116_post()
while($i = mysql_fetch_object($q))
$jsal[$i->id] = $id;
/* question_answers */
$q = mysql_query("SELECT * FROM question_answers WHERE registrations_id='{$j->id}' AND year='{$j->year}'");
echo mysql_error();
while($i = mysql_fetch_object($q))
$qa[$i->id] = $id;
}
}
/* Now write back the judge ids */
@ -196,8 +200,8 @@ function db_update_116_post()
foreach($jsal as $id=>$new_id)
$q = mysql_query("UPDATE judges_specialaward_sel SET judges_id='$new_id' WHERE id='$id' ");
foreach($qa as $id=>$new_id)
$q = mysql_query("UPDATE question_answers SET registrations_id='$new_id' WHERE id='$id' ");
}
?>

View File

@ -22,4 +22,5 @@ ALTER TABLE `users_volunteer` DROP `tmp`;
DROP TABLE users_years;
ALTER TABLE `question_answers` CHANGE `registrations_id` `users_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';

31
db/db.update.117.php Normal file
View File

@ -0,0 +1,31 @@
<?
function db_update_117_post()
{
global $config;
$qmap = array('years_school' => 'Years School',
'years_regional' => 'Years Regional',
'years_national' => 'Years National',
'willing_chair' => 'Willing Chair');
foreach($qmap as $field=>$head) {
$q = mysql_query("SELECT id FROM questions WHERE db_heading='{$head}'");
while($i = mysql_fetch_object($q)) {
$id = $i->id;
/* Drop all answers for this question */
mysql_query("DELETE FROM question_answers
WHERE questions_id='$id'");
}
/* Now dump the question itself */
mysql_query("DELETE FROM questions
WHERE id='$id'");
}
}

10
db/db.update.117.sql Normal file
View File

@ -0,0 +1,10 @@
-- complete has been moved inside each users_* table
ALTER TABLE `users` DROP `complete`;
-- drop the old judge tables, all this info is now in the new user system (converted in the 116 update)
DROP TABLE `judges`,`judges_catpref`,`judges_expertise`,`judges_languages`,`judges_years` ;
-- questions table should use users_id now (which is what was being saved in the registrations_id)
ALTER TABLE `question_answers` CHANGE `registrations_id` `users_id` INT( 10 ) UNSIGNED NOT NULL DEFAULT '0';