Skip to content
Browse files

this is all wrong - will try to clean up later tonight

  • Loading branch information...
1 parent d3f98eb commit abd7dfb38ca2616a46d1101f13622843876dbb25 danmarsden committed Apr 6, 2005
Showing with 30 additions and 31 deletions.
  1. +30 −31 mod/choice/db/postgres7.php
View
61 mod/choice/db/postgres7.php
@@ -41,41 +41,40 @@ function choice_upgrade($oldversion) {
modify_database('','CREATE INDEX prefix_choice_answers_choice_idx ON prefix_choice_answers (choice);');
modify_database('','CREATE INDEX prefix_choice_answers_userid_idx ON prefix_choice_answers (userid);');
}
- if ($oldversion < 2005033000){
- execute_sql("ALTER TABLE {$CFG->prefix}choice_answers RENAME TO {$CFG->prefix}choice_responses;");
- execute_sql("CREATE TABLE {$CFG->prefix}choice_answers (id SERIAL PRIMARY KEY, choice integer NOT NULL default '0', answer TEXT, timemodified integer NOT NULL default '0');");
- execute_sql("CREATE INDEX {$CFG->prefix}choice_answers_choice_idx ON {$CFG->prefix}choice_answers (choice);");
- table_column('choice','','display','integer','10','unsigned','0','not null');
- table_column('choice_responses','answer','answerid','integer','10','unsigned','0','not null');
-
- //move old answers into new answer table.
- $records = get_records('choice');
- if (!empty($records)) {
- foreach ($records as $thischoice) {
- for ($i = 1; $i < 5; $i++) {
- $instance = new stdClass;
- $instance->choice = $thischoice->id;
- $instance->answerid = $thischoice->{'answer'.$i};
- $instance->timemodified = $thischoice->timemodified;
- $result = insert_record('choice_answers', $instance);
- //now fix all responses to the answers.
- execute_sql("UPDATE {$CFG->prefix}choice_responses SET answerid={$result} WHERE choice={$thischoice->id} AND answerid={$i}");
- }
- }
- }
+ // if ($oldversion < 2005033000){
+ // execute_sql("ALTER TABLE {$CFG->prefix}choice_answers RENAME TO {$CFG->prefix}choice_responses;");
+ // execute_sql("CREATE TABLE {$CFG->prefix}choice_answers (id SERIAL PRIMARY KEY, choice integer NOT NULL default '0', answer TEXT, timemodified integer NOT NULL default '0');");
+ // execute_sql("CREATE INDEX {$CFG->prefix}choice_answers_choice_idx ON {$CFG->prefix}choice_answers (choice);");
+ // table_column('choice','','display','integer','10','unsigned','0','not null');
+ // table_column('choice_responses','answer','answerid','integer','10','unsigned','0','not null');
+ //
+ // //move old answers into new answer table.
+ // $records = get_records('choice');
+ // if (!empty($records)) {
+ // foreach ($records as $thischoice) {
+ // for ($i = 1; $i < 5; $i++) {
+ // $instance = new stdClass;
+ // $instance->choice = $thischoice->id;
+ // $instance->answerid = $thischoice->{'answer'.$i};
+ // $instance->timemodified = $thischoice->timemodified;
+ // $result = insert_record('choice_answers', $instance);
+ // //now fix all responses to the answers.
+ // execute_sql("UPDATE {$CFG->prefix}choice_responses SET answerid={$result} WHERE choice={$thischoice->id} AND answerid={$i}");
+ // }
+ // }
+ // }
- //drop old fields
- modify_database('','ALTER TABLE prefix_choice DROP answer1;');
- modify_database('','ALTER TABLE prefix_choice DROP answer2;');
- modify_database('','ALTER TABLE prefix_choice DROP answer3;');
- modify_database('','ALTER TABLE prefix_choice DROP answer4;');
- modify_database('','ALTER TABLE prefix_choice DROP answer5;');
- modify_database('','ALTER TABLE prefix_choice DROP answer6;');
+ // drop old fields
+ // modify_database('','ALTER TABLE prefix_choice DROP answer1;');
+ // modify_database('','ALTER TABLE prefix_choice DROP answer2;');
+ // modify_database('','ALTER TABLE prefix_choice DROP answer3;');
+ // modify_database('','ALTER TABLE prefix_choice DROP answer4;');
+ // modify_database('','ALTER TABLE prefix_choice DROP answer5;');
+ // modify_database('','ALTER TABLE prefix_choice DROP answer6;');
- }
+ // }
return true;
}
-
?>

0 comments on commit abd7dfb

Please sign in to comment.
Something went wrong with that request. Please try again.