Version110.php 42 KB

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