- Timestamp:
- 03/19/10 20:25:22 (2 years ago)
- File:
-
- 1 edited
-
trunk/scripts/migrate-ia-score.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/scripts/migrate-ia-score.php
r1110 r1112 7 7 8 8 $query = "CREATE TABLE `ia_score_user_round` ( 9 user_id int ,10 round_id varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci,11 score decimal(11, 4) ,12 CONSTRAINT user_round UNIQUE(user_id, round_id)9 user_id int NOT NULL, 10 round_id varchar(64) CHARACTER SET utf8 NOT NULL, 11 score decimal(11, 4) NOT NULL, 12 PRIMARY KEY user_round (user_id, round_id) 13 13 )"; 14 14 db_query($query); 15 15 16 16 $query = "CREATE TABLE `ia_score_user_round_task` ( 17 user_id int ,18 round_id varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci,19 task_id varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci,20 score decimal(11, 4) ,21 CONSTRAINT user_round_task UNIQUE(user_id, round_id, task_id)17 user_id int NOT NULL, 18 round_id varchar(64) CHARACTER SET utf8 NOT NULL, 19 task_id varchar(64) CHARACTER SET utf8 NOT NULL, 20 score decimal(11, 4) NOT NULL, 21 PRIMARY KEY user_round_task (user_id, round_id, task_id) 22 22 )"; 23 23 db_query($query); 24 24 25 25 $query = "CREATE TABLE `ia_rating` ( 26 user_id int ,27 round_id varchar(64) CHARACTER SET latin1 COLLATE latin1_general_ci,28 deviation decimal(11, 4) ,29 rating decimal(11, 4) ,30 CONSTRAINT user_round UNIQUE(user_id, round_id)26 user_id int NOT NULL, 27 round_id varchar(64) CHARACTER SET utf8 NOT NULL, 28 deviation decimal(11, 4) NOT NULL, 29 rating decimal(11, 4) NOT NULL, 30 PRIMARY KEY user_round (user_id, round_id) 31 31 )"; 32 32 db_query($query); … … 46 46 db_query($query); 47 47 } 48 48 49 49 $query = "UPDATE `ia_rating` SET `".$score['name']."` = ".db_quote($score['score'])." WHERE ".$where; 50 50 db_query($query); 51 51 } else if ($score['name'] == 'score') { 52 if (is_null($score["round_id"])) { 53 echo implode(' | ', $score)." dumped\n"; 54 continue; 55 } 52 56 $query = "INSERT INTO `ia_score_user_round_task` (`user_id`, `round_id`, `task_id`, `score`) 53 57 VALUES (".implode(',', 54 58 array( 55 59 db_quote($score['user_id']), 56 db_quote($score['round_id']), 60 db_quote($score['round_id']), 57 61 db_quote($score['task_id']), 58 62 db_quote($score['score'])) … … 80 84 } 81 85 db_query($query); 82 } else echo implode(' | ', $score)." dumped\n"; 86 } else if ($score["name"] == "submit_count") { 87 // submit_count is useless and can be ignored 88 } else { 89 echo implode(' | ', $score)." dumped\n"; 90 } 83 91 } 84 92 … … 86 94 $rounds = db_fetch_all($query); 87 95 88 //$query = "DROP TABLE `ia_score`";89 //db_query($query)96 $query = "DROP TABLE `ia_score`"; 97 db_query($query) 90 98 ?>
Note: See TracChangeset
for help on using the changeset viewer.
![[infoarena] development](/chrome/site/logo.png)