| 171 | === Merge Accounts by Id === |
| 172 | {{{ |
| 173 | #!sql |
| 174 | DROP PROCEDURE IF EXISTS merge_by_id; |
| 175 | |
| 176 | delimiter // |
| 177 | |
| 178 | CREATE PROCEDURE merge_by_id(IN target_id INT, IN source_id INT) |
| 179 | BEGIN |
| 180 | DECLARE temp_id INT; |
| 181 | |
| 182 | SELECT CONCAT("Merging user ", source_id, " into ", target_id) as ""; |
| 183 | UPDATE IGNORE groups_members set user_id = target_id where user_id = source_id; |
| 184 | UPDATE IGNORE user_enrols set user_id = target_id where user_id = source_id; |
| 185 | UPDATE IGNORE survey_group_members set user_id = target_id where user_id = source_id; |
| 186 | UPDATE survey_inputs set user_id = target_id where user_id = source_id; |
| 187 | UPDATE evaluation_submissions set submitter_id = target_id where submitter_id = source_id; |
| 188 | UPDATE evaluation_simples set evaluator = target_id where evaluator = source_id; |
| 189 | UPDATE evaluation_simples set evaluatee = target_id where evaluatee = source_id; |
| 190 | UPDATE evaluation_simples set creator_id = target_id where creator_id = source_id; |
| 191 | UPDATE evaluation_simples set updater_id = target_id where updater_id = source_id; |
| 192 | UPDATE evaluation_rubrics set evaluator = target_id where evaluator = source_id; |
| 193 | UPDATE evaluation_rubrics set evaluatee = target_id where evaluatee = source_id; |
| 194 | UPDATE evaluation_rubrics set creator_id = target_id where creator_id = source_id; |
| 195 | UPDATE evaluation_rubrics set updater_id = target_id where updater_id = source_id; |
| 196 | UPDATE evaluation_rubric_details set creator_id = target_id where creator_id = source_id; |
| 197 | UPDATE evaluation_rubric_details set updater_id = target_id where updater_id = source_id; |
| 198 | UPDATE evaluation_mixevals set evaluator = target_id where evaluator = source_id; |
| 199 | UPDATE evaluation_mixevals set evaluatee = target_id where evaluatee = source_id; |
| 200 | UPDATE evaluation_mixevals set creator_id = target_id where creator_id = source_id; |
| 201 | UPDATE evaluation_mixevals set updater_id = target_id where updater_id = source_id; |
| 202 | UPDATE evaluation_mixeval_details set creator_id = target_id where creator_id = source_id; |
| 203 | UPDATE evaluation_mixeval_details set updater_id = target_id where updater_id = source_id; |
| 204 | DELETE from users where id = source_id LIMIT 1; |
| 205 | END// |
| 206 | |
| 207 | delimiter ; |
| 208 | }}} |
| 209 | |