Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/tests/scripts/fix_migrations_1.9.x_1.10.0...

480 lines
76 KiB

<?php
/* For license terms, see /license.txt */
/**
* Fix failed migration 1.9.x to 1.10.0
* Note: You need execute the ./fix_duplicate_settings.php to remove duplicated settings from failed migration
*/
exit;
require_once __DIR__.'/../../main/inc/global.inc.php';
api_protect_admin_script();
if (function_exists('ini_set')) {
ini_set('memory_limit', -1);
ini_set('max_execution_time', 0);
echo "memory_limit set to -1" . PHP_EOL;
echo "max_execution_time 0<br>" . PHP_EOL;
} else {
echo "Could not change memory and time limits<br>" . PHP_EOL;
}
echo "<br>" . PHP_EOL;
Database::query("ALTER TABLE sequence ADD name VARCHAR(255) NOT NULL, ADD graph LONGTEXT DEFAULT NULL, ADD created_at DATETIME NOT NULL, ADD updated_at DATETIME NOT NULL, DROP sequence_row_entity_id, DROP sequence_row_entity_id_next, DROP is_part, CHANGE id id INT AUTO_INCREMENT NOT NULL");
Database::query("CREATE TABLE sequence_resource (id INT AUTO_INCREMENT NOT NULL, sequence_id INT DEFAULT NULL, type INT NOT NULL, resource_id INT NOT NULL, INDEX IDX_34ADA43998FB19AE (sequence_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
Database::query("CREATE TABLE class_item (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(40) DEFAULT NULL, name LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
Database::query("ALTER TABLE sequence_resource ADD CONSTRAINT FK_34ADA43998FB19AE FOREIGN KEY (sequence_id) REFERENCES sequence (id)");
Database::query("DROP INDEX access_cours_code ON track_e_lastaccess");
Database::query("ALTER TABLE track_e_lastaccess DROP access_cours_code, CHANGE access_user_id access_user_id INT DEFAULT NULL, CHANGE access_date access_date DATETIME NOT NULL, CHANGE access_session_id access_session_id INT DEFAULT NULL");
Database::query("CREATE INDEX access_c_id ON track_e_lastaccess (c_id)");
Database::query("ALTER TABLE access_url ADD url_type TINYINT(1) DEFAULT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE active active INT NOT NULL, CHANGE tms tms DATETIME NOT NULL");
Database::query("ALTER TABLE access_url ENGINE=InnoDB");
Database::query("ALTER TABLE session_category CHANGE access_url_id access_url_id INT DEFAULT NULL");
Database::query("ALTER TABLE session_category ENGINE=InnoDB");
Database::query("ALTER TABLE session_category ADD CONSTRAINT FK_8DE079A973444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)");
Database::query("CREATE INDEX IDX_8DE079A973444FD5 ON session_category (access_url_id)");
Database::query("ALTER TABLE user CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE username username VARCHAR(100) NOT NULL, CHANGE auth_source auth_source VARCHAR(50) DEFAULT NULL, CHANGE email email VARCHAR(100) NOT NULL, CHANGE status status INT NOT NULL, CHANGE creator_id creator_id INT DEFAULT NULL, CHANGE chatcall_user_id chatcall_user_id INT DEFAULT NULL, CHANGE active active TINYINT(1) NOT NULL, CHANGE hr_dept_id hr_dept_id SMALLINT DEFAULT NULL");
Database::query("CREATE UNIQUE INDEX UNIQ_8D93D64992FC23A8 ON user (username_canonical)");
Database::query("DROP INDEX username ON user");
Database::query("CREATE UNIQUE INDEX UNIQ_8D93D649F85E0677 ON user (username)");
Database::query("ALTER TABLE user ENGINE=InnoDB");
Database::query("ALTER TABLE session DROP date_start, DROP date_end, DROP nb_days_access_before_beginning, DROP nb_days_access_after_end, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE id_coach id_coach INT DEFAULT NULL, CHANGE name name VARCHAR(150) NOT NULL, CHANGE nbr_courses nbr_courses SMALLINT DEFAULT NULL, CHANGE nbr_users nbr_users INT DEFAULT NULL, CHANGE nbr_classes nbr_classes INT DEFAULT NULL, CHANGE session_admin_id session_admin_id INT DEFAULT NULL, CHANGE visibility visibility INT NOT NULL, CHANGE session_category_id session_category_id INT DEFAULT NULL, CHANGE promotion_id promotion_id INT DEFAULT NULL, CHANGE description description LONGTEXT DEFAULT NULL, CHANGE show_description show_description TINYINT(1) DEFAULT NULL");
Database::query("ALTER TABLE session ENGINE=InnoDB");
Database::query("UPDATE session SET id_coach = NULL WHERE id_coach = 0");
Database::query("UPDATE session SET session_category_id = NULL WHERE session_category_id = 0");
Database::query("ALTER TABLE session ADD CONSTRAINT FK_D044D5D4D1DC2CFC FOREIGN KEY (id_coach) REFERENCES user (id)");
Database::query("ALTER TABLE session ADD CONSTRAINT FK_D044D5D4EE1F8395 FOREIGN KEY (session_category_id) REFERENCES session_category (id)");
Database::query("ALTER TABLE session_rel_user ADD moved_status INT DEFAULT NULL, ADD moved_at DATETIME DEFAULT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE relation_type relation_type INT NOT NULL");
Database::query("ALTER TABLE session_rel_user ENGINE=InnoDB");
Database::query("ALTER TABLE session_rel_user ADD CONSTRAINT FK_B0D7D4C0613FECDF FOREIGN KEY (session_id) REFERENCES session (id)");
Database::query("ALTER TABLE session_rel_user ADD CONSTRAINT FK_B0D7D4C0A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
Database::query("CREATE INDEX IDX_B0D7D4C0613FECDF ON session_rel_user (session_id)");
Database::query("CREATE INDEX IDX_B0D7D4C0A76ED395 ON session_rel_user (user_id)");
Database::query("CREATE INDEX idx_session_rel_user_id_user_moved ON session_rel_user (user_id, moved_to)");
Database::query("ALTER TABLE sequence_rule CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE description description LONGTEXT NOT NULL");
Database::query("ALTER TABLE specific_field CHANGE code code VARCHAR(1) NOT NULL");
Database::query("ALTER TABLE sequence_type_entity CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT NOT NULL, CHANGE ent_table ent_table VARCHAR(255) NOT NULL");
Database::query("ALTER TABLE sequence_row_entity CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sequence_type_entity_id sequence_type_entity_id INT DEFAULT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE row_id row_id INT NOT NULL, CHANGE name name VARCHAR(255) NOT NULL");
Database::query("ALTER TABLE sequence_row_entity ADD CONSTRAINT FK_2779761FAED14944 FOREIGN KEY (sequence_type_entity_id) REFERENCES sequence_type_entity (id)");
Database::query("CREATE INDEX IDX_2779761FAED14944 ON sequence_row_entity (sequence_type_entity_id)");
Database::query("ALTER TABLE track_e_attempt_coeff CHANGE id id INT AUTO_INCREMENT NOT NULL");
Database::query("ALTER TABLE sequence_value CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE sequence_row_entity_id sequence_row_entity_id INT DEFAULT NULL, CHANGE advance advance DOUBLE PRECISION NOT NULL, CHANGE complete_items complete_items INT NOT NULL, CHANGE total_items total_items INT NOT NULL, CHANGE success success TINYINT(1) NOT NULL, CHANGE success_date success_date DATETIME DEFAULT NULL, CHANGE available available TINYINT(1) NOT NULL, CHANGE available_start_date available_start_date DATETIME DEFAULT NULL, CHANGE available_end_date available_end_date DATETIME DEFAULT NULL");
Database::query("ALTER TABLE sequence_value ADD CONSTRAINT FK_66FBF12D218736B2 FOREIGN KEY (sequence_row_entity_id) REFERENCES sequence_row_entity (id)");
Database::query("CREATE INDEX IDX_66FBF12D218736B2 ON sequence_value (sequence_row_entity_id)");
Database::query("ALTER TABLE notification CHANGE dest_mail dest_mail VARCHAR(255) DEFAULT NULL, CHANGE title title VARCHAR(255) DEFAULT NULL, CHANGE content content VARCHAR(255) DEFAULT NULL, CHANGE send_freq send_freq SMALLINT DEFAULT NULL");
Database::query("ALTER TABLE settings_current CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE title title VARCHAR(255) NOT NULL, CHANGE access_url access_url INT DEFAULT 1 NOT NULL, CHANGE access_url_changeable access_url_changeable INT NOT NULL");
Database::query("ALTER TABLE settings_current ENGINE=InnoDB");
Database::query("CREATE UNIQUE INDEX unique_setting ON settings_current (variable, subkey, access_url)");
Database::query("ALTER TABLE gradebook_evaluation CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE max max DOUBLE PRECISION NOT NULL, CHANGE type type VARCHAR(40) NOT NULL, CHANGE locked locked INT NOT NULL");
Database::query("ALTER TABLE track_e_attempt_recording CHANGE exe_id exe_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE insert_date insert_date DATETIME NOT NULL, CHANGE author author INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("ALTER TABLE shared_survey_question CHANGE survey_id survey_id INT NOT NULL, CHANGE type type VARCHAR(250) NOT NULL, CHANGE display display VARCHAR(10) NOT NULL, CHANGE sort sort INT NOT NULL, CHANGE code code VARCHAR(40) NOT NULL");
Database::query("ALTER TABLE user_friend_relation_type CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE title title VARCHAR(20) DEFAULT NULL");
Database::query("ALTER TABLE user_api_key CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE api_key api_key VARCHAR(32) NOT NULL, CHANGE api_service api_service VARCHAR(10) NOT NULL");
Database::query("ALTER TABLE sequence_variable CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(255) DEFAULT NULL, CHANGE default_val default_val VARCHAR(255) DEFAULT NULL");
Database::query("ALTER TABLE sequence_condition CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE description description LONGTEXT NOT NULL, CHANGE mat_op mat_op INT NOT NULL, CHANGE act_true act_true INT NOT NULL, CHANGE act_false act_false INT NOT NULL");
Database::query("ALTER TABLE course_module CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE row row INT NOT NULL, CHANGE `column` `column` INT NOT NULL, CHANGE position position VARCHAR(20) NOT NULL");
Database::query("ALTER TABLE course DROP db_name, CHANGE visibility visibility INT DEFAULT NULL, CHANGE show_score show_score INT DEFAULT NULL, CHANGE disk_quota disk_quota BIGINT DEFAULT NULL, CHANGE subscribe subscribe TINYINT(1) DEFAULT NULL, CHANGE unsubscribe unsubscribe TINYINT(1) DEFAULT NULL, CHANGE registration_code registration_code VARCHAR(255) DEFAULT NULL, CHANGE legal legal LONGTEXT DEFAULT NULL, CHANGE activate_legal activate_legal INT DEFAULT NULL, CHANGE course_type_id course_type_id INT DEFAULT NULL, CHANGE add_teachers_to_sessions_courses add_teachers_to_sessions_courses TINYINT(1) DEFAULT NULL");
Database::query("ALTER TABLE course ENGINE=InnoDB");
Database::query("ALTER TABLE course ADD CONSTRAINT FK_169E6FB954177093 FOREIGN KEY (room_id) REFERENCES room (id)");
Database::query("DROP INDEX code ON course");
Database::query("CREATE UNIQUE INDEX UNIQ_169E6FB977153098 ON course (code)");
Database::query("DROP INDEX idx_course_category_code ON course");
Database::query("CREATE INDEX category_code ON course (category_code)");
Database::query("DROP INDEX idx_course_directory ON course");
Database::query("CREATE INDEX directory ON course (directory)");
Database::query("DROP INDEX access_cours_code ON track_e_access");
Database::query("ALTER TABLE track_e_access DROP access_cours_code, CHANGE access_user_id access_user_id INT DEFAULT NULL, CHANGE access_date access_date DATETIME NOT NULL, CHANGE access_session_id access_session_id INT NOT NULL, CHANGE user_ip user_ip VARCHAR(39) NOT NULL");
Database::query("CREATE INDEX access_c_id ON track_e_access (c_id)");
Database::query("ALTER TABLE personal_agenda_repeat CHANGE cal_id cal_id INT AUTO_INCREMENT NOT NULL, CHANGE cal_frequency cal_frequency INT DEFAULT NULL, CHANGE cal_days cal_days VARCHAR(7) DEFAULT NULL");
Database::query("ALTER TABLE track_e_open CHANGE open_date open_date DATETIME NOT NULL");
Database::query("ALTER TABLE chat_video CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE from_user from_user INT NOT NULL, CHANGE to_user to_user INT NOT NULL");
Database::query("ALTER TABLE usergroup_rel_question CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE usergroup_id usergroup_id INT NOT NULL");
Database::query("ALTER TABLE track_e_default DROP default_cours_code, CHANGE default_user_id default_user_id INT NOT NULL, CHANGE default_date default_date DATETIME NOT NULL, CHANGE c_id c_id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON track_e_default (c_id)");
Database::query("CREATE INDEX session ON track_e_default (session_id)");
Database::query("ALTER TABLE class_user CHANGE class_id class_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("ALTER TABLE course_type CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE translation_var translation_var VARCHAR(40) DEFAULT NULL");
Database::query("ALTER TABLE access_url_rel_usergroup CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE access_url_id access_url_id INT NOT NULL, CHANGE usergroup_id usergroup_id INT NOT NULL");
Database::query("ALTER TABLE extra_field_values CHANGE field_id field_id INT DEFAULT NULL");
Database::query("ALTER TABLE extra_field_values ADD CONSTRAINT FK_171DF924443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id)");
Database::query("CREATE INDEX IDX_171DF924443707B0 ON extra_field_values (field_id)");
Database::query("ALTER TABLE course_rel_class CHANGE course_code course_code VARCHAR(40) NOT NULL, CHANGE class_id class_id INT NOT NULL");
Database::query("ALTER TABLE legal CHANGE legal_id legal_id INT NOT NULL, CHANGE date date INT NOT NULL");
Database::query("DROP INDEX exe_cours_id ON track_e_exercises");
Database::query("ALTER TABLE track_e_exercises DROP exe_cours_id, CHANGE exe_user_id exe_user_id INT DEFAULT NULL, CHANGE exe_date exe_date DATETIME NOT NULL, CHANGE exe_exo_id exe_exo_id INT NOT NULL, CHANGE exe_result exe_result DOUBLE PRECISION NOT NULL, CHANGE exe_weighting exe_weighting DOUBLE PRECISION NOT NULL, CHANGE status status VARCHAR(20) NOT NULL, CHANGE start_date start_date DATETIME NOT NULL, CHANGE steps_counter steps_counter SMALLINT NOT NULL, CHANGE session_id session_id SMALLINT NOT NULL, CHANGE orig_lp_id orig_lp_id INT NOT NULL, CHANGE orig_lp_item_id orig_lp_item_id INT NOT NULL, CHANGE exe_duration exe_duration INT NOT NULL, CHANGE expired_time_control expired_time_control DATETIME NOT NULL, CHANGE orig_lp_item_view_id orig_lp_item_view_id INT NOT NULL, CHANGE user_ip user_ip VARCHAR(39) NOT NULL");
Database::query("CREATE INDEX idx_tee_c_id ON track_e_exercises (c_id)");
Database::query("DROP INDEX exe_user_id ON track_e_exercises");
Database::query("CREATE INDEX idx_tee_user_id ON track_e_exercises (exe_user_id)");
Database::query("ALTER TABLE gradebook_result_log CHANGE created_at created_at DATETIME NOT NULL, CHANGE score score DOUBLE PRECISION DEFAULT NULL");
Database::query("ALTER TABLE sequence_method ADD act_false INT NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE description description LONGTEXT NOT NULL, CHANGE formula formula LONGTEXT NOT NULL, CHANGE assign assign INT NOT NULL, CHANGE met_type met_type INT NOT NULL");
Database::query("DROP INDEX exe_cours_id ON track_e_hotpotatoes");
Database::query("ALTER TABLE track_e_hotpotatoes DROP exe_cours_id, CHANGE exe_user_id exe_user_id INT DEFAULT NULL, CHANGE exe_date exe_date DATETIME NOT NULL, CHANGE exe_result exe_result SMALLINT NOT NULL, CHANGE exe_weighting exe_weighting SMALLINT NOT NULL");
Database::query("CREATE INDEX idx_tehp_c_id ON track_e_hotpotatoes (c_id)");
Database::query("DROP INDEX exe_user_id ON track_e_hotpotatoes");
Database::query("CREATE INDEX idx_tehp_user_id ON track_e_hotpotatoes (exe_user_id)");
Database::query("ALTER TABLE usergroup ENGINE=InnoDB");
Database::query("ALTER TABLE usergroup_rel_user CHANGE usergroup_id usergroup_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE relation_type relation_type INT NOT NULL");
Database::query("ALTER TABLE usergroup_rel_user ENGINE=InnoDB");
Database::query("ALTER TABLE usergroup_rel_user ADD CONSTRAINT FK_739515A9A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
Database::query("ALTER TABLE usergroup_rel_user ADD CONSTRAINT FK_739515A9D2112630 FOREIGN KEY (usergroup_id) REFERENCES usergroup (id)");
Database::query("CREATE INDEX IDX_739515A9A76ED395 ON usergroup_rel_user (user_id)");
Database::query("CREATE INDEX IDX_739515A9D2112630 ON usergroup_rel_user (usergroup_id)");
Database::query("ALTER TABLE track_e_login CHANGE login_user_id login_user_id INT NOT NULL, CHANGE login_date login_date DATETIME NOT NULL, CHANGE user_ip user_ip VARCHAR(39) NOT NULL");
Database::query("ALTER TABLE gradebook_linkeval_log CHANGE created_at created_at DATETIME NOT NULL");
Database::query("ALTER TABLE skill_rel_user CHANGE course_id course_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE acquired_skill_at acquired_skill_at DATETIME NOT NULL");
Database::query("ALTER TABLE hook_event CHANGE id id INT AUTO_INCREMENT NOT NULL");
Database::query("ALTER TABLE access_url_rel_course DROP PRIMARY KEY");
Database::query("ALTER TABLE access_url_rel_course ADD id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, DROP course_code, CHANGE access_url_id access_url_id INT DEFAULT NULL");
Database::query("ALTER TABLE access_url_rel_course ENGINE=InnoDB");
Database::query("ALTER TABLE access_url_rel_course ADD CONSTRAINT FK_8E97FC0891D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)");
Database::query("ALTER TABLE access_url_rel_course ADD CONSTRAINT FK_8E97FC0873444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)");
Database::query("CREATE INDEX IDX_8E97FC0891D79BD3 ON access_url_rel_course (c_id)");
Database::query("CREATE INDEX IDX_8E97FC0873444FD5 ON access_url_rel_course (access_url_id)");
Database::query("ALTER TABLE user_course_category CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("ALTER TABLE gradebook_result CHANGE created_at created_at DATETIME NOT NULL, CHANGE score score DOUBLE PRECISION DEFAULT NULL");
Database::query("ALTER TABLE track_course_ranking CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE url_id url_id INT NOT NULL, CHANGE accesses accesses INT NOT NULL, CHANGE total_score total_score INT NOT NULL, CHANGE users users INT NOT NULL");
Database::query("ALTER TABLE course_category CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(100) NOT NULL, CHANGE code code VARCHAR(40) NOT NULL, CHANGE tree_pos tree_pos INT DEFAULT NULL, CHANGE auth_course_child auth_course_child VARCHAR(40) DEFAULT NULL, CHANGE auth_cat_child auth_cat_child VARCHAR(40) DEFAULT NULL");
Database::query("ALTER TABLE gradebook_score_display CHANGE score score DOUBLE PRECISION NOT NULL, CHANGE category_id category_id INT NOT NULL, CHANGE score_color_percent score_color_percent DOUBLE PRECISION NOT NULL");
Database::query("ALTER TABLE track_e_uploads ADD c_id INT DEFAULT NULL, CHANGE upload_user_id upload_user_id INT DEFAULT NULL, CHANGE upload_date upload_date DATETIME NOT NULL, CHANGE upload_cours_id upload_cours_id VARCHAR(40) NOT NULL, CHANGE upload_work_id upload_work_id INT NOT NULL, CHANGE upload_session_id upload_session_id INT NOT NULL");
Database::query("CREATE INDEX course ON track_e_uploads (c_id)");
Database::query("ALTER TABLE gradebook_certificate CHANGE id id BIGINT AUTO_INCREMENT NOT NULL, CHANGE cat_id cat_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE score_certificate score_certificate DOUBLE PRECISION NOT NULL, CHANGE created_at created_at DATETIME NOT NULL");
Database::query("ALTER TABLE personal_agenda CHANGE user user INT DEFAULT NULL, CHANGE all_day all_day INT NOT NULL");
Database::query("ALTER TABLE access_url_rel_session CHANGE access_url_id access_url_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("ALTER TABLE career CHANGE status status INT NOT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL");
Database::query("DROP INDEX course_code ON track_e_course_access");
Database::query("ALTER TABLE track_e_course_access DROP course_code, CHANGE login_course_date login_course_date DATETIME NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE user_ip user_ip VARCHAR(39) NOT NULL");
Database::query("CREATE INDEX course ON track_e_course_access (c_id)");
Database::query("ALTER TABLE chat CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sent sent DATETIME NOT NULL, CHANGE recd recd INT NOT NULL");
Database::query("DROP INDEX course_code ON session_rel_course");
Database::query("ALTER TABLE session_rel_course DROP PRIMARY KEY");
Database::query("ALTER TABLE session_rel_course ADD id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, DROP course_code, DROP category, CHANGE session_id session_id INT NOT NULL, CHANGE nbr_users nbr_users INT NOT NULL, CHANGE position position INT NOT NULL, CHANGE c_id c_id INT NOT NULL");
Database::query("ALTER TABLE session_rel_course ENGINE=InnoDB");
Database::query("ALTER TABLE session_rel_course ADD CONSTRAINT FK_12D110D3613FECDF FOREIGN KEY (session_id) REFERENCES session (id)");
Database::query("ALTER TABLE session_rel_course ADD CONSTRAINT FK_12D110D391D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)");
Database::query("CREATE INDEX IDX_12D110D3613FECDF ON session_rel_course (session_id)");
Database::query("CREATE INDEX idx_session_rel_course_course_id ON session_rel_course (c_id)");
Database::query("DROP INDEX id ON settings_options");
Database::query("ALTER TABLE settings_options CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE display_text display_text VARCHAR(255) NOT NULL");
Database::query("ALTER TABLE settings_options ENGINE=InnoDB");
Database::query("CREATE UNIQUE INDEX unique_setting_option ON settings_options (variable, value)");
Database::query("ALTER TABLE sys_calendar CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE start_date start_date DATETIME NOT NULL, CHANGE end_date end_date DATETIME NOT NULL, CHANGE access_url_id access_url_id INT NOT NULL, CHANGE all_day all_day INT NOT NULL");
Database::query("ALTER TABLE user_rel_course_vote CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE url_id url_id INT NOT NULL, CHANGE vote vote INT NOT NULL");
Database::query("ALTER TABLE hook_call CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE hook_event_id hook_event_id INT NOT NULL, CHANGE hook_observer_id hook_observer_id INT NOT NULL, CHANGE hook_order hook_order INT NOT NULL");
Database::query("ALTER TABLE message_attachment CHANGE size size INT NOT NULL");
Database::query("ALTER TABLE extra_field_rel_tag CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE field_id field_id INT NOT NULL, CHANGE item_id item_id INT NOT NULL, CHANGE tag_id tag_id INT NOT NULL");
Database::query("DROP INDEX idx_frt_field ON extra_field_rel_tag");
Database::query("CREATE INDEX field ON extra_field_rel_tag (field_id)");
Database::query("DROP INDEX idx_frt_item ON extra_field_rel_tag");
Database::query("CREATE INDEX item ON extra_field_rel_tag (item_id)");
Database::query("DROP INDEX idx_frt_tag ON extra_field_rel_tag");
Database::query("CREATE INDEX tag ON extra_field_rel_tag (tag_id)");
Database::query("DROP INDEX idx_frt_field_item_tag ON extra_field_rel_tag");
Database::query("CREATE INDEX field_item_tag ON extra_field_rel_tag (field_id, item_id, tag_id)");
Database::query("ALTER TABLE access_url_rel_user CHANGE access_url_id access_url_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("ALTER TABLE access_url_rel_user ENGINE=InnoDB");
Database::query("ALTER TABLE access_url_rel_user ADD CONSTRAINT FK_85574263A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
Database::query("ALTER TABLE access_url_rel_user ADD CONSTRAINT FK_8557426373444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id)");
Database::query("ALTER TABLE track_e_item_property CHANGE progress progress INT NOT NULL, CHANGE lastedit_date lastedit_date DATETIME NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("ALTER TABLE promotion CHANGE status status INT NOT NULL, CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL");
Database::query("ALTER TABLE shared_survey_question_option CHANGE question_id question_id INT NOT NULL, CHANGE survey_id survey_id INT NOT NULL, CHANGE sort sort INT NOT NULL");
Database::query("ALTER TABLE block CHANGE active active TINYINT(1) NOT NULL");
Database::query("ALTER TABLE sequence_rule_condition CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sequence_rule_id sequence_rule_id INT DEFAULT NULL, CHANGE sequence_condition_id sequence_condition_id INT DEFAULT NULL");
Database::query("ALTER TABLE sequence_rule_condition ADD CONSTRAINT FK_F948EE6A4044CA89 FOREIGN KEY (sequence_rule_id) REFERENCES sequence_rule (id)");
Database::query("ALTER TABLE sequence_rule_condition ADD CONSTRAINT FK_F948EE6A8C0A7083 FOREIGN KEY (sequence_condition_id) REFERENCES sequence_condition (id)");
Database::query("CREATE INDEX IDX_F948EE6A4044CA89 ON sequence_rule_condition (sequence_rule_id)");
Database::query("CREATE INDEX IDX_F948EE6A8C0A7083 ON sequence_rule_condition (sequence_condition_id)");
Database::query("CREATE INDEX IDX_D044D5D4EE1F8395 ON session (session_category_id)");
Database::query("CREATE INDEX idx_id_coach ON session (id_coach)");
Database::query("DROP INDEX session_admin_id ON session");
Database::query("CREATE INDEX idx_id_session_admin_id ON session (session_admin_id)");
Database::query("ALTER TABLE track_e_hotspot ADD c_id INT DEFAULT NULL, CHANGE hotspot_correct hotspot_correct TINYINT(1) NOT NULL");
Database::query("ALTER TABLE system_template CHANGE id id INT AUTO_INCREMENT NOT NULL");
Database::query("ALTER TABLE track_e_attempt CHANGE user_id user_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE marks marks DOUBLE PRECISION NOT NULL, CHANGE course_code course_code VARCHAR(40) NOT NULL, CHANGE position position INT DEFAULT NULL, CHANGE tms tms DATETIME NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON track_e_attempt (c_id)");
Database::query("ALTER TABLE sequence_rule_method CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sequence_rule_id sequence_rule_id INT DEFAULT NULL, CHANGE sequence_method_id sequence_method_id INT DEFAULT NULL, CHANGE method_order method_order INT NOT NULL");
Database::query("ALTER TABLE sequence_rule_method ADD CONSTRAINT FK_6336EA764044CA89 FOREIGN KEY (sequence_rule_id) REFERENCES sequence_rule (id)");
Database::query("ALTER TABLE sequence_rule_method ADD CONSTRAINT FK_6336EA76B2D1386E FOREIGN KEY (sequence_method_id) REFERENCES sequence_method (id)");
Database::query("CREATE INDEX IDX_6336EA764044CA89 ON sequence_rule_method (sequence_rule_id)");
Database::query("CREATE INDEX IDX_6336EA76B2D1386E ON sequence_rule_method (sequence_method_id)");
Database::query("DROP INDEX links_cours_id ON track_e_links");
Database::query("ALTER TABLE track_e_links DROP links_cours_id, CHANGE links_user_id links_user_id INT DEFAULT NULL, CHANGE links_date links_date DATETIME NOT NULL, CHANGE links_link_id links_link_id INT NOT NULL, CHANGE links_session_id links_session_id INT NOT NULL");
Database::query("CREATE INDEX idx_tel_c_id ON track_e_links (c_id)");
Database::query("DROP INDEX links_user_id ON track_e_links");
Database::query("CREATE INDEX idx_tel_user_id ON track_e_links (links_user_id)");
Database::query("ALTER TABLE sequence_formula CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sequence_method_id sequence_method_id INT DEFAULT NULL, CHANGE sequence_variable_id sequence_variable_id INT DEFAULT NULL");
Database::query("ALTER TABLE sequence_formula ADD CONSTRAINT FK_533B9159B2D1386E FOREIGN KEY (sequence_method_id) REFERENCES sequence_method (id)");
Database::query("ALTER TABLE sequence_formula ADD CONSTRAINT FK_533B915955C65E08 FOREIGN KEY (sequence_variable_id) REFERENCES sequence_variable (id)");
Database::query("CREATE INDEX IDX_533B9159B2D1386E ON sequence_formula (sequence_method_id)");
Database::query("CREATE INDEX IDX_533B915955C65E08 ON sequence_formula (sequence_variable_id)");
Database::query("ALTER TABLE tag CHANGE tag tag VARCHAR(255) NOT NULL");
Database::query("DROP INDEX course ON track_e_online");
Database::query("ALTER TABLE track_e_online DROP course, CHANGE login_user_id login_user_id INT NOT NULL, CHANGE login_date login_date DATETIME NOT NULL, CHANGE user_ip user_ip VARCHAR(39) NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE access_url_id access_url_id INT NOT NULL");
Database::query("CREATE INDEX course ON track_e_online (c_id)");
Database::query("ALTER TABLE shared_survey CHANGE survey_id survey_id INT AUTO_INCREMENT NOT NULL, CHANGE creation_date creation_date DATETIME NOT NULL, CHANGE course_code course_code VARCHAR(40) NOT NULL");
Database::query("ALTER TABLE course_request CHANGE user_id user_id INT NOT NULL, CHANGE request_date request_date DATETIME NOT NULL, CHANGE status status INT NOT NULL, CHANGE info info INT NOT NULL, CHANGE exemplary_content exemplary_content INT NOT NULL");
Database::query("DROP INDEX course_code ON session_rel_course_rel_user");
Database::query("ALTER TABLE session_rel_course_rel_user DROP PRIMARY KEY");
Database::query("ALTER TABLE session_rel_course_rel_user ADD id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, DROP course_code, CHANGE session_id session_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE visibility visibility INT NOT NULL, CHANGE status status INT NOT NULL, CHANGE legal_agreement legal_agreement INT DEFAULT NULL, CHANGE c_id c_id INT NOT NULL");
Database::query("ALTER TABLE session_rel_course_rel_user ENGINE=InnoDB");
Database::query("ALTER TABLE session_rel_course_rel_user ADD CONSTRAINT FK_720167EA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
Database::query("ALTER TABLE session_rel_course_rel_user ADD CONSTRAINT FK_720167E613FECDF FOREIGN KEY (session_id) REFERENCES session (id)");
Database::query("ALTER TABLE session_rel_course_rel_user ADD CONSTRAINT FK_720167E91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)");
Database::query("CREATE INDEX IDX_720167E613FECDF ON session_rel_course_rel_user (session_id)");
Database::query("CREATE INDEX idx_session_rel_course_rel_user_course_id ON session_rel_course_rel_user (c_id)");
//Database::query("DROP INDEX id_user ON session_rel_course_rel_user");
//Database::query("CREATE INDEX idx_session_rel_course_rel_user_id_user ON session_rel_course_rel_user (user_id)");
Database::query("ALTER TABLE sys_announcement CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE date_start date_start DATETIME NOT NULL, CHANGE date_end date_end DATETIME NOT NULL, CHANGE visible_teacher visible_teacher TINYINT(1) NOT NULL, CHANGE visible_student visible_student TINYINT(1) NOT NULL, CHANGE visible_guest visible_guest TINYINT(1) NOT NULL, CHANGE title title VARCHAR(250) NOT NULL, CHANGE access_url_id access_url_id INT NOT NULL");
Database::query("ALTER TABLE user_rel_user CHANGE id id BIGINT AUTO_INCREMENT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE friend_user_id friend_user_id INT NOT NULL, CHANGE relation_type relation_type INT NOT NULL");
Database::query("ALTER TABLE gradebook_score_log CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE category_id category_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("DROP INDEX down_cours_id ON track_e_downloads");
Database::query("ALTER TABLE track_e_downloads DROP down_cours_id, CHANGE down_user_id down_user_id INT DEFAULT NULL, CHANGE down_date down_date DATETIME NOT NULL, CHANGE down_doc_path down_doc_path VARCHAR(255) NOT NULL, CHANGE down_session_id down_session_id INT NOT NULL");
Database::query("CREATE INDEX idx_ted_c_id ON track_e_downloads (c_id)");
Database::query("DROP INDEX down_user_id ON track_e_downloads");
Database::query("CREATE INDEX idx_ted_user_id ON track_e_downloads (down_user_id)");
Database::query("ALTER TABLE sequence_valid CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sequence_variable_id sequence_variable_id INT DEFAULT NULL, CHANGE sequence_condition_id sequence_condition_id INT DEFAULT NULL");
Database::query("ALTER TABLE sequence_valid ADD CONSTRAINT FK_F78B9CE655C65E08 FOREIGN KEY (sequence_variable_id) REFERENCES sequence_variable (id)");
Database::query("ALTER TABLE sequence_valid ADD CONSTRAINT FK_F78B9CE68C0A7083 FOREIGN KEY (sequence_condition_id) REFERENCES sequence_condition (id)");
Database::query("CREATE INDEX IDX_F78B9CE655C65E08 ON sequence_valid (sequence_variable_id)");
Database::query("CREATE INDEX IDX_F78B9CE68C0A7083 ON sequence_valid (sequence_condition_id)");
Database::query("ALTER TABLE language CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE available available TINYINT(1) NOT NULL, CHANGE parent_id parent_id TINYINT(1) DEFAULT NULL");
Database::query("ALTER TABLE track_stored_values_stack CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE course_id course_id VARCHAR(40) NOT NULL, CHANGE sv_key sv_key VARCHAR(64) NOT NULL");
Database::query("DROP INDEX user_id ON track_stored_values_stack");
Database::query("CREATE INDEX user_sco_course_sv_stack ON track_stored_values_stack (user_id, sco_id, course_id, sv_key, stack_order)");
Database::query("ALTER TABLE track_stored_values CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE course_id course_id VARCHAR(40) NOT NULL, CHANGE sv_key sv_key VARCHAR(64) NOT NULL");
Database::query("DROP INDEX user_id ON track_stored_values");
Database::query("CREATE INDEX user_sco_course_sv ON track_stored_values (user_id, sco_id, course_id, sv_key)");
Database::query("ALTER TABLE hook_observer CHANGE id id INT AUTO_INCREMENT NOT NULL");
Database::query("ALTER TABLE admin CHANGE user_id user_id INT NOT NULL");
Database::query("ALTER TABLE gradebook_link CHANGE created_at created_at DATETIME NOT NULL, CHANGE locked locked INT NOT NULL");
Database::query("ALTER TABLE message CHANGE id id BIGINT AUTO_INCREMENT NOT NULL, CHANGE user_sender_id user_sender_id INT NOT NULL, CHANGE user_receiver_id user_receiver_id INT NOT NULL, CHANGE msg_status msg_status TINYINT(1) NOT NULL, CHANGE send_date send_date DATETIME NOT NULL, CHANGE group_id group_id INT NOT NULL, CHANGE parent_id parent_id INT NOT NULL, CHANGE update_date update_date DATETIME NOT NULL");
Database::query("ALTER TABLE gradebook_category CHANGE document_id document_id INT DEFAULT NULL, CHANGE locked locked INT NOT NULL, CHANGE grade_model_id grade_model_id INT DEFAULT NULL, CHANGE generate_certificates generate_certificates TINYINT(1) NOT NULL");
Database::query("ALTER TABLE event_email_template CHANGE activated activated TINYINT(1) NOT NULL");
Database::query("ALTER TABLE course_rel_user DROP PRIMARY KEY");
Database::query("ALTER TABLE course_rel_user ADD id INT AUTO_INCREMENT NOT NULL PRIMARY KEY, DROP course_code, DROP role, DROP group_id, CHANGE user_id user_id INT DEFAULT NULL, CHANGE relation_type relation_type INT NOT NULL, CHANGE status status INT NOT NULL, CHANGE is_tutor is_tutor TINYINT(1) DEFAULT NULL, CHANGE user_course_cat user_course_cat INT DEFAULT NULL, CHANGE legal_agreement legal_agreement INT DEFAULT NULL");
Database::query("ALTER TABLE course_rel_user ENGINE=InnoDB");
Database::query("ALTER TABLE course_rel_user ADD CONSTRAINT FK_92CFD9FEA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
Database::query("ALTER TABLE course_rel_user ADD CONSTRAINT FK_92CFD9FE91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)");
Database::query("CREATE INDEX IDX_92CFD9FE91D79BD3 ON course_rel_user (c_id)");
//Database::query("DROP INDEX user_id ON course_rel_user");
//Database::query("CREATE INDEX IDX_92CFD9FEA76ED395 ON course_rel_user (user_id)");
Database::query("ALTER TABLE c_wiki_discuss CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE publication_id publication_id INT NOT NULL, CHANGE userc_id userc_id INT NOT NULL, CHANGE dtime dtime DATETIME NOT NULL");
Database::query("CREATE INDEX course ON c_wiki_discuss (c_id)");
Database::query("ALTER TABLE c_quiz_question CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE ponderation ponderation DOUBLE PRECISION NOT NULL, CHANGE position position INT NOT NULL, CHANGE type type TINYINT(1) NOT NULL, CHANGE level level INT NOT NULL, CHANGE question_code question_code VARCHAR(10) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_quiz_question (c_id)");
Database::query("ALTER TABLE c_forum_thread CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE thread_id thread_id INT NOT NULL, CHANGE forum_id forum_id INT DEFAULT NULL, CHANGE thread_poster_name thread_poster_name VARCHAR(100) DEFAULT NULL, CHANGE thread_date thread_date DATETIME DEFAULT NULL, CHANGE thread_sticky thread_sticky TINYINT(1) DEFAULT NULL, CHANGE locked locked INT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE thread_title_qualify thread_title_qualify VARCHAR(255) DEFAULT NULL, CHANGE thread_qualify_max thread_qualify_max DOUBLE PRECISION NOT NULL, CHANGE thread_close_date thread_close_date DATETIME DEFAULT NULL, CHANGE thread_weight thread_weight DOUBLE PRECISION NOT NULL, CHANGE thread_peer_qualify thread_peer_qualify TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_forum_thread (c_id)");
Database::query("ALTER TABLE c_dropbox_person CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE file_id file_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_dropbox_person (c_id)");
Database::query("CREATE INDEX user ON c_dropbox_person (user_id)");
Database::query("ALTER TABLE c_announcement_attachment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE size size INT NOT NULL");
Database::query("CREATE INDEX course ON c_announcement_attachment (c_id)");
Database::query("ALTER TABLE c_online_link CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE name name VARCHAR(50) NOT NULL, CHANGE url url VARCHAR(100) NOT NULL");
Database::query("CREATE INDEX course ON c_online_link (c_id)");
Database::query("ALTER TABLE c_forum_mailcue CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE thread_id thread_id INT NOT NULL, CHANGE post_id post_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_forum_mailcue (c_id)");
Database::query("CREATE INDEX thread ON c_forum_mailcue (thread_id)");
Database::query("CREATE INDEX user ON c_forum_mailcue (user_id)");
Database::query("CREATE INDEX post ON c_forum_mailcue (post_id)");
Database::query("ALTER TABLE c_role CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE role_id role_id INT NOT NULL, CHANGE role_name role_name VARCHAR(250) NOT NULL, CHANGE default_role default_role TINYINT(1) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_role (c_id)");
Database::query("ALTER TABLE c_dropbox_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE cat_id cat_id INT NOT NULL, CHANGE received received TINYINT(1) NOT NULL, CHANGE sent sent TINYINT(1) NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_dropbox_category (c_id)");
Database::query("ALTER TABLE c_group_rel_user CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE group_id group_id INT NOT NULL, CHANGE status status INT NOT NULL, CHANGE role role VARCHAR(50) NOT NULL");
Database::query("CREATE INDEX course ON c_group_rel_user (c_id)");
Database::query("ALTER TABLE c_notebook CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE notebook_id notebook_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE creation_date creation_date DATETIME NOT NULL, CHANGE update_date update_date DATETIME NOT NULL");
Database::query("CREATE INDEX course ON c_notebook (c_id)");
Database::query("ALTER TABLE c_group_rel_tutor CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE group_id group_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_group_rel_tutor (c_id)");
Database::query("ALTER TABLE c_document CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE path path VARCHAR(255) NOT NULL, CHANGE filetype filetype VARCHAR(10) NOT NULL, CHANGE size size INT NOT NULL, CHANGE readonly readonly TINYINT(1) NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_document (c_id)");
Database::query("ALTER TABLE c_lp_item CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE lp_id lp_id INT NOT NULL, CHANGE item_type item_type VARCHAR(32) NOT NULL, CHANGE description description VARCHAR(511) DEFAULT NULL, CHANGE min_score min_score DOUBLE PRECISION NOT NULL, CHANGE max_score max_score DOUBLE PRECISION DEFAULT '100', CHANGE mastery_score mastery_score DOUBLE PRECISION DEFAULT NULL, CHANGE parent_item_id parent_item_id INT NOT NULL, CHANGE previous_item_id previous_item_id INT NOT NULL, CHANGE next_item_id next_item_id INT NOT NULL, CHANGE display_order display_order INT NOT NULL, CHANGE max_time_allowed max_time_allowed VARCHAR(13) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_lp_item (c_id)");
Database::query("ALTER TABLE c_forum_thread_qualify CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE qualify qualify DOUBLE PRECISION NOT NULL, CHANGE qualify_time qualify_time DATETIME DEFAULT NULL");
Database::query("CREATE INDEX course ON c_forum_thread_qualify (c_id)");
Database::query("ALTER TABLE c_blog_comment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE comment_id comment_id INT NOT NULL, CHANGE title title VARCHAR(250) NOT NULL, CHANGE author_id author_id INT NOT NULL, CHANGE date_creation date_creation DATETIME NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE post_id post_id INT NOT NULL, CHANGE parent_comment_id parent_comment_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_blog_comment (c_id)");
Database::query("ALTER TABLE c_lp_iv_interaction CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE order_id order_id INT NOT NULL, CHANGE lp_iv_id lp_iv_id BIGINT NOT NULL, CHANGE interaction_id interaction_id VARCHAR(255) NOT NULL, CHANGE interaction_type interaction_type VARCHAR(255) NOT NULL, CHANGE weighting weighting DOUBLE PRECISION NOT NULL, CHANGE completion_time completion_time VARCHAR(16) NOT NULL, CHANGE result result VARCHAR(255) NOT NULL, CHANGE latency latency VARCHAR(16) NOT NULL");
Database::query("CREATE INDEX course ON c_lp_iv_interaction (c_id)");
Database::query("ALTER TABLE c_thematic_plan CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_thematic_plan (c_id)");
Database::query("ALTER TABLE c_resource CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE source_id source_id INT DEFAULT NULL, CHANGE resource_id resource_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_resource (c_id)");
Database::query("ALTER TABLE c_blog_rel_user CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_blog_rel_user (c_id)");
Database::query("ALTER TABLE c_permission_user CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE tool tool VARCHAR(250) NOT NULL, CHANGE action action VARCHAR(250) NOT NULL");
Database::query("CREATE INDEX course ON c_permission_user (c_id)");
Database::query("ALTER TABLE c_wiki_conf CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE page_id page_id INT NOT NULL, CHANGE startdate_assig startdate_assig DATETIME NOT NULL, CHANGE enddate_assig enddate_assig DATETIME NOT NULL, CHANGE delayedsubmit delayedsubmit INT NOT NULL");
Database::query("CREATE INDEX course ON c_wiki_conf (c_id)");
Database::query("ALTER TABLE c_survey_group CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE survey_id survey_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_survey_group (c_id)");
Database::query("ALTER TABLE c_lp CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE lp_type lp_type INT NOT NULL, CHANGE force_commit force_commit TINYINT(1) NOT NULL, CHANGE default_view_mod default_view_mod VARCHAR(32) DEFAULT 'embedded' NOT NULL, CHANGE default_encoding default_encoding VARCHAR(32) DEFAULT 'UTF-8' NOT NULL, CHANGE display_order display_order INT DEFAULT 0 NOT NULL, CHANGE prevent_reinit prevent_reinit TINYINT(1) DEFAULT '1' NOT NULL, CHANGE debug debug TINYINT(1) NOT NULL, CHANGE theme theme VARCHAR(255) NOT NULL, CHANGE preview_image preview_image VARCHAR(255) NOT NULL, CHANGE author author VARCHAR(255) NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE prerequisite prerequisite INT NOT NULL, CHANGE hide_toc_frame hide_toc_frame TINYINT(1) NOT NULL, CHANGE seriousgame_mode seriousgame_mode TINYINT(1) NOT NULL, CHANGE use_max_score use_max_score INT DEFAULT 1 NOT NULL, CHANGE autolaunch autolaunch INT NOT NULL, CHANGE created_on created_on DATETIME NOT NULL, CHANGE modified_on modified_on DATETIME NOT NULL, CHANGE publicated_on publicated_on DATETIME NOT NULL, CHANGE expired_on expired_on DATETIME NOT NULL, CHANGE category_id category_id INT NOT NULL, CHANGE subscribe_users subscribe_users INT NOT NULL");
Database::query("CREATE INDEX course ON c_lp (c_id)");
Database::query("ALTER TABLE c_blog CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE blog_name blog_name VARCHAR(250) NOT NULL, CHANGE date_creation date_creation DATETIME NOT NULL, CHANGE visibility visibility TINYINT(1) NOT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_blog (c_id)");
Database::query("ALTER TABLE c_student_publication_rel_user ADD iid INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (iid)");
Database::query("CREATE INDEX course ON c_student_publication_rel_user (c_id)");
Database::query("CREATE INDEX work ON c_student_publication_rel_user (work_id)");
Database::query("CREATE INDEX user ON c_student_publication_rel_user (user_id)");
Database::query("ALTER TABLE c_announcement CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE display_order display_order INT NOT NULL, CHANGE email_sent email_sent TINYINT(1) DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_announcement (c_id)");
Database::query("ALTER TABLE c_chat_connected CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE last_connection last_connection DATETIME NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE to_group_id to_group_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_chat_connected (c_id)");
Database::query("CREATE INDEX user ON c_chat_connected (user_id)");
Database::query("ALTER TABLE c_thematic CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE display_order display_order INT NOT NULL, CHANGE active active TINYINT(1) NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_thematic (c_id)");
Database::query("ALTER TABLE c_calendar_event_repeat CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE cal_id cal_id INT NOT NULL, CHANGE cal_frequency cal_frequency INT DEFAULT NULL, CHANGE cal_days cal_days VARCHAR(7) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_calendar_event_repeat (c_id)");
Database::query("ALTER TABLE c_permission_task CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE task_id task_id INT NOT NULL, CHANGE tool tool VARCHAR(250) NOT NULL, CHANGE action action VARCHAR(250) NOT NULL");
Database::query("CREATE INDEX course ON c_permission_task (c_id)");
Database::query("ALTER TABLE c_attendance_sheet_log CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT NOT NULL, CHANGE lastedit_date lastedit_date DATETIME NOT NULL, CHANGE lastedit_user_id lastedit_user_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_attendance_sheet_log (c_id)");
Database::query("ALTER TABLE c_quiz CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE type type TINYINT(1) NOT NULL, CHANGE random random INT NOT NULL, CHANGE random_answers random_answers TINYINT(1) NOT NULL, CHANGE active active TINYINT(1) NOT NULL, CHANGE results_disabled results_disabled INT NOT NULL, CHANGE max_attempt max_attempt INT NOT NULL, CHANGE start_time start_time DATETIME NOT NULL, CHANGE end_time end_time DATETIME NOT NULL, CHANGE feedback_type feedback_type INT NOT NULL, CHANGE expired_time expired_time INT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE propagate_neg propagate_neg INT NOT NULL, CHANGE review_answers review_answers INT NOT NULL, CHANGE random_by_category random_by_category INT NOT NULL, CHANGE display_category_name display_category_name INT NOT NULL");
Database::query("CREATE INDEX course ON c_quiz (c_id)");
Database::query("ALTER TABLE c_permission_group CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE group_id group_id INT NOT NULL, CHANGE tool tool VARCHAR(250) NOT NULL, CHANGE action action VARCHAR(250) NOT NULL");
Database::query("CREATE INDEX course ON c_permission_group (c_id)");
Database::query("ALTER TABLE c_calendar_event_attachment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE size size INT NOT NULL");
Database::query("CREATE INDEX course ON c_calendar_event_attachment (c_id)");
Database::query("ALTER TABLE c_blog_rating CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE rating_id rating_id INT NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE rating_type rating_type VARCHAR(40) NOT NULL, CHANGE item_id item_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE rating rating INT NOT NULL");
Database::query("CREATE INDEX course ON c_blog_rating (c_id)");
Database::query("ALTER TABLE c_item_property CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE tool tool VARCHAR(100) NOT NULL, CHANGE insert_date insert_date DATETIME NOT NULL, CHANGE lastedit_date lastedit_date DATETIME NOT NULL, CHANGE ref ref INT NOT NULL, CHANGE lastedit_type lastedit_type VARCHAR(100) NOT NULL, CHANGE lastedit_user_id lastedit_user_id INT NOT NULL, CHANGE to_group_id to_group_id INT DEFAULT NULL, CHANGE to_user_id to_user_id INT DEFAULT NULL, CHANGE visibility visibility TINYINT(1) NOT NULL");
Database::query("ALTER TABLE c_item_property ENGINE=InnoDB");
Database::query("ALTER TABLE c_group_info CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE category_id category_id INT NOT NULL, CHANGE max_student max_student INT NOT NULL, CHANGE doc_state doc_state TINYINT(1) NOT NULL, CHANGE calendar_state calendar_state TINYINT(1) NOT NULL, CHANGE work_state work_state TINYINT(1) NOT NULL, CHANGE announcements_state announcements_state TINYINT(1) NOT NULL, CHANGE forum_state forum_state TINYINT(1) NOT NULL, CHANGE wiki_state wiki_state TINYINT(1) NOT NULL, CHANGE chat_state chat_state TINYINT(1) NOT NULL, CHANGE self_registration_allowed self_registration_allowed TINYINT(1) NOT NULL, CHANGE self_unregistration_allowed self_unregistration_allowed TINYINT(1) NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE status status TINYINT(1) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_group_info (c_id)");
Database::query("ALTER TABLE c_group_info ENGINE=InnoDB");
Database::query("ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18191D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)");
Database::query("ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181330D47E9 FOREIGN KEY (to_group_id) REFERENCES c_group_info (iid)");
Database::query("ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C18129F6EE60 FOREIGN KEY (to_user_id) REFERENCES user (id)");
Database::query("ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C1819C859CC3 FOREIGN KEY (insert_user_id) REFERENCES user (id)");
Database::query("ALTER TABLE c_item_property ADD CONSTRAINT FK_1D84C181613FECDF FOREIGN KEY (session_id) REFERENCES session (id)");
Database::query("ALTER TABLE c_link_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE display_order display_order INT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_link_category (c_id)");
Database::query("ALTER TABLE c_group_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE title title VARCHAR(255) NOT NULL, CHANGE doc_state doc_state TINYINT(1) NOT NULL, CHANGE calendar_state calendar_state TINYINT(1) NOT NULL, CHANGE work_state work_state TINYINT(1) NOT NULL, CHANGE announcements_state announcements_state TINYINT(1) NOT NULL, CHANGE forum_state forum_state TINYINT(1) NOT NULL, CHANGE wiki_state wiki_state TINYINT(1) NOT NULL, CHANGE chat_state chat_state TINYINT(1) NOT NULL, CHANGE max_student max_student INT NOT NULL, CHANGE self_reg_allowed self_reg_allowed TINYINT(1) NOT NULL, CHANGE self_unreg_allowed self_unreg_allowed TINYINT(1) NOT NULL, CHANGE groups_per_user groups_per_user INT NOT NULL, CHANGE display_order display_order INT NOT NULL");
Database::query("CREATE INDEX course ON c_group_category (c_id)");
Database::query("ALTER TABLE c_lp_item_view CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE lp_item_id lp_item_id INT NOT NULL, CHANGE lp_view_id lp_view_id INT NOT NULL, CHANGE view_count view_count INT NOT NULL, CHANGE start_time start_time INT NOT NULL, CHANGE total_time total_time INT NOT NULL, CHANGE score score DOUBLE PRECISION NOT NULL, CHANGE status status VARCHAR(32) DEFAULT 'not attempted' NOT NULL, CHANGE max_score max_score VARCHAR(8) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_lp_item_view (c_id)");
Database::query("ALTER TABLE c_survey CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE survey_id survey_id INT NOT NULL, CHANGE is_shared is_shared VARCHAR(1) DEFAULT NULL, CHANGE creation_date creation_date DATETIME NOT NULL, CHANGE anonymous anonymous VARCHAR(10) NOT NULL, CHANGE shuffle shuffle TINYINT(1) NOT NULL, CHANGE one_question_per_page one_question_per_page TINYINT(1) NOT NULL, CHANGE survey_version survey_version VARCHAR(255) NOT NULL, CHANGE parent_id parent_id INT NOT NULL, CHANGE survey_type survey_type INT NOT NULL, CHANGE show_form_profile show_form_profile INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE visible_results visible_results INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_survey (c_id)");
Database::query("ALTER TABLE c_link CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE category_id category_id INT DEFAULT NULL, CHANGE display_order display_order INT NOT NULL, CHANGE on_homepage on_homepage VARCHAR(10) NOT NULL, CHANGE target target VARCHAR(10) DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_link (c_id)");
Database::query("ALTER TABLE c_thematic_advance CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE attendance_id attendance_id INT NOT NULL, CHANGE start_date start_date DATETIME NOT NULL, CHANGE duration duration INT NOT NULL, CHANGE done_advance done_advance TINYINT(1) NOT NULL");
Database::query("ALTER TABLE c_thematic_advance ENGINE=InnoDB");
Database::query("ALTER TABLE c_thematic_advance ADD CONSTRAINT FK_62798E9754177093 FOREIGN KEY (room_id) REFERENCES room (id)");
Database::query("CREATE INDEX course ON c_thematic_advance (c_id)");
Database::query("ALTER TABLE c_online_connected CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE last_connection last_connection DATETIME NOT NULL");
Database::query("CREATE INDEX course ON c_online_connected (c_id)");
Database::query("ALTER TABLE c_student_publication_assignment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE expires_on expires_on DATETIME DEFAULT NULL, CHANGE ends_on ends_on DATETIME DEFAULT NULL");
Database::query("CREATE INDEX course ON c_student_publication_assignment (c_id)");
Database::query("ALTER TABLE c_calendar_event_repeat_not CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE cal_id cal_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_calendar_event_repeat_not (c_id)");
Database::query("ALTER TABLE c_role_user CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE role_id role_id INT NOT NULL, CHANGE scope scope VARCHAR(20) NOT NULL, CHANGE user_id user_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_role_user (c_id)");
Database::query("CREATE INDEX user ON c_role_user (user_id)");
Database::query("ALTER TABLE c_tool CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE visibility visibility TINYINT(1) DEFAULT NULL, CHANGE added_tool added_tool TINYINT(1) DEFAULT NULL, CHANGE target target VARCHAR(20) NOT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_tool (c_id)");
Database::query("ALTER TABLE c_wiki_mailcue CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_wiki_mailcue (c_id)");
Database::query("CREATE INDEX user ON c_wiki_mailcue (user_id)");
Database::query("ALTER TABLE c_blog_post CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE post_id post_id INT NOT NULL, CHANGE title title VARCHAR(250) NOT NULL, CHANGE date_creation date_creation DATETIME NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE author_id author_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_blog_post (c_id)");
Database::query("CREATE INDEX course ON c_attendance_calendar_rel_group (c_id)");
Database::query("CREATE INDEX `group` ON c_attendance_calendar_rel_group (group_id)");
Database::query("ALTER TABLE c_wiki CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE page_id page_id INT DEFAULT NULL, CHANGE reflink reflink VARCHAR(255) NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE dtime dtime DATETIME NOT NULL, CHANGE addlock addlock INT NOT NULL, CHANGE editlock editlock INT NOT NULL, CHANGE visibility visibility INT NOT NULL, CHANGE addlock_disc addlock_disc INT NOT NULL, CHANGE visibility_disc visibility_disc INT NOT NULL, CHANGE ratinglock_disc ratinglock_disc INT NOT NULL, CHANGE assignment assignment INT NOT NULL, CHANGE score score INT DEFAULT NULL, CHANGE is_editing is_editing INT NOT NULL, CHANGE time_edit time_edit DATETIME NOT NULL, CHANGE hits hits INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_wiki (c_id)");
Database::query("ALTER TABLE c_student_publication_rel_document ADD iid INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (iid)");
Database::query("CREATE INDEX course ON c_student_publication_rel_document (c_id)");
Database::query("CREATE INDEX work ON c_student_publication_rel_document (work_id)");
Database::query("CREATE INDEX document ON c_student_publication_rel_document (document_id)");
Database::query("ALTER TABLE c_tool_intro CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id VARCHAR(255) NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_tool_intro (c_id)");
Database::query("ALTER TABLE c_course_description CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE description_type description_type INT NOT NULL, CHANGE progress progress INT NOT NULL");
Database::query("ALTER TABLE c_blog_attachment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE path path VARCHAR(255) NOT NULL, CHANGE size size INT NOT NULL, CHANGE filename filename VARCHAR(255) NOT NULL, CHANGE comment_id comment_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_blog_attachment (c_id)");
Database::query("ALTER TABLE c_attendance_calendar CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE date_time date_time DATETIME NOT NULL, CHANGE done_attendance done_attendance TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_attendance_calendar (c_id)");
Database::query("ALTER TABLE c_dropbox_post CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE file_id file_id INT NOT NULL, CHANGE dest_user_id dest_user_id INT NOT NULL, CHANGE feedback_date feedback_date DATETIME NOT NULL, CHANGE cat_id cat_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_dropbox_post (c_id)");
Database::query("CREATE INDEX dest_user ON c_dropbox_post (dest_user_id)");
Database::query("ALTER TABLE c_student_publication_comment ADD iid INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (iid)");
Database::query("CREATE INDEX course ON c_student_publication_comment (c_id)");
Database::query("CREATE INDEX user ON c_student_publication_comment (user_id)");
Database::query("CREATE INDEX work ON c_student_publication_comment (work_id)");
Database::query("ALTER TABLE c_role_group CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE role_id role_id INT NOT NULL, CHANGE scope scope VARCHAR(20) NOT NULL, CHANGE group_id group_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_role_group (c_id)");
Database::query("CREATE INDEX `group` ON c_role_group (group_id)");
Database::query("ALTER TABLE c_forum_post CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE post_id post_id INT NOT NULL, CHANGE thread_id thread_id INT DEFAULT NULL, CHANGE forum_id forum_id INT DEFAULT NULL, CHANGE poster_id poster_id INT DEFAULT NULL, CHANGE poster_name poster_name VARCHAR(100) DEFAULT NULL, CHANGE post_date post_date DATETIME DEFAULT NULL, CHANGE post_notification post_notification TINYINT(1) DEFAULT NULL, CHANGE post_parent_id post_parent_id INT DEFAULT NULL, CHANGE visible visible TINYINT(1) DEFAULT NULL");
Database::query("CREATE INDEX course ON c_forum_post (c_id)");
Database::query("ALTER TABLE c_role_permissions CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE role_id role_id INT NOT NULL, CHANGE tool tool VARCHAR(250) NOT NULL, CHANGE action action VARCHAR(50) NOT NULL, CHANGE default_perm default_perm TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_role_permissions (c_id)");
Database::query("CREATE INDEX role ON c_role_permissions (role_id)");
Database::query("ALTER TABLE c_dropbox_feedback CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE feedback_id feedback_id INT NOT NULL, CHANGE file_id file_id INT NOT NULL, CHANGE author_user_id author_user_id INT NOT NULL, CHANGE feedback_date feedback_date DATETIME NOT NULL");
Database::query("CREATE INDEX course ON c_dropbox_feedback (c_id)");
Database::query("ALTER TABLE c_dropbox_file CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE uploader_id uploader_id INT NOT NULL, CHANGE filename filename VARCHAR(250) NOT NULL, CHANGE filesize filesize INT NOT NULL, CHANGE title title VARCHAR(250) DEFAULT NULL, CHANGE description description VARCHAR(250) DEFAULT NULL, CHANGE author author VARCHAR(250) DEFAULT NULL, CHANGE upload_date upload_date DATETIME NOT NULL, CHANGE last_upload_date last_upload_date DATETIME NOT NULL, CHANGE cat_id cat_id INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_dropbox_file (c_id)");
Database::query("ALTER TABLE c_survey_question_option CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE question_option_id question_option_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE survey_id survey_id INT NOT NULL, CHANGE value value INT NOT NULL");
Database::query("CREATE INDEX course ON c_survey_question_option (c_id)");
Database::query("ALTER TABLE c_attendance CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE active active TINYINT(1) NOT NULL, CHANGE attendance_qualify_max attendance_qualify_max INT NOT NULL, CHANGE attendance_weight attendance_weight DOUBLE PRECISION NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE locked locked INT NOT NULL");
Database::query("CREATE INDEX course ON c_attendance (c_id)");
Database::query("ALTER TABLE c_lp_view CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE lp_id lp_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE view_count view_count INT NOT NULL, CHANGE last_item last_item INT NOT NULL, CHANGE progress progress INT DEFAULT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_lp_view (c_id)");
Database::query("ALTER TABLE c_blog_task CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE task_id task_id INT NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE title title VARCHAR(250) NOT NULL, CHANGE color color VARCHAR(10) NOT NULL, CHANGE system_task system_task TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_blog_task (c_id)");
Database::query("CREATE INDEX course ON c_lp_category (c_id)");
Database::query("ALTER TABLE c_glossary CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE glossary_id glossary_id INT NOT NULL, CHANGE session_id session_id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_glossary (c_id)");
Database::query("ALTER TABLE c_survey_question CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE survey_id survey_id INT NOT NULL, CHANGE survey_group_pri survey_group_pri INT NOT NULL, CHANGE survey_group_sec1 survey_group_sec1 INT NOT NULL, CHANGE survey_group_sec2 survey_group_sec2 INT NOT NULL");
Database::query("CREATE INDEX course ON c_survey_question (c_id)");
Database::query("ALTER TABLE c_lp_iv_objective CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE lp_iv_id lp_iv_id BIGINT NOT NULL, CHANGE order_id order_id INT NOT NULL, CHANGE objective_id objective_id VARCHAR(255) NOT NULL, CHANGE score_raw score_raw DOUBLE PRECISION NOT NULL, CHANGE score_max score_max DOUBLE PRECISION NOT NULL, CHANGE score_min score_min DOUBLE PRECISION NOT NULL, CHANGE status status VARCHAR(32) NOT NULL");
Database::query("CREATE INDEX course ON c_lp_iv_objective (c_id)");
Database::query("ALTER TABLE c_survey_invitation CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE survey_invitation_id survey_invitation_id INT NOT NULL, CHANGE answered answered INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_survey_invitation (c_id)");
Database::query("ALTER TABLE c_blog_task_rel_user CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE blog_id blog_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE task_id task_id INT NOT NULL, CHANGE target_date target_date DATE NOT NULL");
Database::query("CREATE INDEX course ON c_blog_task_rel_user (c_id)");
Database::query("CREATE INDEX user ON c_blog_task_rel_user (user_id)");
Database::query("CREATE INDEX task ON c_blog_task_rel_user (task_id)");
Database::query("ALTER TABLE c_quiz_question_rel_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_quiz_question_rel_category (c_id)");
Database::query("ALTER TABLE c_forum_notification CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE forum_id forum_id INT NOT NULL, CHANGE thread_id thread_id INT NOT NULL, CHANGE post_id post_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_forum_notification (c_id)");
Database::query("CREATE INDEX thread ON c_forum_notification (thread_id)");
Database::query("CREATE INDEX post ON c_forum_notification (post_id)");
Database::query("ALTER TABLE c_forum_thread_qualify_log CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE qualify qualify DOUBLE PRECISION NOT NULL, CHANGE qualify_time qualify_time DATETIME DEFAULT NULL");
Database::query("CREATE INDEX course ON c_forum_thread_qualify_log (c_id)");
Database::query("ALTER TABLE c_quiz_answer CHANGE c_id c_id INT UNSIGNED NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE id_auto id_auto INT UNSIGNED NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE correct correct INT DEFAULT NULL, CHANGE ponderation ponderation DOUBLE PRECISION NOT NULL, CHANGE position position INT NOT NULL, CHANGE answer_code answer_code VARCHAR(10) DEFAULT NULL");
Database::query("CREATE INDEX c_id ON c_quiz_answer (c_id)");
Database::query("ALTER TABLE c_attendance_sheet CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE presence presence TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_attendance_sheet (c_id)");
Database::query("CREATE INDEX user ON c_attendance_sheet (user_id)");
Database::query("ALTER TABLE c_student_publication CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE accepted accepted TINYINT(1) DEFAULT NULL, CHANGE post_group_id post_group_id INT NOT NULL, CHANGE sent_date sent_date DATETIME DEFAULT NULL, CHANGE filetype filetype VARCHAR(10) NOT NULL, CHANGE has_properties has_properties INT NOT NULL, CHANGE qualification qualification DOUBLE PRECISION NOT NULL, CHANGE date_of_qualification date_of_qualification DATETIME DEFAULT NULL, CHANGE parent_id parent_id INT NOT NULL, CHANGE qualificator_id qualificator_id INT NOT NULL, CHANGE weight weight DOUBLE PRECISION NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE allow_text_assignment allow_text_assignment INT NOT NULL, CHANGE contains_file contains_file INT NOT NULL, CHANGE document_id document_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_student_publication (c_id)");
Database::query("ALTER TABLE c_course_setting CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE variable variable VARCHAR(255) NOT NULL, CHANGE value value VARCHAR(255) DEFAULT NULL, CHANGE title title VARCHAR(255) NOT NULL");
Database::query("CREATE INDEX course ON c_course_setting (c_id)");
Database::query("ALTER TABLE c_quiz_question_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL");
Database::query("CREATE INDEX course ON c_quiz_question_category (c_id)");
Database::query("ALTER TABLE c_userinfo_def CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE title title VARCHAR(80) NOT NULL, CHANGE line_count line_count TINYINT(1) NOT NULL, CHANGE rank rank TINYINT(1) NOT NULL");
Database::query("CREATE INDEX course ON c_userinfo_def (c_id)");
Database::query("ALTER TABLE c_forum_forum CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE forum_id forum_id INT NOT NULL, CHANGE forum_title forum_title VARCHAR(255) NOT NULL, CHANGE forum_threads forum_threads INT DEFAULT NULL, CHANGE forum_posts forum_posts INT DEFAULT NULL, CHANGE forum_last_post forum_last_post INT DEFAULT NULL, CHANGE forum_group_public_private forum_group_public_private VARCHAR(20) DEFAULT NULL, CHANGE locked locked INT NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE forum_image forum_image VARCHAR(255) NOT NULL, CHANGE start_time start_time DATETIME NOT NULL, CHANGE end_time end_time DATETIME NOT NULL");
Database::query("CREATE INDEX course ON c_forum_forum (c_id)");
Database::query("ALTER TABLE c_quiz_question_option CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE position position INT NOT NULL");
Database::query("CREATE INDEX course ON c_quiz_question_option (c_id)");
Database::query("ALTER TABLE c_userinfo_content CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE user_id user_id INT NOT NULL, CHANGE definition_id definition_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_userinfo_content (c_id)");
Database::query("ALTER TABLE c_forum_attachment CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE size size INT NOT NULL");
Database::query("CREATE INDEX course ON c_forum_attachment (c_id)");
Database::query("ALTER TABLE c_quiz_rel_question CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE exercice_id exercice_id INT NOT NULL, CHANGE question_order question_order INT NOT NULL");
Database::query("CREATE INDEX course ON c_quiz_rel_question (c_id)");
Database::query("CREATE INDEX question ON c_quiz_rel_question (question_id)");
Database::query("CREATE INDEX exercice ON c_quiz_rel_question (exercice_id)");
Database::query("ALTER TABLE c_attendance_result CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE score score INT NOT NULL");
Database::query("CREATE INDEX course ON c_attendance_result (c_id)");
Database::query("ALTER TABLE c_forum_category CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE cat_id cat_id INT NOT NULL, CHANGE cat_title cat_title VARCHAR(255) NOT NULL, CHANGE cat_order cat_order INT NOT NULL, CHANGE locked locked INT NOT NULL, CHANGE session_id session_id INT NOT NULL");
Database::query("CREATE INDEX course ON c_forum_category (c_id)");
Database::query("ALTER TABLE c_survey_answer CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE answer_id answer_id INT NOT NULL, CHANGE survey_id survey_id INT NOT NULL, CHANGE question_id question_id INT NOT NULL, CHANGE value value INT NOT NULL");
Database::query("CREATE INDEX course ON c_survey_answer (c_id)");
Database::query("ALTER TABLE c_calendar_event CHANGE iid iid INT AUTO_INCREMENT NOT NULL, CHANGE c_id c_id INT NOT NULL, CHANGE id id INT DEFAULT NULL, CHANGE start_date start_date DATETIME NOT NULL, CHANGE end_date end_date DATETIME NOT NULL, CHANGE session_id session_id INT NOT NULL, CHANGE all_day all_day INT NOT NULL");
Database::query("ALTER TABLE c_calendar_event ENGINE=InnoDB");
Database::query("ALTER TABLE c_calendar_event ADD CONSTRAINT FK_A062258154177093 FOREIGN KEY (room_id) REFERENCES room (id)");
Database::query("CREATE INDEX course ON c_calendar_event (c_id)");
echo "Done!<br>" . PHP_EOL;