forked from science-ation/science-ation
37 lines
857 B
PHP
37 lines
857 B
PHP
<?
|
|
function db_update_212_pre()
|
|
{
|
|
}
|
|
|
|
function db_update_212_post()
|
|
{
|
|
$tables=array("volunteer_positions_signup", "volunteer_positions");
|
|
|
|
// add the conferences_id field
|
|
foreach($tables as $tableName){
|
|
$query = "ALTER TABLE `$tableName` ADD `conferences_id` INT NOT NULL";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
|
|
// get the year => conference_id links
|
|
$q1 = mysql_query("SELECT year, id FROM conferences WHERE year > 0");
|
|
|
|
//update the tables
|
|
while($r = mysql_fetch_assoc($q1)){
|
|
foreach($tables as $tableName){
|
|
$query = "UPDATE `$tableName` SET `conferences_id` = {$r['id']} WHERE `year` = {$r['year']}";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
}
|
|
|
|
// add the conferences_id field
|
|
foreach($tables as $tableName){
|
|
$query = "ALTER TABLE `$tableName` DROP `year`";
|
|
mysql_query($query);
|
|
echo $query . ";\n";
|
|
}
|
|
}
|
|
?>
|