forked from science-ation/science-ation
Adding conferences_id fields to judges tables. Will later drop the year fields
This commit is contained in:
parent
5cd3f22088
commit
fa69916607
@ -1 +1 @@
|
|||||||
203
|
204
|
||||||
|
46
db/db.update.204.php
Executable file
46
db/db.update.204.php
Executable file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
function db_update_204_pre()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
function db_update_204_post()
|
||||||
|
{
|
||||||
|
$tables = array(
|
||||||
|
'judges_schedulerconfig',
|
||||||
|
'judges_teams',
|
||||||
|
'judges_teams_awards_link',
|
||||||
|
'judges_teams_link',
|
||||||
|
'judges_teams_timeslots_link',
|
||||||
|
'judges_teams_timeslots_projects_link',
|
||||||
|
'judges_timeslots'
|
||||||
|
);
|
||||||
|
|
||||||
|
// get the year => conference_id links
|
||||||
|
$q1 = mysql_query("SELECT year, id FROM conferences");
|
||||||
|
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";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// a couple more
|
||||||
|
foreach($tables as $tableName){
|
||||||
|
$query = "UPDATE `$tableName` SET `conferences_id` = -1 WHERE `year` = -1";
|
||||||
|
mysql_query($query);
|
||||||
|
echo $query . ";\n";
|
||||||
|
|
||||||
|
$query = mysql_query("SELECT DISTINCT(year) FROM `$tableName` WHERE `conferences_id` = 0");
|
||||||
|
$badYears = array();
|
||||||
|
while($data = mysql_fetch_assoc($query)){
|
||||||
|
$badYears[] = $data['year'];
|
||||||
|
}
|
||||||
|
if(count($badYears) > 0){
|
||||||
|
echo "ERROR: could not update conference_id in the table '$tableName' for the years ";
|
||||||
|
echo implode(', ', $badYears) . "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
?>
|
7
db/db.update.204.sql
Normal file
7
db/db.update.204.sql
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
ALTER TABLE `judges_schedulerconfig` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_teams` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_teams_awards_link` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_teams_link` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_teams_timeslots_link` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_teams_timeslots_projects_link` ADD `conferences_id` INT NOT NULL;
|
||||||
|
ALTER TABLE `judges_timeslots` ADD `conferences_id` INT NOT NULL;
|
Loading…
Reference in New Issue
Block a user