Version110.php 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. namespace Application\Migrations\Schema\V110;
  4. use Application\Migrations\AbstractMigrationChamilo;
  5. use Doctrine\DBAL\Schema\Schema;
  6. use \Doctrine\DBAL\Types\Type;
  7. /**
  8. * Class Version110
  9. *
  10. * Migrate file to updated to Chamilo 1.10
  11. *
  12. * @package Application\Migrations\Schema\V110
  13. */
  14. class Version110 extends AbstractMigrationChamilo
  15. {
  16. /**
  17. * @param Schema $schema
  18. */
  19. public function preUp(Schema $schema)
  20. {
  21. $this->addSql("ALTER TABLE session_rel_course ENGINE=InnoDB");
  22. $this->addSql("ALTER TABLE session_rel_course_rel_user ENGINE=InnoDB");
  23. $this->addSql("ALTER TABLE session_rel_user ENGINE=InnoDB");
  24. $this->addSql("UPDATE session SET session.id_coach = (SELECT u.user_id FROM admin a INNER JOIN user u ON (u.user_id = a.user_id AND u.active = 1) LIMIT 1) WHERE id_coach NOT IN (SELECT user_id FROM user)");
  25. }
  26. /**
  27. * @param Schema $schema
  28. *
  29. * @throws \Doctrine\DBAL\Schema\SchemaException
  30. */
  31. public function up(Schema $schema)
  32. {
  33. // Needed to update 0000-00-00 00:00:00 values
  34. $this->addSql('SET sql_mode = ""');
  35. // In case this one didn't work, also try this
  36. $this->addSql('SET SESSION sql_mode = ""');
  37. $connection = $this->connection;
  38. $this->addSql("CREATE TABLE IF NOT EXISTS course_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)");
  39. $this->addSql("CREATE TABLE IF NOT EXISTS session_field_options (id INT NOT NULL PRIMARY KEY AUTO_INCREMENT, field_id INT NOT NULL, option_value TEXT, option_display_text VARCHAR(64), option_order INT, tms DATETIME)");
  40. $this->addSql("CREATE TABLE IF NOT EXISTS hook_observer( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, path varchar(255) NOT NULL, plugin_name varchar(255) NULL, PRIMARY KEY PK_hook_management_hook_observer(id))");
  41. $this->addSql("CREATE TABLE IF NOT EXISTS hook_event( id int UNSIGNED NOT NULL AUTO_INCREMENT, class_name varchar(255) UNIQUE, description varchar(255), PRIMARY KEY PK_hook_management_hook_event(id))");
  42. $this->addSql("CREATE TABLE IF NOT EXISTS hook_call( id int UNSIGNED NOT NULL AUTO_INCREMENT, hook_event_id int UNSIGNED NOT NULL, hook_observer_id int UNSIGNED NOT NULL, type tinyint NOT NULL, hook_order int UNSIGNED NOT NULL, enabled tinyint NOT NULL, PRIMARY KEY PK_hook_management_hook_call(id))");
  43. $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_document (iid INT NOT NULL PRIMARY KEY, id INT NULL, work_id INT NOT NULL, document_id INT NOT NULL, c_id INT NOT NULL)");
  44. $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_rel_user (iid INT NOT NULL AUTO_INCREMENT PRIMARY KEY, id INT NULL, work_id INT NOT NULL, user_id INT NOT NULL, c_id INT NOT NULL)");
  45. $this->addSql("CREATE TABLE IF NOT EXISTS c_student_publication_comment (iid INT NOT NULL PRIMARY KEY AUTO_INCREMENT, id INT NULL, work_id INT NOT NULL, c_id INT NOT NULL, comment text, file VARCHAR(255), user_id int NOT NULL, sent_at datetime NOT NULL)");
  46. $this->addSql("CREATE TABLE IF NOT EXISTS c_attendance_calendar_rel_group (iid int NOT NULL auto_increment PRIMARY KEY, id INT, c_id INT NOT NULL, group_id INT NOT NULL, calendar_id INT NOT NULL)");
  47. $this->addSql("ALTER TABLE skill_rel_user MODIFY COLUMN acquired_skill_at datetime default NULL");
  48. $this->addSql("ALTER TABLE track_e_access MODIFY COLUMN access_date datetime DEFAULT NULL");
  49. $this->addSql("ALTER TABLE track_e_lastaccess MODIFY COLUMN access_date datetime DEFAULT NULL");
  50. $table = $schema->getTable('skill_rel_user');
  51. if (!$table->hasColumn('course_id')) {
  52. $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN course_id INT NOT NULL DEFAULT 0 AFTER id");
  53. }
  54. if (!$table->hasColumn('session_id')) {
  55. $this->addSql("ALTER TABLE skill_rel_user ADD COLUMN session_id INT NOT NULL DEFAULT 0 AFTER course_id");
  56. }
  57. if (!$table->hasIndex('idx_select_cs')) {
  58. $this->addSql("ALTER TABLE skill_rel_user ADD INDEX idx_select_cs (course_id, session_id)");
  59. }
  60. // Delete info of session_rel_user if session does not exists;
  61. $this->addSql("DELETE FROM session_rel_user WHERE id_session NOT IN (SELECT id FROM session)");
  62. // Delete info of usergroup_rel_user if usergroup does not exists;
  63. $this->addSql("DELETE FROM usergroup_rel_user WHERE usergroup_id NOT IN (SELECT id FROM usergroup)");
  64. $session = $schema->getTable('session');
  65. $session->getColumn('id')->setType(Type::getType(Type::INTEGER))->setUnsigned(false);
  66. if (!$session->hasColumn('description')) {
  67. $session->addColumn(
  68. 'description',
  69. 'text'
  70. );
  71. }
  72. if (!$session->hasColumn('show_description')) {
  73. $session->addColumn(
  74. 'show_description',
  75. 'smallint',
  76. array('default' => 0, 'unsigned' => true)
  77. );
  78. }
  79. $sessionTable = $schema->getTable('session');
  80. if (!$sessionTable->hasColumn('duration')) {
  81. $this->addSql("ALTER TABLE session ADD COLUMN duration int");
  82. }
  83. $sessionRelUser = $schema->getTable('session_rel_user');
  84. if (!$sessionRelUser->hasColumn('duration')) {
  85. $this->addSql("ALTER TABLE session_rel_user ADD COLUMN duration int");
  86. }
  87. $table = $schema->getTable('skill');
  88. if (!$table->hasColumn('criteria')) {
  89. $this->addSql("ALTER TABLE skill ADD COLUMN criteria text");
  90. }
  91. $table = $schema->getTable('gradebook_category');
  92. if (!$table->hasColumn('generate_certificates')) {
  93. $this->addSql("ALTER TABLE gradebook_category ADD COLUMN generate_certificates TINYINT NOT NULL DEFAULT 0");
  94. }
  95. $this->addSql("ALTER TABLE track_e_access ADD COLUMN c_id int NOT NULL");
  96. $this->addSql("ALTER TABLE track_e_lastaccess ADD COLUMN c_id int NOT NULL");
  97. $this->addSql("ALTER TABLE track_e_exercices ADD COLUMN c_id int NOT NULL");
  98. $this->addSql("ALTER TABLE track_e_downloads ADD COLUMN c_id int NOT NULL");
  99. $this->addSql("ALTER TABLE track_e_hotpotatoes ADD COLUMN c_id int NOT NULL");
  100. $this->addSql("ALTER TABLE track_e_links ADD COLUMN c_id int NOT NULL");
  101. $this->addSql("ALTER TABLE track_e_course_access ADD COLUMN c_id int NOT NULL");
  102. $this->addSql("ALTER TABLE track_e_online ADD COLUMN c_id int NOT NULL");
  103. $this->addSql("ALTER TABLE track_e_attempt ADD COLUMN c_id int NOT NULL");
  104. $table = $schema->getTable('track_e_default');
  105. if (!$table->hasColumn('session_id')) {
  106. $this->addSql("ALTER TABLE track_e_default ADD COLUMN session_id int NOT NULL");
  107. }
  108. if (!$table->hasColumn('c_id')) {
  109. $this->addSql("ALTER TABLE track_e_default ADD COLUMN c_id int NOT NULL");
  110. }
  111. $this->addSql("ALTER TABLE track_e_access ADD COLUMN user_ip varchar(39) NOT NULL default ''");
  112. $this->addSql("ALTER TABLE track_e_exercices ADD COLUMN user_ip varchar(39) NOT NULL default ''");
  113. $this->addSql("ALTER TABLE track_e_course_access ADD COLUMN user_ip varchar(39) NOT NULL default ''");
  114. $this->addSql("ALTER TABLE track_e_online CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''");
  115. $this->addSql("ALTER TABLE track_e_login CHANGE COLUMN login_ip user_ip varchar(39) NOT NULL DEFAULT ''");
  116. $this->addSql('LOCK TABLE user WRITE');
  117. $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned NOT NULL");
  118. $this->addSql("ALTER TABLE user DROP PRIMARY KEY");
  119. $this->addSql("ALTER TABLE user MODIFY COLUMN user_id int unsigned DEFAULT NULL");
  120. $this->addSql("ALTER TABLE user ADD COLUMN id INT DEFAULT NULL");
  121. $this->addSql("UPDATE user SET id = user_id");
  122. $this->addSql("ALTER TABLE user MODIFY COLUMN id INT NOT NULL PRIMARY KEY AUTO_INCREMENT AFTER user_id");
  123. $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_date datetime default NULL");
  124. $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_text varchar(50) default NULL");
  125. $this->addSql("ALTER TABLE user MODIFY COLUMN chatcall_user_id int unsigned default 0");
  126. $this->addSql("ALTER TABLE user MODIFY COLUMN expiration_date datetime default NULL");
  127. $this->addSql("ALTER TABLE user MODIFY COLUMN registration_date datetime NOT NULL");
  128. $this->addSql('UNLOCK TABLES');
  129. $table = $schema->getTable('course');
  130. if (!$table->hasColumn('add_teachers_to_sessions_courses')) {
  131. $this->addSql("ALTER TABLE course ADD COLUMN add_teachers_to_sessions_courses tinyint NOT NULL default 0");
  132. }
  133. $this->addSql("ALTER TABLE course DROP COLUMN target_course_code");
  134. $this->addSql("ALTER TABLE session MODIFY COLUMN name char(100) NOT NULL DEFAULT ''");
  135. $this->addSql("ALTER TABLE course_rel_user ADD COLUMN c_id int default NULL");
  136. $this->addSql("ALTER TABLE course_field_values ADD COLUMN c_id int default NULL");
  137. $this->addSql('LOCK TABLE session_rel_course_rel_user WRITE');
  138. $this->addSql("ALTER TABLE session_rel_course_rel_user ADD COLUMN c_id int NOT NULL");
  139. $this->addSql("ALTER TABLE session_rel_course_rel_user CHANGE id_session session_id int");
  140. $this->addSql("ALTER TABLE session_rel_course_rel_user CHANGE id_user user_id int");
  141. $this->addSql('UNLOCK TABLES');
  142. $this->addSql("ALTER TABLE access_url_rel_course ADD COLUMN c_id int");
  143. $table = $schema->getTable('session_rel_course');
  144. if (!$table->hasColumn('position')) {
  145. $this->addSql("ALTER TABLE session_rel_course ADD COLUMN position int NOT NULL default 0");
  146. }
  147. $this->addSql("ALTER TABLE session_rel_course ADD COLUMN category varchar(255) default ''");
  148. $this->addSql("ALTER TABLE session_rel_course ADD COLUMN c_id int unsigned NOT NULL");
  149. $this->addSql("ALTER TABLE session_rel_course CHANGE id_session session_id int");
  150. $this->addSql('DELETE FROM session_rel_course WHERE session_id NOT IN (SELECT id FROM session)');
  151. $this->addSql("DELETE FROM course_rel_user WHERE course_code NOT IN (SELECT code FROM course)");
  152. $this->addSql("UPDATE course_rel_user SET c_id = (SELECT id FROM course WHERE code = course_code)");
  153. // Add iid
  154. $tables = [
  155. 'c_announcement',
  156. 'c_announcement_attachment',
  157. 'c_attendance',
  158. 'c_attendance_calendar',
  159. //'c_attendance_calendar_rel_group',
  160. 'c_attendance_result',
  161. //'c_attendance_sheet',
  162. 'c_attendance_sheet_log',
  163. //'c_blog',
  164. 'c_blog_attachment',
  165. //'c_blog_comment',
  166. //'c_blog_post',
  167. //'c_blog_rating',
  168. //'c_blog_rel_user',
  169. //'c_blog_task',
  170. //'c_blog_task_rel_user',
  171. 'c_calendar_event',
  172. 'c_calendar_event_attachment',
  173. //'c_calendar_event_repeat',
  174. //'c_calendar_event_repeat_not',
  175. 'c_chat_connected',
  176. 'c_course_description',
  177. 'c_course_setting',
  178. 'c_document',
  179. //'c_dropbox_category',
  180. //'c_dropbox_feedback',
  181. 'c_dropbox_file',
  182. //'c_dropbox_person',
  183. //'c_dropbox_post',
  184. 'c_forum_attachment',
  185. //'c_forum_category',
  186. //'c_forum_forum',
  187. 'c_forum_mailcue',
  188. 'c_forum_notification',
  189. //'c_forum_post',
  190. //'c_forum_thread',
  191. 'c_forum_thread_qualify',
  192. 'c_forum_thread_qualify_log',
  193. //'c_glossary',
  194. 'c_group_category',
  195. 'c_group_info',
  196. 'c_group_rel_tutor',
  197. 'c_group_rel_user',
  198. 'c_item_property',
  199. 'c_link',
  200. 'c_link_category',
  201. 'c_lp',
  202. 'c_lp_item',
  203. 'c_lp_item_view',
  204. 'c_lp_iv_interaction',
  205. 'c_lp_iv_objective',
  206. 'c_lp_view',
  207. //'c_notebook',
  208. //'c_online_connected',
  209. 'c_online_link',
  210. 'c_permission_group',
  211. 'c_permission_task',
  212. 'c_permission_user',
  213. 'c_quiz',
  214. //'c_quiz_answer',
  215. 'c_quiz_question',
  216. 'c_quiz_question_category',
  217. 'c_quiz_question_option',
  218. //'c_quiz_question_rel_category',
  219. //'c_quiz_rel_question',
  220. 'c_resource',
  221. //'c_role',
  222. 'c_role_group',
  223. 'c_role_permissions',
  224. //'c_role_user',
  225. 'c_student_publication',
  226. 'c_student_publication_assignment',
  227. //'c_student_publication_comment',
  228. //'c_student_publication_rel_document',
  229. //'c_student_publication_rel_user',
  230. //'c_survey',
  231. //'c_survey_answer',
  232. 'c_survey_group',
  233. //'c_survey_invitation',
  234. //'c_survey_question',
  235. //'c_survey_question_option',
  236. 'c_thematic',
  237. 'c_thematic_advance',
  238. 'c_thematic_plan',
  239. 'c_tool',
  240. //'c_tool_intro',
  241. 'c_userinfo_content',
  242. 'c_userinfo_def',
  243. 'c_wiki',
  244. //'c_wiki_conf',
  245. 'c_wiki_discuss',
  246. 'c_wiki_mailcue'
  247. ];
  248. foreach ($tables as $table) {
  249. if ($schema->hasTable($table)) {
  250. $this->addSql("ALTER TABLE $table MODIFY COLUMN id INT NOT NULL");
  251. $this->addSql("ALTER TABLE $table MODIFY COLUMN c_id INT NOT NULL");
  252. $this->addSql("ALTER TABLE $table DROP PRIMARY KEY");
  253. $this->addSql("ALTER TABLE $table MODIFY COLUMN id INT NULL");
  254. $this->addSql("ALTER TABLE $table ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  255. }
  256. }
  257. if ($schema->hasTable('c_attendance_calendar_rel_group')) {
  258. $table = $schema->getTable('c_attendance_calendar_rel_group');
  259. if ($table->hasColumn('iid') === false) {
  260. $this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NOT NULL");
  261. $this->addSql("ALTER TABLE c_attendance_calendar_rel_group DROP PRIMARY KEY");
  262. $this->addSql("ALTER TABLE c_attendance_calendar_rel_group MODIFY COLUMN id INT NULL DEFAULT NULL");
  263. $this->addSql("ALTER TABLE c_attendance_calendar_rel_group ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  264. }
  265. }
  266. $this->addSql("ALTER TABLE c_attendance_sheet MODIFY COLUMN c_id INT NOT NULL");
  267. $this->addSql("ALTER TABLE c_attendance_sheet DROP PRIMARY KEY");
  268. $this->addSql("ALTER TABLE c_attendance_sheet ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  269. $this->addSql("ALTER TABLE c_blog MODIFY COLUMN blog_id int unsigned NOT NULL");
  270. $this->addSql("ALTER TABLE c_blog MODIFY COLUMN c_id INT NOT NULL");
  271. $this->addSql("ALTER TABLE c_blog DROP PRIMARY KEY");
  272. $this->addSql("ALTER TABLE c_blog MODIFY COLUMN blog_id int unsigned DEFAULT NULL");
  273. $this->addSql("ALTER TABLE c_blog ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  274. $this->addSql("ALTER TABLE c_blog_comment MODIFY COLUMN comment_id int NOT NULL");
  275. $this->addSql("ALTER TABLE c_blog_comment MODIFY COLUMN c_id INT NOT NULL");
  276. $this->addSql("ALTER TABLE c_blog_comment DROP PRIMARY KEY");
  277. $this->addSql("ALTER TABLE c_blog_comment MODIFY COLUMN comment_id int DEFAULT NULL");
  278. $this->addSql("ALTER TABLE c_blog_comment ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  279. $this->addSql("ALTER TABLE c_blog_post MODIFY COLUMN post_id int unsigned NOT NULL");
  280. $this->addSql("ALTER TABLE c_blog_post MODIFY COLUMN c_id INT NOT NULL");
  281. $this->addSql("ALTER TABLE c_blog_post DROP PRIMARY KEY");
  282. $this->addSql("ALTER TABLE c_blog_post MODIFY COLUMN post_id int unsigned DEFAULT NULL");
  283. $this->addSql("ALTER TABLE c_blog_post ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  284. $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_id int unsigned NOT NULL");
  285. $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN c_id INT NOT NULL");
  286. $this->addSql("ALTER TABLE c_blog_rating DROP PRIMARY KEY");
  287. $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_id int unsigned DEFAULT NULL");
  288. $this->addSql("ALTER TABLE c_blog_rating ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  289. $this->addSql("ALTER TABLE c_blog_rel_user DROP PRIMARY KEY");
  290. $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN c_id INT NOT NULL");
  291. $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN blog_id int unsigned DEFAULT NULL");
  292. $this->addSql("ALTER TABLE c_blog_rel_user MODIFY COLUMN user_id int unsigned DEFAULT NULL");
  293. $this->addSql("ALTER TABLE c_blog_rel_user ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  294. $this->addSql("ALTER TABLE c_blog_task MODIFY COLUMN task_id int unsigned NOT NULL");
  295. $this->addSql("ALTER TABLE c_blog_task MODIFY COLUMN c_id INT NOT NULL");
  296. $this->addSql("ALTER TABLE c_blog_task DROP PRIMARY KEY");
  297. $this->addSql("ALTER TABLE c_blog_task MODIFY COLUMN task_id int unsigned DEFAULT NULL");
  298. $this->addSql("ALTER TABLE c_blog_task ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  299. $this->addSql("ALTER TABLE c_blog_task_rel_user DROP PRIMARY KEY");
  300. $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN blog_id int unsigned DEFAULT NULL");
  301. $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN user_id int unsigned DEFAULT NULL");
  302. $this->addSql("ALTER TABLE c_blog_task_rel_user MODIFY COLUMN task_id int unsigned DEFAULT NULL");
  303. $this->addSql("ALTER TABLE c_blog_task_rel_user ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  304. $this->addSql("ALTER TABLE c_calendar_event_repeat DROP PRIMARY KEY");
  305. $this->addSql("ALTER TABLE c_calendar_event_repeat MODIFY COLUMN cal_id int unsigned DEFAULT NULL");
  306. $this->addSql("ALTER TABLE c_calendar_event_repeat MODIFY COLUMN c_id INT NOT NULL");
  307. $this->addSql("ALTER TABLE c_calendar_event_repeat ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  308. $this->addSql("ALTER TABLE c_calendar_event_repeat_not DROP PRIMARY KEY");
  309. $this->addSql("ALTER TABLE c_calendar_event_repeat_not MODIFY COLUMN cal_id int unsigned DEFAULT NULL");
  310. $this->addSql("ALTER TABLE c_calendar_event_repeat_not MODIFY COLUMN c_id INT NOT NULL");
  311. $this->addSql("ALTER TABLE c_calendar_event_repeat_not ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  312. $this->addSql("ALTER TABLE c_dropbox_category MODIFY COLUMN cat_id int unsigned NOT NULL");
  313. $this->addSql("ALTER TABLE c_dropbox_category DROP PRIMARY KEY");
  314. $this->addSql("ALTER TABLE c_dropbox_category MODIFY COLUMN cat_id int unsigned DEFAULT NULL");
  315. $this->addSql("ALTER TABLE c_dropbox_category MODIFY COLUMN c_id INT NOT NULL");
  316. $this->addSql("ALTER TABLE c_dropbox_category ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  317. $this->addSql("ALTER TABLE c_dropbox_feedback MODIFY COLUMN feedback_id int unsigned NOT NULL");
  318. $this->addSql("ALTER TABLE c_dropbox_feedback DROP PRIMARY KEY");
  319. $this->addSql("ALTER TABLE c_dropbox_feedback MODIFY COLUMN feedback_id int unsigned DEFAULT NULL");
  320. $this->addSql("ALTER TABLE c_dropbox_feedback MODIFY COLUMN c_id INT NOT NULL");
  321. $this->addSql("ALTER TABLE c_dropbox_feedback ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  322. $this->addSql("ALTER TABLE c_dropbox_person DROP PRIMARY KEY");
  323. $this->addSql("ALTER TABLE c_dropbox_person MODIFY COLUMN file_id int unsigned DEFAULT NULL");
  324. $this->addSql("ALTER TABLE c_dropbox_person MODIFY COLUMN c_id INT NOT NULL");
  325. $this->addSql("ALTER TABLE c_dropbox_person ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  326. $this->addSql("ALTER TABLE c_dropbox_post DROP PRIMARY KEY");
  327. $this->addSql("ALTER TABLE c_dropbox_post MODIFY COLUMN file_id int unsigned DEFAULT NULL");
  328. $this->addSql("ALTER TABLE c_dropbox_post MODIFY COLUMN c_id INT NOT NULL");
  329. $this->addSql("ALTER TABLE c_dropbox_post ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  330. $this->addSql("ALTER TABLE c_forum_category MODIFY COLUMN cat_id int unsigned NOT NULL");
  331. $this->addSql("ALTER TABLE c_forum_category DROP PRIMARY KEY");
  332. $this->addSql("ALTER TABLE c_forum_category MODIFY COLUMN cat_id int unsigned DEFAULT NULL");
  333. $this->addSql("ALTER TABLE c_forum_category MODIFY COLUMN c_id INT NOT NULL");
  334. $this->addSql("ALTER TABLE c_forum_category ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  335. $this->addSql("ALTER TABLE c_forum_forum MODIFY COLUMN forum_id int unsigned NOT NULL");
  336. $this->addSql("ALTER TABLE c_forum_forum DROP PRIMARY KEY");
  337. $this->addSql("ALTER TABLE c_forum_forum MODIFY COLUMN forum_id int unsigned DEFAULT NULL");
  338. $this->addSql("ALTER TABLE c_forum_forum MODIFY COLUMN c_id INT NOT NULL");
  339. $this->addSql("ALTER TABLE c_forum_forum ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  340. $this->addSql("ALTER TABLE c_forum_post MODIFY COLUMN post_id int unsigned NOT NULL");
  341. $this->addSql("ALTER TABLE c_forum_post DROP PRIMARY KEY");
  342. $this->addSql("ALTER TABLE c_forum_post MODIFY COLUMN post_id int unsigned DEFAULT NULL");
  343. $this->addSql("ALTER TABLE c_forum_post MODIFY COLUMN c_id INT NOT NULL");
  344. $this->addSql("ALTER TABLE c_forum_post ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  345. $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN thread_id int unsigned NOT NULL");
  346. $this->addSql("ALTER TABLE c_forum_thread DROP PRIMARY KEY");
  347. $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN forum_id int unsigned DEFAULT NULL");
  348. $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN c_id INT NOT NULL");
  349. $this->addSql("ALTER TABLE c_forum_thread MODIFY COLUMN thread_id int unsigned DEFAULT NULL");
  350. $this->addSql("ALTER TABLE c_forum_thread ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  351. $this->addSql("ALTER TABLE c_forum_thread ADD COLUMN thread_peer_qualify tinyint default 0");
  352. $this->addSql("ALTER TABLE c_glossary MODIFY COLUMN glossary_id int unsigned NOT NULL");
  353. $this->addSql("ALTER TABLE c_glossary MODIFY COLUMN c_id INT NOT NULL");
  354. $this->addSql("ALTER TABLE c_glossary DROP PRIMARY KEY");
  355. $this->addSql("ALTER TABLE c_glossary MODIFY COLUMN glossary_id int unsigned DEFAULT NULL");
  356. $this->addSql("ALTER TABLE c_glossary ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  357. $this->addSql("ALTER TABLE c_notebook MODIFY COLUMN notebook_id int unsigned NOT NULL");
  358. $this->addSql("ALTER TABLE c_notebook MODIFY COLUMN c_id INT NOT NULL");
  359. $this->addSql("ALTER TABLE c_notebook DROP PRIMARY KEY");
  360. $this->addSql("ALTER TABLE c_notebook MODIFY COLUMN notebook_id int unsigned DEFAULT NULL");
  361. $this->addSql("ALTER TABLE c_notebook ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  362. $this->addSql("ALTER TABLE c_online_connected MODIFY COLUMN c_id INT NOT NULL");
  363. $this->addSql("ALTER TABLE c_online_connected DROP PRIMARY KEY");
  364. $this->addSql("ALTER TABLE c_online_connected ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  365. // For some reason c_tool_intro.id is a varchar in 1.9.x
  366. $this->addSql("ALTER TABLE c_tool_intro MODIFY COLUMN id VARCHAR(50) NOT NULL");
  367. $this->addSql("ALTER TABLE c_tool_intro MODIFY COLUMN c_id INT NOT NULL");
  368. $this->addSql("ALTER TABLE c_tool_intro MODIFY COLUMN session_id int unsigned NOT NULL");
  369. $this->addSql("ALTER TABLE c_tool_intro DROP PRIMARY KEY");
  370. $this->addSql("ALTER TABLE c_tool_intro MODIFY COLUMN session_id int unsigned DEFAULT NULL");
  371. $this->addSql("ALTER TABLE c_tool_intro ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  372. $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN c_id INT NOT NULL");
  373. $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id INT DEFAULT NULL");
  374. $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned NOT NULL");
  375. $this->addSql("ALTER TABLE c_quiz_answer DROP PRIMARY KEY");
  376. $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN id_auto int unsigned DEFAULT NULL");
  377. $this->addSql("ALTER TABLE c_quiz_answer ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  378. $this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN c_id INT NOT NULL");
  379. $this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN question_id int unsigned NOT NULL");
  380. $this->addSql("ALTER TABLE c_quiz_question_rel_category DROP PRIMARY KEY");
  381. $this->addSql("ALTER TABLE c_quiz_question_rel_category MODIFY COLUMN question_id int unsigned DEFAULT NULL");
  382. $this->addSql("ALTER TABLE c_quiz_question_rel_category ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  383. $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN id_session int");
  384. $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN id_user int");
  385. $this->addSql("ALTER TABLE session_rel_user MODIFY COLUMN relation_type int unsigned DEFAULT 0");
  386. $this->addSql("ALTER TABLE session_rel_user DROP PRIMARY KEY");
  387. $this->addSql("ALTER TABLE session_rel_user CHANGE id_session session_id int");
  388. $this->addSql("ALTER TABLE session_rel_user CHANGE id_user user_id int");
  389. $this->addSql("DELETE FROM session_rel_user WHERE user_id NOT IN (SELECT id FROM user)");
  390. $this->addSql("ALTER TABLE session_rel_user ADD COLUMN id int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  391. $this->addSql("ALTER TABLE c_item_property CHANGE id_session session_id int");
  392. $this->addSql("ALTER TABLE course_rel_user CHANGE tutor_id is_tutor int");
  393. $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN c_id INT NOT NULL");
  394. $this->addSql("ALTER TABLE c_quiz_rel_question DROP PRIMARY KEY");
  395. $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN question_id int unsigned DEFAULT NULL");
  396. $this->addSql("ALTER TABLE c_quiz_rel_question MODIFY COLUMN exercice_id int unsigned DEFAULT NULL");
  397. $this->addSql("ALTER TABLE c_quiz_rel_question ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  398. $this->addSql("ALTER TABLE c_role MODIFY COLUMN role_id int unsigned NOT NULL");
  399. $this->addSql("ALTER TABLE c_role MODIFY COLUMN c_id INT NOT NULL");
  400. $this->addSql("ALTER TABLE c_role DROP PRIMARY KEY");
  401. $this->addSql("ALTER TABLE c_role MODIFY COLUMN role_id int unsigned DEFAULT NULL");
  402. $this->addSql("ALTER TABLE c_role ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  403. $this->addSql("ALTER TABLE c_role_user DROP PRIMARY KEY");
  404. $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN role_id int unsigned DEFAULT NULL");
  405. $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN user_id int unsigned DEFAULT NULL");
  406. $this->addSql("ALTER TABLE c_role_user MODIFY COLUMN c_id INT NOT NULL");
  407. $this->addSql("ALTER TABLE c_role_user ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  408. $this->addSql("ALTER TABLE c_survey MODIFY COLUMN survey_id int NOT NULL");
  409. $this->addSql("ALTER TABLE c_survey MODIFY COLUMN c_id INT NOT NULL");
  410. $this->addSql("ALTER TABLE c_survey DROP PRIMARY KEY");
  411. $this->addSql("ALTER TABLE c_survey MODIFY COLUMN survey_id int NULL");
  412. $this->addSql("ALTER TABLE c_survey ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  413. $this->addSql("ALTER TABLE c_survey_answer MODIFY COLUMN answer_id int unsigned NOT NULL");
  414. $this->addSql("ALTER TABLE c_survey_answer MODIFY COLUMN c_id INT NOT NULL");
  415. $this->addSql("ALTER TABLE c_survey_answer DROP PRIMARY KEY");
  416. $this->addSql("ALTER TABLE c_survey_answer MODIFY COLUMN answer_id int unsigned DEFAULT NULL");
  417. $this->addSql("ALTER TABLE c_survey_answer ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  418. $this->addSql("ALTER TABLE c_survey_invitation MODIFY COLUMN survey_invitation_id int unsigned NOT NULL");
  419. $this->addSql("ALTER TABLE c_survey_invitation MODIFY COLUMN c_id INT NOT NULL");
  420. $this->addSql("ALTER TABLE c_survey_invitation DROP PRIMARY KEY");
  421. $this->addSql("ALTER TABLE c_survey_invitation MODIFY COLUMN survey_invitation_id int unsigned DEFAULT NULL");
  422. $this->addSql("ALTER TABLE c_survey_invitation ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  423. $this->addSql("ALTER TABLE c_survey_question MODIFY COLUMN question_id int unsigned NOT NULL");
  424. $this->addSql("ALTER TABLE c_survey_question MODIFY COLUMN c_id INT NOT NULL");
  425. $this->addSql("ALTER TABLE c_survey_question DROP PRIMARY KEY");
  426. $this->addSql("ALTER TABLE c_survey_question MODIFY COLUMN question_id int unsigned DEFAULT NULL");
  427. $this->addSql("ALTER TABLE c_survey_question ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  428. $this->addSql("ALTER TABLE c_survey_question_option MODIFY COLUMN question_option_id int unsigned NOT NULL");
  429. $this->addSql("ALTER TABLE c_survey_question_option MODIFY COLUMN c_id INT NOT NULL");
  430. $this->addSql("ALTER TABLE c_survey_question_option DROP PRIMARY KEY");
  431. $this->addSql("ALTER TABLE c_survey_question_option MODIFY COLUMN question_option_id int unsigned DEFAULT NULL");
  432. $this->addSql("ALTER TABLE c_survey_question_option ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  433. $this->addSql("ALTER TABLE c_wiki_conf DROP PRIMARY KEY");
  434. $this->addSql("ALTER TABLE c_wiki_conf MODIFY COLUMN page_id int unsigned DEFAULT NULL");
  435. $this->addSql("ALTER TABLE c_wiki_conf MODIFY COLUMN c_id INT NOT NULL");
  436. $this->addSql("ALTER TABLE c_wiki_conf ADD COLUMN iid int NOT NULL PRIMARY KEY AUTO_INCREMENT");
  437. // Course
  438. $this->addSql("ALTER TABLE c_survey ADD COLUMN visible_results INT UNSIGNED DEFAULT 0");
  439. $this->addSql("ALTER TABLE c_survey_invitation ADD COLUMN group_id INT NOT NULL");
  440. $this->addSql("ALTER TABLE c_lp_item ADD COLUMN prerequisite_min_score float");
  441. $this->addSql("ALTER TABLE c_lp_item ADD COLUMN prerequisite_max_score float");
  442. $table = $schema->getTable('c_group_info');
  443. if (!$table->hasColumn('status')) {
  444. $this->addSql("ALTER TABLE c_group_info ADD COLUMN status tinyint DEFAULT 1");
  445. }
  446. $table = $schema->getTable('c_student_publication');
  447. if (!$table->hasColumn('document_id')) {
  448. $this->addSql("ALTER TABLE c_student_publication ADD COLUMN document_id int DEFAULT 0");
  449. }
  450. $this->addSql("ALTER TABLE c_lp_item MODIFY COLUMN description VARCHAR(511) DEFAULT ''");
  451. $this->addSql("ALTER TABLE course_category MODIFY COLUMN auth_course_child VARCHAR(40) DEFAULT 'TRUE' ");
  452. $this->addSql("ALTER TABLE course_category MODIFY COLUMN auth_cat_child VARCHAR(40) DEFAULT 'TRUE'");
  453. $this->addSql("ALTER TABLE c_quiz_answer MODIFY COLUMN hotspot_type varchar(40) default NULL");
  454. $this->addSql("ALTER TABLE c_tool MODIFY COLUMN target varchar(20) NOT NULL default '_self' ");
  455. $this->addSql("ALTER TABLE c_link MODIFY COLUMN on_homepage char(10) NOT NULL default '0' ");
  456. $this->addSql("ALTER TABLE c_blog_rating MODIFY COLUMN rating_type char(40) NOT NULL default 'post' ");
  457. $this->addSql("ALTER TABLE c_survey MODIFY COLUMN anonymous char(10) NOT NULL default '0'");
  458. $this->addSql("ALTER TABLE c_course_setting MODIFY COLUMN value varchar(255) default ''");
  459. $this->addSql("UPDATE course_field SET field_type = 13 WHERE field_variable = 'special_course'");
  460. $this->addSql("UPDATE user SET registration_date = NULL WHERE registration_date = '0000-00-00 00:00:00'");
  461. $this->addSql("UPDATE user SET expiration_date = NULL WHERE expiration_date = '0000-00-00 00:00:00'");
  462. $this->addSql("UPDATE track_e_default SET default_date = NULL WHERE default_date = '0000-00-00 00:00:00'");
  463. $this->addSql("UPDATE track_e_lastaccess SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'");
  464. $this->addSql("UPDATE track_e_downloads SET down_date = NULL WHERE down_date = '0000-00-00 00:00:00'");
  465. $this->addSql("UPDATE track_e_access SET access_date = NULL WHERE access_date = '0000-00-00 00:00:00'");
  466. $this->addSql("UPDATE track_e_access SET c_id = (SELECT id FROM course WHERE code = access_cours_code)");
  467. $this->addSql("UPDATE track_e_default SET c_id = (SELECT id FROM course WHERE code = default_cours_code)");
  468. $this->addSql("UPDATE track_e_lastaccess SET c_id = (SELECT id FROM course WHERE code = access_cours_code)");
  469. $this->addSql("UPDATE track_e_exercices SET c_id = (SELECT id FROM course WHERE code = exe_cours_id)");
  470. $this->addSql("UPDATE track_e_downloads SET c_id = (SELECT id FROM course WHERE code = down_cours_id)");
  471. $this->addSql("UPDATE track_e_hotpotatoes SET c_id = (SELECT id FROM course WHERE code = exe_cours_id)");
  472. $this->addSql("UPDATE track_e_links SET c_id = (SELECT id FROM course WHERE code = links_cours_id)");
  473. $this->addSql("UPDATE track_e_course_access SET c_id = (SELECT id FROM course WHERE code = course_code)");
  474. $this->addSql("UPDATE track_e_online SET c_id = (SELECT id FROM course WHERE code = course)");
  475. $this->addSql("UPDATE track_e_attempt SET c_id = (SELECT id FROM course WHERE code = course_code)");
  476. $this->addSql("UPDATE course_field_values SET c_id = (SELECT id FROM course WHERE code = course_code)");
  477. $this->addSql("UPDATE session_rel_course_rel_user SET c_id = (SELECT id FROM course WHERE code = course_code)");
  478. $this->addSql('DELETE FROM session_rel_course WHERE course_code NOT IN (SELECT code FROM course)');
  479. $this->addSql("UPDATE session_rel_course SET c_id = (SELECT id FROM course WHERE code = course_code)");
  480. $this->addSql("DELETE FROM access_url_rel_course WHERE course_code NOT IN (SELECT code FROM course)");
  481. $this->addSql("UPDATE access_url_rel_course SET c_id = (SELECT id FROM course WHERE code = course_code)");
  482. $this->addSql("ALTER TABLE settings_current DROP INDEX unique_setting");
  483. $this->addSql("ALTER TABLE settings_options DROP INDEX unique_setting_option");
  484. $this->addSql("DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'");
  485. $this->addSql("DELETE FROM settings_current WHERE variable = 'wcag_anysurfer_public_pages'");
  486. $this->addSql("DELETE FROM settings_options WHERE variable = 'wcag_anysurfer_public_pages'");
  487. $this->addSql("DELETE FROM settings_current WHERE variable = 'advanced_filemanager'");
  488. $this->addSql("DELETE FROM settings_options WHERE variable = 'advanced_filemanager'");
  489. // Fixes missing options show_glossary_in_extra_tools
  490. $sql = "SELECT * FROM settings_current WHERE variable = 'institution_address'";
  491. $result = $connection->executeQuery($sql);
  492. $count = $result->rowCount();
  493. if (empty($count)) {
  494. $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('institution_address', NULL, 'textfield', 'Platform', '', 'InstitutionAddressTitle', 'InstitutionAddressComment', NULL, NULL, 1)");
  495. }
  496. $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('prevent_session_admins_to_manage_all_users', NULL, 'radio', 'Session', 'false', 'PreventSessionAdminsToManageAllUsersTitle', 'PreventSessionAdminsToManageAllUsersComment', NULL, NULL, 1)");
  497. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('prevent_session_admins_to_manage_all_users', 'true', 'Yes'), ('prevent_session_admins_to_manage_all_users', 'false', 'No')");
  498. // Fixes missing options show_glossary_in_extra_tools
  499. $sql = "SELECT * FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'";
  500. $result = $connection->executeQuery($sql);
  501. $count = $result->rowCount();
  502. if (empty($count)) {
  503. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'none', 'None')");
  504. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise', 'Exercise')");
  505. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'Learning path')");
  506. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')");
  507. }
  508. $sql = "SELECT * FROM settings_current WHERE variable = 'documents_default_visibility_defined_in_course'";
  509. $result = $connection->executeQuery($sql);
  510. $count = $result->rowCount();
  511. if (empty($count)) {
  512. $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('documents_default_visibility_defined_in_course', NULL,'radio','Tools','false','DocumentsDefaultVisibilityDefinedInCourseTitle','DocumentsDefaultVisibilityDefinedInCourseComment',NULL, NULL, 1)");
  513. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'true', 'Yes')");
  514. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('documents_default_visibility_defined_in_course', 'false', 'No')");
  515. }
  516. $this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('enabled_mathjax', NULL, 'radio', 'Editor', 'false', 'EnableMathJaxTitle', 'EnableMathJaxComment', NULL, NULL, 0)");
  517. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'true', 'Yes')");
  518. $this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('enabled_mathjax', 'false', 'No')");
  519. $this->addSql("INSERT INTO language (original_name, english_name, isocode, dokeos_folder, available) VALUES ('Føroyskt', 'faroese', 'fo', 'faroese', 0), ('Tagalog', 'tagalog', 'tl', 'tagalog',1), ('Tibetan', 'tibetan', 'bo', 'tibetan', 0), ('isiXhosa', 'xhosa', 'xh', 'xhosa', 0)");
  520. $this->addSql("ALTER TABLE c_student_publication MODIFY COLUMN date_of_qualification DATETIME NULL DEFAULT NULL");
  521. $this->addSql("ALTER TABLE c_student_publication MODIFY COLUMN sent_date DATETIME NULL DEFAULT NULL");
  522. $this->addSql("UPDATE c_student_publication SET date_of_qualification = NULL WHERE date_of_qualification = '0000-00-00 00:00:00'");
  523. $this->addSql("UPDATE c_student_publication SET sent_date = NULL WHERE sent_date = '0000-00-00 00:00:00'");
  524. $this->addSql("ALTER TABLE c_student_publication_assignment MODIFY COLUMN expires_on DATETIME NULL DEFAULT NULL");
  525. $this->addSql("ALTER TABLE c_student_publication_assignment MODIFY COLUMN ends_on DATETIME NULL DEFAULT NULL");
  526. $this->addSql("UPDATE c_student_publication_assignment SET expires_on = NULL WHERE expires_on = '0000-00-00 00:00:00'");
  527. $this->addSql("UPDATE c_student_publication_assignment SET ends_on = NULL WHERE ends_on = '0000-00-00 00:00:00'");
  528. $this->addSql("UPDATE settings_current SET type = 'checkbox' WHERE variable = 'registration' AND category = 'User'");
  529. $this->addSql("UPDATE settings_current SET selected_value = 'UTF-8' WHERE variable = 'platform_charset'");
  530. $this->addSql("ALTER TABLE course_rel_user DROP PRIMARY KEY");
  531. $this->addSql("ALTER TABLE course_rel_user ADD COLUMN id INT NOT NULL PRIMARY KEY AUTO_INCREMENT");
  532. $this->addSql("ALTER TABLE course_rel_user MODIFY COLUMN user_id INT NULL");
  533. $this->addSql("ALTER TABLE user MODIFY COLUMN user_id INT NULL");
  534. $this->addSql("ALTER TABLE access_url_rel_course DROP PRIMARY KEY");
  535. $this->addSql("ALTER TABLE access_url_rel_course ADD COLUMN id INT NOT NULL PRIMARY KEY AUTO_INCREMENT");
  536. $this->addSql("ALTER TABLE access_url_rel_course DROP COLUMN course_code");
  537. $this->addSql("ALTER TABLE access_url_rel_course ADD INDEX idx_select_c (c_id)");
  538. $this->addSql("ALTER TABLE access_url_rel_course ADD INDEX idx_select_u (access_url_id)");
  539. $this->addSql("ALTER TABLE access_url ADD COLUMN url_type TINYINT(1) NULL");
  540. $this->addSql("ALTER TABLE course_rel_user ADD INDEX idx_select_c (c_id)");
  541. $this->addSql("ALTER TABLE track_e_uploads ADD COLUMN c_id INT NOT NULL");
  542. $this->addSql("UPDATE track_e_uploads SET c_id = (SELECT id FROM course WHERE code = upload_cours_id)");
  543. //postUp
  544. $this->addSql("ALTER TABLE track_e_access DROP COLUMN access_cours_code");
  545. $this->addSql("ALTER TABLE track_e_default DROP COLUMN default_cours_code");
  546. $this->addSql("ALTER TABLE track_e_lastaccess DROP COLUMN access_cours_code");
  547. $this->addSql("ALTER TABLE track_e_exercices DROP COLUMN exe_cours_id");
  548. $this->addSql("ALTER TABLE track_e_downloads DROP COLUMN down_cours_id");
  549. $this->addSql("ALTER TABLE track_e_hotpotatoes DROP COLUMN exe_cours_id");
  550. $this->addSql("ALTER TABLE track_e_links DROP COLUMN links_cours_id");
  551. $this->addSql("ALTER TABLE track_e_course_access DROP COLUMN course_code");
  552. $this->addSql("ALTER TABLE track_e_online DROP COLUMN course");
  553. $this->addSql("ALTER TABLE track_e_attempt DROP COLUMN course_code");
  554. $this->addSql("ALTER TABLE course_rel_user DROP COLUMN group_id");
  555. $this->addSql("ALTER TABLE course_rel_user DROP COLUMN role");
  556. $this->addSql("DROP TABLE track_c_countries");
  557. $this->addSql("DROP TABLE track_c_browsers");
  558. $this->addSql("DROP TABLE track_c_os");
  559. $this->addSql("DROP TABLE track_c_providers");
  560. $this->addSql("DROP TABLE track_c_referers");
  561. }
  562. /**
  563. * We don't allow downgrades yet
  564. * @param Schema $schema
  565. */
  566. public function down(Schema $schema)
  567. {
  568. }
  569. }