upgrade app

This commit is contained in:
Xes
2025-08-14 22:33:03 +02:00
parent d862a535e5
commit 2fe1c43b3e
39284 changed files with 991979 additions and 0 deletions

View File

@@ -0,0 +1,567 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version111
* Migrate file to updated to Chamilo 1.11
*
*/
class Version111 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
// Needed to update 0000-00-00 00:00:00 values
$this->addSql('SET sql_mode = ""');
// In case this one didn't work, also try this
$this->addSql('SET SESSION sql_mode = ""');
$this->addSql("ALTER TABLE extra_field ENGINE=InnoDB");
$this->addSql('CREATE TABLE extra_field_saved_search (id INT AUTO_INCREMENT NOT NULL, field_id INT DEFAULT NULL, user_id INT DEFAULT NULL, value LONGTEXT DEFAULT NULL COLLATE utf8_unicode_ci, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_16ABE32A443707B0 (field_id), INDEX IDX_16ABE32AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE extra_field_saved_search ADD CONSTRAINT FK_16ABE32A443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id)');
$this->addSql('ALTER TABLE extra_field_saved_search ADD CONSTRAINT FK_16ABE32AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql("ALTER TABLE extra_field_saved_search CHANGE value value LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)'");
$this->addSql('CREATE TABLE c_lp_category_user (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, INDEX IDX_61F042712469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE c_lp_category_user ADD CONSTRAINT FK_61F042712469DE2 FOREIGN KEY (category_id) REFERENCES c_lp_category (iid)');
$this->addSql('ALTER TABLE c_lp_category_user ADD user_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE c_lp_category_user ADD CONSTRAINT FK_61F0427A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
$this->addSql('CREATE INDEX IDX_61F0427A76ED395 ON c_lp_category_user (user_id);');
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_my_files',NULL,'radio','Platform','true','AllowMyFilesTitle','AllowMyFilesComment','',NULL, 1)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_my_files','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_my_files','false','No') ");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('exercise_invisible_in_session',NULL,'radio','Session','false','ExerciseInvisibleInSessionTitle','ExerciseInvisibleInSessionComment','',NULL, 1)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('exercise_invisible_in_session','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('exercise_invisible_in_session','false','No') ");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('configure_exercise_visibility_in_course',NULL,'radio','Session','false','ConfigureExerciseVisibilityInCourseTitle','ConfigureExerciseVisibilityInCourseComment','',NULL, 1)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('configure_exercise_visibility_in_course','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('configure_exercise_visibility_in_course','false','No') ");
$this->addSql("ALTER TABLE c_forum_forum ADD moderated TINYINT(1) DEFAULT NULL");
$this->addSql("ALTER TABLE c_forum_post ADD status INT DEFAULT NULL");
$this->addSql("CREATE TABLE IF NOT EXISTS c_quiz_rel_category (iid BIGINT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, category_id INT NOT NULL, exercise_id INT NOT NULL, count_questions INT NOT NULL, PRIMARY KEY(iid))");
$table = $schema->getTable('c_quiz');
if (!$table->hasColumn('question_selection_type')) {
$this->addSql("ALTER TABLE c_quiz ADD COLUMN question_selection_type INT");
}
$this->addSql("ALTER TABLE c_quiz ADD hide_question_title TINYINT(1) DEFAULT 0");
$this->addSql("CREATE TABLE faq_question_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_C2D1A2C2AC5D3 (translatable_id), UNIQUE INDEX faq_question_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE faq_category_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT DEFAULT NULL, headline VARCHAR(255) NOT NULL, body LONGTEXT DEFAULT NULL, slug VARCHAR(50) NOT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_5493B0FC2C2AC5D3 (translatable_id), UNIQUE INDEX faq_category_translation_unique_translation (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE faq_category (id INT AUTO_INCREMENT NOT NULL, rank INT NOT NULL, is_active TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX is_active_idx (is_active), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE faq_question (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, is_active TINYINT(1) NOT NULL, rank INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, only_auth_users TINYINT(1) NOT NULL, INDEX IDX_4A55B05912469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("ALTER TABLE faq_question_translation ADD CONSTRAINT FK_C2D1A2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES faq_question (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE faq_category_translation ADD CONSTRAINT FK_5493B0FC2C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES faq_category (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE faq_question ADD CONSTRAINT FK_4A55B05912469DE2 FOREIGN KEY (category_id) REFERENCES faq_category (id);");
$this->addSql("CREATE TABLE contact_category (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$table = $schema->getTable('session_rel_user');
if (!$table->hasColumn('duration')) {
$this->addSql("ALTER TABLE session_rel_user ADD duration INT DEFAULT NULL");
}
$this->addSql('CREATE TABLE access_url_rel_course_category (id INT AUTO_INCREMENT NOT NULL, access_url_id INT NOT NULL, course_category_id INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$stmt = $this->connection->query('SELECT id FROM course_category');
$results = $stmt->fetchAll();
foreach ($results as $result) {
$this->addSql("
INSERT INTO access_url_rel_course_category (access_url_id, course_category_id)
VALUES (1, {$result['id']})
");
}
$this->addSql('ALTER TABLE notification CHANGE content content TEXT');
$this->addSql('ALTER TABLE c_lp CHANGE publicated_on publicated_on DATETIME');
$this->addSql('ALTER TABLE c_lp CHANGE expired_on expired_on DATETIME');
$this->addSql('UPDATE c_lp SET publicated_on = NULL WHERE publicated_on = "0000-00-00 00:00:00"');
$this->addSql('UPDATE c_lp SET expired_on = NULL WHERE expired_on = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_quiz CHANGE start_time start_time DATETIME');
$this->addSql('ALTER TABLE c_quiz CHANGE end_time end_time DATETIME');
$this->addSql('UPDATE c_quiz SET start_time = NULL WHERE start_time = "0000-00-00 00:00:00"');
$this->addSql('UPDATE c_quiz SET end_time = NULL WHERE end_time = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_calendar_event CHANGE start_date start_date DATETIME');
$this->addSql('ALTER TABLE c_calendar_event CHANGE end_date end_date DATETIME');
$this->addSql('UPDATE c_calendar_event SET start_date = NULL WHERE start_date = "0000-00-00 00:00:00"');
$this->addSql('UPDATE c_calendar_event SET end_date = NULL WHERE end_date = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE personal_agenda CHANGE date date DATETIME');
$this->addSql('ALTER TABLE personal_agenda CHANGE enddate enddate DATETIME');
$this->addSql('UPDATE personal_agenda SET date = NULL WHERE date = "0000-00-00 00:00:00"');
$this->addSql('UPDATE personal_agenda SET enddate = NULL WHERE enddate = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_forum_forum CHANGE start_time start_time DATETIME');
$this->addSql('ALTER TABLE c_forum_forum CHANGE end_time end_time DATETIME');
$this->addSql('UPDATE c_forum_forum SET start_time = NULL WHERE start_time = "0000-00-00 00:00:00"');
$this->addSql('UPDATE c_forum_forum SET end_time = NULL WHERE end_time = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE sys_calendar CHANGE start_date start_date DATETIME');
$this->addSql('ALTER TABLE sys_calendar CHANGE end_date end_date DATETIME');
$this->addSql('UPDATE sys_calendar SET start_date = NULL WHERE start_date = "0000-00-00 00:00:00"');
$this->addSql('UPDATE sys_calendar SET end_date = NULL WHERE end_date = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE message ADD votes INT DEFAULT NULL');
$this->addSql('ALTER TABLE message CHANGE update_date update_date DATETIME');
$this->addSql('UPDATE message SET update_date = NULL WHERE update_date = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_wiki_conf CHANGE startdate_assig startdate_assig DATETIME');
$this->addSql('ALTER TABLE c_wiki_conf CHANGE enddate_assig enddate_assig DATETIME');
$this->addSql('UPDATE c_wiki_conf SET startdate_assig = NULL WHERE startdate_assig = "0000-00-00 00:00:00"');
$this->addSql('UPDATE c_wiki_conf SET enddate_assig = NULL WHERE enddate_assig = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_wiki CHANGE time_edit time_edit DATETIME');
$this->addSql('UPDATE c_wiki SET time_edit = NULL WHERE time_edit = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE c_wiki CHANGE dtime dtime DATETIME');
$this->addSql('UPDATE c_wiki SET dtime = NULL WHERE dtime = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE access_url CHANGE tms tms DATETIME');
$this->addSql('UPDATE access_url SET tms = NULL WHERE tms = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE track_e_attempt CHANGE tms tms DATETIME');
$this->addSql('UPDATE track_e_attempt SET tms = NULL WHERE tms = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE track_e_default CHANGE default_date default_date DATETIME');
$this->addSql('UPDATE track_e_default SET default_date = NULL WHERE default_date = "0000-00-00 00:00:00"');
$this->addSql('ALTER TABLE track_e_exercises CHANGE expired_time_control expired_time_control DATETIME');
$this->addSql('DROP TABLE group_rel_user');
$this->addSql('DROP TABLE group_rel_tag');
$this->addSql('DROP TABLE group_rel_group');
$this->addSql('DROP TABLE groups');
if ($schema->hasTable('plugin_ticket_ticket')) {
// Mean plugin was installed
$this->addSql('ALTER TABLE plugin_ticket_ticket ADD COLUMN subject varchar(255) DEFAULT NULL;');
$this->addSql('ALTER TABLE plugin_ticket_ticket ADD COLUMN message text NOT NULL;');
$this->addSql('UPDATE plugin_ticket_ticket t INNER JOIN plugin_ticket_message as m ON(t.ticket_id = m.ticket_id and message_id =1) SET t.subject = m.subject');
$this->addSql('UPDATE plugin_ticket_ticket t INNER JOIN plugin_ticket_message as m ON(t.ticket_id = m.ticket_id and message_id =1) SET t.message = m.message');
$this->addSql('DELETE FROM plugin_ticket_message WHERE message_id = 1');
$this->addSql('UPDATE plugin_ticket_project SET sys_insert_user_id = 1 WHERE sys_insert_user_id IS NULL');
$this->addSql('UPDATE plugin_ticket_project SET sys_insert_datetime = NOW() WHERE sys_insert_datetime IS NULL');
$this->addSql('ALTER TABLE plugin_ticket_ticket MODIFY ticket_id INT UNSIGNED NOT NULL;');
$this->addSql('DROP INDEX UN_ticket_code ON plugin_ticket_ticket;');
$this->addSql('DROP INDEX FK_ticket_category ON plugin_ticket_ticket;');
$this->addSql('ALTER TABLE plugin_ticket_ticket DROP PRIMARY KEY;');
$this->addSql('ALTER TABLE plugin_ticket_ticket ADD id INT, ADD code VARCHAR(255) NOT NULL');
$this->addSql('UPDATE plugin_ticket_priority SET sys_insert_datetime = NOW() WHERE sys_insert_datetime IS NULL');
$this->addSql('UPDATE plugin_ticket_priority SET sys_insert_user_id = 1 WHERE sys_insert_user_id IS NULL');
$this->addSql('ALTER TABLE plugin_ticket_priority ADD code VARCHAR(255) NOT NULL, ADD name VARCHAR(255) NOT NULL, ADD description LONGTEXT DEFAULT NULL, ADD color VARCHAR(255) NOT NULL, ADD urgency VARCHAR(255) NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;');
$this->addSql('UPDATE plugin_ticket_priority SET code = priority_id');
$this->addSql('UPDATE plugin_ticket_priority SET name = priority');
$this->addSql('UPDATE plugin_ticket_priority SET description = priority_desc');
$this->addSql('UPDATE plugin_ticket_priority SET color = priority_color');
$this->addSql('UPDATE plugin_ticket_priority SET urgency = priority_urgency');
$this->addSql('ALTER TABLE plugin_ticket_status ADD code VARCHAR(255) NOT NULL, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT DEFAULT NULL;');
$this->addSql('UPDATE plugin_ticket_status SET code = status_id ');
$this->addSql('ALTER TABLE plugin_ticket_status DROP status_id');
$this->addSql('UPDATE plugin_ticket_ticket t SET priority_id = (SELECT id FROM plugin_ticket_priority t2 WHERE t2.code = t.priority_id)');
$this->addSql('UPDATE plugin_ticket_ticket t SET status_id = (SELECT id FROM plugin_ticket_status t2 WHERE t2.code = t.status_id)');
$this->addSql('ALTER TABLE plugin_ticket_ticket CHANGE project_id project_id INT DEFAULT NULL, CHANGE priority_id priority_id INT DEFAULT NULL, CHANGE course_id course_id INT DEFAULT NULL, CHANGE session_id session_id INT DEFAULT NULL, CHANGE personal_email personal_email VARCHAR(255) NOT NULL, CHANGE assigned_last_user assigned_last_user INT DEFAULT NULL, CHANGE status_id status_id INT DEFAULT NULL, CHANGE total_messages total_messages INT NOT NULL, CHANGE keyword keyword VARCHAR(255) DEFAULT NULL, CHANGE source source VARCHAR(255) DEFAULT NULL, CHANGE start_date start_date DATETIME DEFAULT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL, CHANGE subject subject VARCHAR(255) NOT NULL, CHANGE message message LONGTEXT DEFAULT NULL;');
$this->addSql('UPDATE plugin_ticket_ticket SET code = ticket_code');
$this->addSql('UPDATE plugin_ticket_ticket SET id = ticket_id');
$this->addSql('ALTER TABLE plugin_ticket_ticket DROP ticket_id, DROP ticket_code, DROP request_user');
$this->addSql('ALTER TABLE plugin_ticket_ticket MODIFY COLUMN id INT NOT NULL PRIMARY KEY AUTO_INCREMENT');
$table = $schema->getTable('plugin_ticket_ticket');
if ($table->hasIndex('fk_ticket_priority')) {
$this->addSql('ALTER TABLE plugin_ticket_ticket DROP INDEX fk_ticket_priority, ADD INDEX IDX_EDE2C768497B19F9(priority_id)');
}
if ($schema->hasTable('plugin_ticket_assigned_log')) {
$table = $schema->getTable('plugin_ticket_assigned_log');
if ($table->hasIndex('fk_ticket_assigned_log')) {
$this->addSql('ALTER TABLE plugin_ticket_assigned_log DROP INDEX fk_ticket_assigned_log, ADD INDEX IDX_54B65868700047D2(ticket_id);');
}
$this->addSql('RENAME TABLE plugin_ticket_assigned_log TO ticket_assigned_log');
$this->addSql('ALTER TABLE ticket_assigned_log ENGINE=InnoDB');
}
if ($schema->hasTable('plugin_ticket_category')) {
$this->addSql('RENAME TABLE plugin_ticket_category TO ticket_category');
$this->addSql('ALTER TABLE ticket_category ENGINE=InnoDB');
}
if ($schema->hasTable('plugin_ticket_message')) {
$table = $schema->getTable('plugin_ticket_message');
if ($table->hasIndex('fk_tick_message')) {
$this->addSql('ALTER TABLE plugin_ticket_message DROP INDEX fk_tick_message, ADD INDEX IDX_BA71692D700047D2(ticket_id);');
}
$this->addSql('RENAME TABLE plugin_ticket_message TO ticket_message');
$this->addSql('ALTER TABLE ticket_message ENGINE=InnoDB');
}
if ($schema->hasTable('plugin_ticket_priority')) {
$this->addSql('RENAME TABLE plugin_ticket_priority TO ticket_priority');
$this->addSql('ALTER TABLE ticket_priority ENGINE=InnoDB');
}
if ($schema->hasTable('plugin_ticket_project')) {
$this->addSql('RENAME TABLE plugin_ticket_project TO ticket_project');
$this->addSql('ALTER TABLE ticket_project ENGINE=InnoDB');
}
if ($schema->hasTable('plugin_ticket_status')) {
$this->addSql('RENAME TABLE plugin_ticket_status TO ticket_status');
$this->addSql('ALTER TABLE ticket_status ENGINE=InnoDB');
}
$this->addSql('RENAME TABLE plugin_ticket_ticket TO ticket_ticket');
$this->addSql('ALTER TABLE ticket_ticket ENGINE=InnoDB');
$this->addSql('ALTER TABLE ticket_project DROP project_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT DEFAULT NULL, CHANGE email email VARCHAR(255) DEFAULT NULL, CHANGE other_area other_area INT DEFAULT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;');
$this->addSql('UPDATE ticket_category SET sys_insert_user_id = 1 WHERE sys_insert_user_id IS NULL');
$this->addSql('UPDATE ticket_category SET sys_insert_datetime = NOW() WHERE sys_insert_datetime IS NULL');
$this->addSql('UPDATE ticket_category SET course_required = 0 WHERE course_required IS NULL OR course_required = ""');
$this->addSql('UPDATE ticket_category SET project_id = 1 WHERE project_id IS NULL OR project_id = ""');
$this->addSql('ALTER TABLE ticket_category DROP category_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE project_id project_id INT DEFAULT NULL, CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT DEFAULT NULL, CHANGE total_tickets total_tickets INT NOT NULL, CHANGE course_required course_required TINYINT(1) NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE ticket_category ADD CONSTRAINT FK_8325E540166D1F9C FOREIGN KEY (project_id) REFERENCES ticket_project (id);');
$this->addSql('CREATE INDEX IDX_8325E540166D1F9C ON ticket_category (project_id);');
if ($schema->hasTable('plugin_ticket_category_rel_user')) {
$table = $schema->getTable('plugin_ticket_category_rel_user');
$this->addSql('RENAME TABLE plugin_ticket_category_rel_user TO ticket_category_rel_user');
$this->addSql('ALTER TABLE ticket_category_rel_user ENGINE=InnoDB');
$this->addSql('ALTER TABLE ticket_category_rel_user CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE category_id category_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL;');
if ($table->hasIndex('fk_5b8a98712469de2')) {
$table->dropIndex('fk_5b8a98712469de2');
}
if ($table->hasIndex('fk_5b8a987a76ed395')) {
$table->dropIndex('fk_5b8a987a76ed395');
}
$this->addSql('CREATE INDEX IDX_5B8A98712469DE2 ON ticket_category_rel_user (category_id);');
$this->addSql('CREATE INDEX IDX_5B8A987A76ED395 ON ticket_category_rel_user (user_id);');
} else {
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_category_rel_user (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, user_id INT DEFAULT NULL, INDEX IDX_5B8A98712469DE2 (category_id), INDEX IDX_5B8A987A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE ticket_category_rel_user ADD CONSTRAINT FK_5B8A98712469DE2 FOREIGN KEY (category_id) REFERENCES ticket_category (id)');
$this->addSql('ALTER TABLE ticket_category_rel_user ADD CONSTRAINT FK_5B8A987A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
$this->addSql('ALTER TABLE ticket_message DROP message_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE ticket_id ticket_id INT DEFAULT NULL, CHANGE subject subject VARCHAR(255) DEFAULT NULL, CHANGE message message LONGTEXT DEFAULT NULL, CHANGE status status VARCHAR(255) NOT NULL, CHANGE ip_address ip_address VARCHAR(255) NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE ticket_message ADD CONSTRAINT FK_BA71692D700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id);');
if ($schema->hasTable('plugin_ticket_message_attachments')) {
$table = $schema->getTable('plugin_ticket_message_attachments');
if ($table->hasIndex('ticket_message_id_fk')) {
$this->addSql('ALTER TABLE plugin_ticket_message_attachments DROP INDEX ticket_message_id_fk, ADD INDEX IDX_70BF9E26537A1329(message_id);');
}
$this->addSql('RENAME TABLE plugin_ticket_message_attachments TO ticket_message_attachments');
$this->addSql('ALTER TABLE ticket_message_attachments ENGINE=InnoDB');
$this->addSql('ALTER TABLE ticket_message_attachments DROP message_attch_id, CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE message_id message_id INT DEFAULT NULL, CHANGE ticket_id ticket_id INT DEFAULT NULL, CHANGE filename filename LONGTEXT NOT NULL, CHANGE size size INT NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL, CHANGE sys_insert_datetime sys_insert_datetime DATETIME NOT NULL, CHANGE sys_lastedit_user_id sys_lastedit_user_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id);');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26537A1329 FOREIGN KEY (message_id) REFERENCES ticket_message (id);');
$this->addSql('CREATE INDEX IDX_70BF9E26700047D2 ON ticket_message_attachments (ticket_id);');
} else {
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_message_attachments (id INT AUTO_INCREMENT NOT NULL, ticket_id INT DEFAULT NULL, message_id INT DEFAULT NULL, path VARCHAR(255) NOT NULL, filename LONGTEXT NOT NULL, size INT NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_70BF9E26700047D2 (ticket_id), INDEX IDX_70BF9E26537A1329 (message_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id)');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26537A1329 FOREIGN KEY (message_id) REFERENCES ticket_message (id)');
}
$this->addSql('UPDATE ticket_priority SET sys_insert_user_id = 1 WHERE sys_insert_user_id IS NULL');
$this->addSql('UPDATE ticket_priority SET sys_insert_datetime = NOW() WHERE sys_insert_datetime IS NULL');
$this->addSql('ALTER TABLE ticket_priority DROP priority_id, DROP priority, DROP priority_desc, DROP priority_color, DROP priority_urgency');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768497B19F9 FOREIGN KEY (priority_id) REFERENCES ticket_priority (id);');
$this->addSql('UPDATE ticket_ticket SET project_id = 1 WHERE project_id is NULL or project_id = 0');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768166D1F9C FOREIGN KEY (project_id) REFERENCES ticket_project (id);');
$this->addSql('UPDATE ticket_ticket SET course_id = NULL WHERE course_id = 0');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768591CC992 FOREIGN KEY (course_id) REFERENCES course (id);');
$this->addSql('UPDATE ticket_ticket SET session_id = NULL WHERE session_id = 0');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768613FECDF FOREIGN KEY (session_id) REFERENCES session (id);');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C7686BF700BD FOREIGN KEY (status_id) REFERENCES ticket_status (id);');
$this->addSql('CREATE INDEX IDX_EDE2C768166D1F9C ON ticket_ticket (project_id);');
$this->addSql('CREATE INDEX IDX_EDE2C768591CC992 ON ticket_ticket (course_id);');
$this->addSql('CREATE INDEX IDX_EDE2C768613FECDF ON ticket_ticket (session_id);');
$this->addSql('CREATE INDEX IDX_EDE2C7686BF700BD ON ticket_ticket (status_id);');
$this->addSql('ALTER TABLE ticket_assigned_log CHANGE id id INT AUTO_INCREMENT NOT NULL, CHANGE ticket_id ticket_id INT DEFAULT NULL, CHANGE user_id user_id INT DEFAULT NULL, CHANGE assigned_date assigned_date DATETIME NOT NULL, CHANGE sys_insert_user_id sys_insert_user_id INT NOT NULL;');
$this->addSql('ALTER TABLE ticket_assigned_log ADD CONSTRAINT FK_54B65868700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id);');
$this->addSql('DELETE FROM ticket_assigned_log WHERE user_id = 0 OR user_id IS NULL');
$this->addSql('ALTER TABLE ticket_assigned_log ADD CONSTRAINT FK_54B65868A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
$this->addSql('CREATE INDEX IDX_54B65868A76ED395 ON ticket_assigned_log (user_id);');
$this->addSql('ALTER TABLE ticket_ticket CHANGE category_id category_id INT DEFAULT NULL;');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C76812469DE2 FOREIGN KEY (category_id) REFERENCES ticket_category (id);');
$this->addSql('CREATE INDEX IDX_EDE2C76812469DE2 ON ticket_ticket (category_id);');
$this->addSql('DELETE FROM settings_current WHERE title = "Ticket"');
} else {
// Plugin was never installed. Create ticket tables
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_project (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, email VARCHAR(255) DEFAULT NULL, other_area INT DEFAULT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_status (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_category_rel_user (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, user_id INT DEFAULT NULL, INDEX IDX_5B8A98712469DE2 (category_id), INDEX IDX_5B8A987A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_message_attachments (id INT AUTO_INCREMENT NOT NULL, ticket_id INT DEFAULT NULL, message_id INT DEFAULT NULL, path VARCHAR(255) NOT NULL, filename LONGTEXT NOT NULL, size INT NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_70BF9E26700047D2 (ticket_id), INDEX IDX_70BF9E26537A1329 (message_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_priority (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, code VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, color VARCHAR(255) NOT NULL, urgency VARCHAR(255) NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_message (id INT AUTO_INCREMENT NOT NULL, ticket_id INT DEFAULT NULL, subject VARCHAR(255) DEFAULT NULL, message LONGTEXT DEFAULT NULL, status VARCHAR(255) NOT NULL, ip_address VARCHAR(255) NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_BA71692D700047D2 (ticket_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_category (id INT AUTO_INCREMENT NOT NULL, project_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, total_tickets INT NOT NULL, course_required TINYINT(1) NOT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_8325E540166D1F9C (project_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_ticket (id INT AUTO_INCREMENT NOT NULL, project_id INT DEFAULT NULL, category_id INT DEFAULT NULL, priority_id INT DEFAULT NULL, course_id INT DEFAULT NULL, session_id INT DEFAULT NULL, status_id INT DEFAULT NULL, code VARCHAR(255) NOT NULL, subject VARCHAR(255) NOT NULL, message LONGTEXT DEFAULT NULL, personal_email VARCHAR(255) NOT NULL, assigned_last_user INT DEFAULT NULL, total_messages INT NOT NULL, keyword VARCHAR(255) DEFAULT NULL, source VARCHAR(255) DEFAULT NULL, start_date DATETIME DEFAULT NULL, end_date DATETIME DEFAULT NULL, sys_insert_user_id INT NOT NULL, sys_insert_datetime DATETIME NOT NULL, sys_lastedit_user_id INT DEFAULT NULL, sys_lastedit_datetime DATETIME DEFAULT NULL, INDEX IDX_EDE2C768166D1F9C (project_id), INDEX IDX_EDE2C76812469DE2 (category_id), INDEX IDX_EDE2C768497B19F9 (priority_id), INDEX IDX_EDE2C768591CC992 (course_id), INDEX IDX_EDE2C768613FECDF (session_id), INDEX IDX_EDE2C7686BF700BD (status_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('CREATE TABLE IF NOT EXISTS ticket_assigned_log (id INT AUTO_INCREMENT NOT NULL, ticket_id INT DEFAULT NULL, user_id INT DEFAULT NULL, sys_insert_user_id INT NOT NULL, assigned_date DATETIME NOT NULL, INDEX IDX_54B65868700047D2 (ticket_id), INDEX IDX_54B65868A76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
$this->addSql('ALTER TABLE ticket_category_rel_user ADD CONSTRAINT FK_5B8A98712469DE2 FOREIGN KEY (category_id) REFERENCES ticket_category (id)');
$this->addSql('ALTER TABLE ticket_category_rel_user ADD CONSTRAINT FK_5B8A987A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id)');
$this->addSql('ALTER TABLE ticket_message_attachments ADD CONSTRAINT FK_70BF9E26537A1329 FOREIGN KEY (message_id) REFERENCES ticket_message (id)');
$this->addSql('ALTER TABLE ticket_message ADD CONSTRAINT FK_BA71692D700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id)');
$this->addSql('ALTER TABLE ticket_category ADD CONSTRAINT FK_8325E540166D1F9C FOREIGN KEY (project_id) REFERENCES ticket_project (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768166D1F9C FOREIGN KEY (project_id) REFERENCES ticket_project (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C76812469DE2 FOREIGN KEY (category_id) REFERENCES ticket_category (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768497B19F9 FOREIGN KEY (priority_id) REFERENCES ticket_priority (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768591CC992 FOREIGN KEY (course_id) REFERENCES course (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C768613FECDF FOREIGN KEY (session_id) REFERENCES session (id)');
$this->addSql('ALTER TABLE ticket_ticket ADD CONSTRAINT FK_EDE2C7686BF700BD FOREIGN KEY (status_id) REFERENCES ticket_status (id)');
$this->addSql('ALTER TABLE ticket_assigned_log ADD CONSTRAINT FK_54B65868700047D2 FOREIGN KEY (ticket_id) REFERENCES ticket_ticket (id)');
$this->addSql('ALTER TABLE ticket_assigned_log ADD CONSTRAINT FK_54B65868A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
}
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('ticket_allow_student_add', NULL, 'radio','Ticket', 'false','TicketAllowStudentAddTitle','TicketAllowStudentAddComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('ticket_allow_category_edition', NULL, 'radio','Ticket', 'false','TicketAllowCategoryEditionTitle','TicketAllowCategoryEditionComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('ticket_send_warning_to_all_admins', NULL, 'radio','Ticket', 'false','TicketSendWarningToAllAdminsTitle','TicketSendWarningToAllAdminsComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('ticket_warn_admin_no_user_in_category', NULL, 'radio','Ticket', 'false','TicketWarnAdminNoUserInCategoryTitle','TicketWarnAdminNoUserInCategoryComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('load_term_conditions_section', NULL, 'radio','Platform', 'login','LoadTermConditionsSectionTitle','LoadTermConditionsSectionDescription',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_terms_if_profile_completed', NULL, 'radio','Ticket', 'false','ShowTermsIfProfileCompletedTitle','ShowTermsIfProfileCompletedComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('show_link_ticket_notification', NULL, 'radio', 'Platform', 'false', 'ShowLinkTicketNotificationTitle', 'ShowLinkTicketNotificationComment', NULL, NULL, 0)");
// Make sure there isn't already an sso_authentication_subclass before adding an empty one
$stmt = $this->connection->query('SELECT id FROM settings_current WHERE variable = "sso_authentication_subclass" AND access_url = 1');
$results = $stmt->fetchAll();
if (empty($results)) {
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, access_url) VALUES ('sso_authentication_subclass', NULL, 'textfield', 'Security', '', 'SSOSubclassTitle', 'SSOSubclassComment', 1)");
}
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('ticket_allow_student_add', 'true', 'Yes'), ('ticket_allow_student_add', 'false', 'No')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('ticket_allow_category_edition', 'true', 'Yes'), ('ticket_allow_category_edition', 'false', 'No')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('ticket_send_warning_to_all_admins', 'true', 'Yes'), ('ticket_send_warning_to_all_admins', 'false', 'No')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('ticket_warn_admin_no_user_in_category', 'true', 'Yes'), ('ticket_warn_admin_no_user_in_category', 'false', 'No')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('load_term_conditions_section', 'login', 'Login'), ('load_term_conditions_section', 'course', 'Course')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_terms_if_profile_completed', 'true', 'Yes'), ('show_terms_if_profile_completed', 'false', 'No')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_link_ticket_notification', 'true', 'Yes'), ('show_link_ticket_notification', 'false', 'No')");
$table = $schema->getTable('c_quiz_question_rel_category');
if (!$table->hasIndex('idx_qqrc_qid')) {
$this->addSql("ALTER TABLE c_quiz_question_rel_category ADD INDEX idx_qqrc_qid (question_id)");
}
$table = $schema->getTable('c_quiz_answer');
$hasIndex = $table->hasIndex('idx_cqa_q');
if (!$hasIndex) {
$this->addSql("ALTER TABLE c_quiz_answer ADD INDEX idx_cqa_q (question_id)");
}
$this->addSql("ALTER TABLE c_student_publication ADD INDEX idx_csp_u (user_id)");
$this->addSql('ALTER TABLE legal MODIFY COLUMN language_id INT NOT NULL');
$this->addSql('ALTER TABLE legal MODIFY COLUMN legal_id INT NOT NULL');
$this->addSql('ALTER TABLE legal DROP PRIMARY KEY;');
$this->addSql('ALTER TABLE legal ADD id INT');
$this->addSql('UPDATE legal SET id = legal_id');
$this->addSql('UPDATE legal SET id = 1 WHERE id = 0');
$this->addSql('ALTER TABLE legal DROP legal_id');
$this->addSql('ALTER TABLE legal CHANGE id id INT AUTO_INCREMENT NOT NULL PRIMARY KEY;');
$this->addSql('ALTER TABLE user ADD profile_completed TINYINT(1) DEFAULT NULL;');
$this->addSql('ALTER TABLE extra_field_options CHANGE display_text display_text VARCHAR(255) DEFAULT NULL');
$this->addSql('ALTER TABLE extra_field CHANGE variable variable VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE c_course_setting MODIFY COLUMN value TEXT');
$this->addSql("ALTER TABLE session MODIFY COLUMN name VARCHAR(150) NOT NULL DEFAULT ''");
if (!$schema->hasTable('version')) {
$sql = getVersionTable();
$this->addSql($sql);
}
if ($schema->hasTable('resource')) {
$schema->dropTable('resource');
}
$this->addSql('DELETE FROM settings_current WHERE variable = "service_visio"');
$this->addSql('DELETE FROM settings_current WHERE variable = "course_create_active_tools" AND subkey = "online_conference"');
$this->addSql('DELETE FROM settings_options WHERE variable = "visio_use_rtmpt"');
$this->addSql('DELETE FROM course_module WHERE name = "conference"');
$this->addSql('ALTER TABLE c_student_publication_assignment CHANGE add_to_calendar add_to_calendar INT NOT NULL;');
// Fixes missing options show_glossary_in_extra_tools
$this->addSql("DELETE FROM settings_options WHERE variable = 'show_glossary_in_extra_tools'");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'none', 'None')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise', 'Exercise')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'lp', 'LearningPaths')");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')");
// Fixes from 1.10.x
// Promotion
if ($schema->hasTable('promotion')) {
$table = $schema->getTable('promotion');
$this->addSql('ALTER TABLE promotion CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT NOT NULL, CHANGE career_id career_id INT DEFAULT NULL, CHANGE status status INT');
if ($table->hasForeignKey('FK_C11D7DD1B58CDA09') == false) {
$this->addSql('ALTER TABLE promotion ADD CONSTRAINT FK_C11D7DD1B58CDA09 FOREIGN KEY (career_id) REFERENCES career (id);');
}
if ($table->hasIndex('IDX_C11D7DD1B58CDA09') == false) {
$this->addSql('CREATE INDEX IDX_C11D7DD1B58CDA09 ON promotion (career_id);');
}
}
if ($schema->hasTable('skill_profile')) {
$this->addSql('ALTER TABLE skill_profile CHANGE name name VARCHAR(255) NOT NULL, CHANGE description description LONGTEXT NOT NULL;');
}
// skill_rel_user_comment
if ($schema->hasTable('skill_rel_user_comment')) {
$table = $schema->getTable('skill_rel_user_comment');
$this->addSql('ALTER TABLE skill_rel_user_comment CHANGE skill_rel_user_id skill_rel_user_id INT DEFAULT NULL, CHANGE feedback_giver_id feedback_giver_id INT DEFAULT NULL, CHANGE feedback_text feedback_text LONGTEXT NOT NULL, CHANGE feedback_value feedback_value INT DEFAULT 1, CHANGE feedback_datetime feedback_datetime DATETIME NOT NULL;');
if ($table->hasForeignKey('FK_7AE9F6B6484A9317') == false) {
$this->addSql('ALTER TABLE skill_rel_user_comment ADD CONSTRAINT FK_7AE9F6B6484A9317 FOREIGN KEY (skill_rel_user_id) REFERENCES skill_rel_user (id);');
}
if ($table->hasForeignKey('FK_7AE9F6B63AF3B65B') == false) {
$this->addSql('ALTER TABLE skill_rel_user_comment ADD CONSTRAINT FK_7AE9F6B63AF3B65B FOREIGN KEY (feedback_giver_id) REFERENCES user (id);');
}
if ($table->hasIndex('IDX_7AE9F6B6484A9317') == false) {
$this->addSql('CREATE INDEX IDX_7AE9F6B6484A9317 ON skill_rel_user_comment (skill_rel_user_id);');
}
if ($table->hasIndex('IDX_7AE9F6B63AF3B65B') == false) {
$this->addSql('CREATE INDEX IDX_7AE9F6B63AF3B65B ON skill_rel_user_comment (feedback_giver_id);');
}
if ($table->hasIndex('idx_select_su_giver') == false) {
$this->addSql('CREATE INDEX idx_select_su_giver ON skill_rel_user_comment (skill_rel_user_id, feedback_giver_id);');
}
}
$this->addSql('ALTER TABLE skill_rel_gradebook CHANGE type type VARCHAR(10) NOT NULL;');
// access_url_rel_user
if ($schema->hasTable('access_url_rel_user')) {
$table = $schema->getTable('access_url_rel_user');
$this->addSql('ALTER TABLE access_url_rel_user CHANGE access_url_id access_url_id INT NOT NULL, CHANGE user_id user_id INT NOT NULL;');
if ($table->hasForeignKey('FK_85574263A76ED395') == false) {
$this->addSql('ALTER TABLE access_url_rel_user ADD CONSTRAINT FK_85574263A76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
}
if ($table->hasForeignKey('FK_8557426373444FD5') == false) {
$this->addSql('ALTER TABLE access_url_rel_user ADD CONSTRAINT FK_8557426373444FD5 FOREIGN KEY (access_url_id) REFERENCES access_url (id);');
}
}
if ($schema->hasTable('sequence_rule')) {
$table = $schema->getTable('sequence_rule');
if ($table->hasColumn('text')) {
$this->addSql('ALTER TABLE sequence_rule DROP text');
}
if (!$table->hasColumn('description')) {
$this->addSql(
'ALTER TABLE sequence_rule ADD description LONGTEXT NOT NULL'
);
}
}
$this->addSql(
'CREATE TABLE IF NOT EXISTS course_rel_user_catalogue (id int NOT NULL AUTO_INCREMENT, user_id int DEFAULT NULL, c_id int DEFAULT NULL, visible int NOT NULL, PRIMARY KEY (id), KEY (user_id), KEY (c_id), CONSTRAINT FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE, CONSTRAINT FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
);
if ($schema->hasTable('course_rel_user_catalogue')) {
$table = $schema->getTable('course_rel_user_catalogue');
if ($table->hasForeignKey('course_rel_user_catalogue_ibfk_1')) {
$this->addSql('ALTER TABLE course_rel_user_catalogue DROP FOREIGN KEY course_rel_user_catalogue_ibfk_1;');
}
if ($table->hasForeignKey('course_rel_user_catalogue_ibfk_2')) {
$this->addSql('ALTER TABLE course_rel_user_catalogue DROP FOREIGN KEY course_rel_user_catalogue_ibfk_2;');
}
if ($table->hasForeignKey('FK_79CA412EA76ED395') == false) {
$this->addSql('ALTER TABLE course_rel_user_catalogue ADD CONSTRAINT FK_79CA412EA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
}
if ($table->hasForeignKey('FK_79CA412E91D79BD3') == false) {
$this->addSql('ALTER TABLE course_rel_user_catalogue ADD CONSTRAINT FK_79CA412E91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);');
}
}
if ($schema->hasTable('extra_field_values')) {
$table = $schema->getTable('extra_field_values');
if ($table->hasForeignKey('FK_171DF924443707B0') == false) {
$this->addSql('ALTER TABLE extra_field_values ADD CONSTRAINT FK_171DF924443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id);');
}
}
if ($schema->hasTable('extra_field_options')) {
$table = $schema->getTable('extra_field_options');
if ($table->hasForeignKey('FK_A572E3AE443707B0') == false) {
$this->addSql('ALTER TABLE extra_field_options ADD CONSTRAINT FK_A572E3AE443707B0 FOREIGN KEY (field_id) REFERENCES extra_field (id);');
}
}
if ($schema->hasTable('session_rel_course')) {
$table = $schema->getTable('session_rel_course');
if ($table->hasColumn('category')) {
$this->addSql('ALTER TABLE session_rel_course DROP category');
}
}
}
/**
* @param Schema $schema
*/
public function postUp(Schema $schema)
{
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql('DROP TABLE c_lp_category_user');
$this->addSql('DROP TABLE access_url_rel_course_category');
}
}

View File

@@ -0,0 +1,82 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160302133200
*/
class Version20160302133200 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$allowSendPushNotification = $this->getConfigurationValue('messaging_allow_send_push_notification');
$this->addSettingCurrent(
'messaging_allow_send_push_notification',
null,
'radio',
'WebServices',
($allowSendPushNotification ? 'true' : 'false'),
'MessagingAllowSendPushNotificationTitle',
'MessagingAllowSendPushNotificationComment',
null,
'',
1,
true,
false,
[
['value' => 'true', 'text' => 'Yes'],
['value' => 'false', 'text' => 'No'],
]
);
$gdcProjectNumber = $this->getConfigurationValue('messaging_gdc_project_number');
$this->addSettingCurrent(
'messaging_gdc_project_number',
null,
'textfield',
'WebServices',
!empty($gdcProjectNumber) ? $gdcProjectNumber : '',
'MessagingGDCProjectNumberTitle',
'MessagingGDCProjectNumberComment',
null,
'',
1,
true,
false
);
$gdcApiKey = $this->getConfigurationValue('messaging_gdc_api_key');
$this->addSettingCurrent(
'messaging_gdc_api_key',
null,
'textfield',
'WebServices',
!empty($gdcApiKey) ? $gdcApiKey : '',
'MessagingGDCApiKeyTitle',
'MessagingGDCApiKeyComment',
null,
'',
1,
true,
false
);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,31 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160304151300
*/
class Version20160304151300 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("UPDATE extra_field SET visible = 0 WHERE variable IN('mail_notify_invitation', 'mail_notify_message', 'mail_notify_group_message') AND extra_field_type = 1");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,32 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160315155700
* Change type of the course_creation_use_template setting
*/
class Version20160315155700 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("UPDATE settings_current SET type = 'select_course' WHERE variable = 'course_creation_use_template'");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,178 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160330103045
* @package Application\Migrations\Schema\V111
*/
class Version20160330103045 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
/*
$this->addSql(
'CREATE TABLE page__site (id INT AUTO_INCREMENT NOT NULL, enabled TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, relative_path VARCHAR(255) DEFAULT NULL, host VARCHAR(255) NOT NULL, enabled_from DATETIME DEFAULT NULL, enabled_to DATETIME DEFAULT NULL, is_default TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, locale VARCHAR(6) DEFAULT NULL, title VARCHAR(64) DEFAULT NULL, meta_keywords VARCHAR(255) DEFAULT NULL, meta_description VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE page__page (id INT AUTO_INCREMENT NOT NULL, site_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, target_id INT DEFAULT NULL, route_name VARCHAR(255) NOT NULL, page_alias VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, decorate TINYINT(1) NOT NULL, edited TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, slug LONGTEXT DEFAULT NULL, url LONGTEXT DEFAULT NULL, custom_url LONGTEXT DEFAULT NULL, request_method VARCHAR(255) DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, meta_keyword VARCHAR(255) DEFAULT NULL, meta_description VARCHAR(255) DEFAULT NULL, javascript LONGTEXT DEFAULT NULL, stylesheet LONGTEXT DEFAULT NULL, raw_headers LONGTEXT DEFAULT NULL, template VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_2FAE39EDF6BD1646 (site_id), INDEX IDX_2FAE39ED727ACA70 (parent_id), INDEX IDX_2FAE39ED158E0B66 (target_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE page__snapshot (id INT AUTO_INCREMENT NOT NULL, site_id INT DEFAULT NULL, page_id INT DEFAULT NULL, route_name VARCHAR(255) NOT NULL, page_alias VARCHAR(255) DEFAULT NULL, type VARCHAR(255) DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, decorate TINYINT(1) NOT NULL, name VARCHAR(255) NOT NULL, url LONGTEXT DEFAULT NULL, parent_id INT DEFAULT NULL, target_id INT DEFAULT NULL, content LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', publication_date_start DATETIME DEFAULT NULL, publication_date_end DATETIME DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_3963EF9AF6BD1646 (site_id), INDEX IDX_3963EF9AC4663E4 (page_id), INDEX idx_snapshot_dates_enabled (publication_date_start, publication_date_end, enabled), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE page__bloc (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, page_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, type VARCHAR(64) NOT NULL, settings LONGTEXT NOT NULL COMMENT \'(DC2Type:json)\', enabled TINYINT(1) DEFAULT NULL, position INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_FCDC1A97727ACA70 (parent_id), INDEX IDX_FCDC1A97C4663E4 (page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE classification__category (id INT AUTO_INCREMENT NOT NULL, parent_id INT DEFAULT NULL, context VARCHAR(255) DEFAULT NULL, media_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, position INT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_43629B36727ACA70 (parent_id), INDEX IDX_43629B36E25D857E (context), INDEX IDX_43629B36EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE classification__context (id VARCHAR(255) NOT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE classification__tag (id INT AUTO_INCREMENT NOT NULL, context VARCHAR(255) DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_CA57A1C7E25D857E (context), UNIQUE INDEX tag_context (slug, context), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE classification__collection (id INT AUTO_INCREMENT NOT NULL, context VARCHAR(255) DEFAULT NULL, media_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, slug VARCHAR(255) NOT NULL, description VARCHAR(255) DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX IDX_A406B56AE25D857E (context), INDEX IDX_A406B56AEA9FDD75 (media_id), UNIQUE INDEX tag_collection (slug, context), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE media__gallery (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, context VARCHAR(64) NOT NULL, default_format VARCHAR(255) NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE media__media (id INT AUTO_INCREMENT NOT NULL, category_id INT DEFAULT NULL, name VARCHAR(255) NOT NULL, description TEXT DEFAULT NULL, enabled TINYINT(1) NOT NULL, provider_name VARCHAR(255) NOT NULL, provider_status INT NOT NULL, provider_reference VARCHAR(255) NOT NULL, provider_metadata LONGTEXT DEFAULT NULL COMMENT \'(DC2Type:json)\', width INT DEFAULT NULL, height INT DEFAULT NULL, length NUMERIC(10, 0) DEFAULT NULL, content_type VARCHAR(255) DEFAULT NULL, content_size INT DEFAULT NULL, copyright VARCHAR(255) DEFAULT NULL, author_name VARCHAR(255) DEFAULT NULL, context VARCHAR(64) DEFAULT NULL, cdn_is_flushable TINYINT(1) DEFAULT NULL, cdn_flush_identifier VARCHAR(64) DEFAULT NULL, cdn_flush_at DATETIME DEFAULT NULL, cdn_status INT DEFAULT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_5C6DD74E12469DE2 (category_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE media__gallery_media (id INT AUTO_INCREMENT NOT NULL, gallery_id INT DEFAULT NULL, media_id INT DEFAULT NULL, position INT NOT NULL, enabled TINYINT(1) NOT NULL, updated_at DATETIME NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_80D4C5414E7AF8F (gallery_id), INDEX IDX_80D4C541EA9FDD75 (media_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39EDF6BD1646 FOREIGN KEY (site_id) REFERENCES page__site (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39ED727ACA70 FOREIGN KEY (parent_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__page ADD CONSTRAINT FK_2FAE39ED158E0B66 FOREIGN KEY (target_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__snapshot ADD CONSTRAINT FK_3963EF9AF6BD1646 FOREIGN KEY (site_id) REFERENCES page__site (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__snapshot ADD CONSTRAINT FK_3963EF9AC4663E4 FOREIGN KEY (page_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__bloc ADD CONSTRAINT FK_FCDC1A97727ACA70 FOREIGN KEY (parent_id) REFERENCES page__bloc (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE page__bloc ADD CONSTRAINT FK_FCDC1A97C4663E4 FOREIGN KEY (page_id) REFERENCES page__page (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36727ACA70 FOREIGN KEY (parent_id) REFERENCES classification__category (id) ON DELETE CASCADE'
);
$this->addSql(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36E25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$this->addSql(
'ALTER TABLE classification__category ADD CONSTRAINT FK_43629B36EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE SET NULL'
);
$this->addSql(
'ALTER TABLE classification__tag ADD CONSTRAINT FK_CA57A1C7E25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$this->addSql(
'ALTER TABLE classification__collection ADD CONSTRAINT FK_A406B56AE25D857E FOREIGN KEY (context) REFERENCES classification__context (id)'
);
$this->addSql(
'ALTER TABLE classification__collection ADD CONSTRAINT FK_A406B56AEA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id) ON DELETE SET NULL'
);
$this->addSql(
'ALTER TABLE media__media ADD CONSTRAINT FK_5C6DD74E12469DE2 FOREIGN KEY (category_id) REFERENCES classification__category (id) ON DELETE SET NULL'
);
$this->addSql(
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C5414E7AF8F FOREIGN KEY (gallery_id) REFERENCES media__gallery (id)'
);
$this->addSql(
'ALTER TABLE media__gallery_media ADD CONSTRAINT FK_80D4C541EA9FDD75 FOREIGN KEY (media_id) REFERENCES media__media (id)'
);
$this->addSql("CREATE TABLE timeline__timeline (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, subject_id INT DEFAULT NULL, context VARCHAR(255) NOT NULL, type VARCHAR(255) NOT NULL, created_at DATETIME NOT NULL, INDEX IDX_FFBC6AD59D32F035 (action_id), INDEX IDX_FFBC6AD523EDC87 (subject_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__component (id INT AUTO_INCREMENT NOT NULL, model VARCHAR(255) NOT NULL, identifier LONGTEXT NOT NULL COMMENT '(DC2Type:array)', hash VARCHAR(255) NOT NULL, UNIQUE INDEX UNIQ_1B2F01CDD1B862B8 (hash), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__action (id INT AUTO_INCREMENT NOT NULL, verb VARCHAR(255) NOT NULL, status_current VARCHAR(255) NOT NULL, status_wanted VARCHAR(255) NOT NULL, duplicate_key VARCHAR(255) DEFAULT NULL, duplicate_priority INT DEFAULT NULL, created_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("CREATE TABLE timeline__action_component (id INT AUTO_INCREMENT NOT NULL, action_id INT DEFAULT NULL, component_id INT DEFAULT NULL, type VARCHAR(255) NOT NULL, text VARCHAR(255) DEFAULT NULL, INDEX IDX_6ACD1B169D32F035 (action_id), INDEX IDX_6ACD1B16E2ABAFFF (component_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB;");
$this->addSql("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD59D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id);");
$this->addSql("ALTER TABLE timeline__timeline ADD CONSTRAINT FK_FFBC6AD523EDC87 FOREIGN KEY (subject_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B169D32F035 FOREIGN KEY (action_id) REFERENCES timeline__action (id) ON DELETE CASCADE;");
$this->addSql("ALTER TABLE timeline__action_component ADD CONSTRAINT FK_6ACD1B16E2ABAFFF FOREIGN KEY (component_id) REFERENCES timeline__component (id) ON DELETE CASCADE;");
//$this->addSql("CREATE UNIQUE INDEX UNIQ_8D93D649A0D96FBF ON user (email_canonical);");
*/
$table = $schema->getTable('track_stored_values_stack');
$hasIndex = $table->hasIndex('user_sco_course_sv_stack');
if ($hasIndex) {
$this->addSql('DROP INDEX user_sco_course_sv_stack ON track_stored_values_stack');
}
$table = $schema->getTable('session_rel_user');
$hasColumn = $table->hasColumn('duration');
if (!$hasColumn) {
$this->addSql('ALTER TABLE session_rel_user ADD duration INT DEFAULT NULL');
}
$table = $schema->getTable('track_stored_values');
$hasIndex = $table->hasIndex('user_sco_course_sv');
if ($hasIndex) {
$this->addSql('DROP INDEX user_sco_course_sv ON track_stored_values');
}
$table = $schema->getTable('user');
$hasIndex = $table->hasIndex('UNIQ_8D93D649F85E0677');
if ($hasIndex) {
$this->addSql('DROP INDEX UNIQ_8D93D649F85E0677 ON user');
}
$this->addSql('ALTER TABLE user ADD email_canonical VARCHAR(255) NOT NULL');
$this->addSql('ALTER TABLE user ADD credentials_expired TINYINT(1)');
$this->addSql('ALTER TABLE user ADD credentials_expire_at DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE user ADD locked TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE user ADD enabled TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE user ADD expired TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE user ADD expires_at DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE user CHANGE username username VARCHAR(100) NOT NULL');
$this->addSql('ALTER TABLE user CHANGE username_canonical username_canonical VARCHAR(100) NOT NULL');
$this->addSql('ALTER TABLE user CHANGE email email VARCHAR(100) NOT NULL');
$sql = "UPDATE user SET email_canonical = email";
$this->addSql($sql);
$sql = "ALTER TABLE user ADD roles LONGTEXT NOT NULL COMMENT '(DC2Type:array)'";
$this->addSql($sql);
$sql = "UPDATE user SET roles = 'a:0:{}'";
$this->addSql($sql);
$sql = "UPDATE user SET enabled = '1' WHERE active = 1";
$this->addSql($sql);
$sql = "ALTER TABLE user ADD created_at DATETIME DEFAULT NULL, ADD updated_at DATETIME DEFAULT NULL;";
$this->addSql($sql);
$sql = "UPDATE user SET username_canonical = username";
$this->addSql($sql);
$this->addSql("CREATE TABLE fos_group(id INT AUTO_INCREMENT NOT NULL, code VARCHAR(40) NOT NULL, UNIQUE INDEX UNIQ_4B019DDB77153098 (code), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("CREATE TABLE fos_user_user_group (user_id INT NOT NULL, group_id INT NOT NULL, INDEX IDX_B3C77447A76ED395 (user_id), INDEX IDX_B3C77447FE54D947 (group_id), PRIMARY KEY(user_id, group_id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB");
$this->addSql("ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)");
$this->addSql("ALTER TABLE fos_user_user_group ADD CONSTRAINT FK_B3C77447FE54D947 FOREIGN KEY (group_id) REFERENCES fos_group (id)");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,48 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160331103600
*/
class Version20160331103600 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSettingCurrent(
'teacher_can_select_course_template',
null,
'radio',
'Course',
'true',
'TeacherCanSelectCourseTemplateTitle',
'TeacherCanSelectCourseTemplateComment',
null,
'',
1,
true,
false,
[
['value' => 'true', 'text' => 'Yes'],
['value' => 'false', 'text' => 'No'],
]
);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,131 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160405112100
* @package Application\Migrations\Schema\V111
*/
class Version20160405112100 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->addSql(
'CREATE TABLE skill_level_profile (id INT AUTO_INCREMENT NOT NULL, name VARCHAR(255) NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'CREATE TABLE skill_level (id INT AUTO_INCREMENT NOT NULL, profile_id INT NOT NULL, name VARCHAR(255) NOT NULL, position INT, short_name VARCHAR(255), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql(
'ALTER TABLE skill_rel_user ADD acquired_level INT, ADD argumentation TEXT, ADD argumentation_author_id INT, MODIFY course_id INT, MODIFY session_id INT'
);
$this->addSql(
'CREATE TABLE skill_rel_user_comment (id INT AUTO_INCREMENT NOT NULL, skill_rel_user_id INT NOT NULL, feedback_giver_id INT NOT NULL, feedback_text TEXT, feedback_value INT, feedback_datetime DATETIME, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB'
);
$this->addSql('ALTER TABLE skill ADD profile_id INT');
if ($schema->hasTable('skill')) {
$table = $schema->getTable('skill');
if ($table->hasForeignKey('FK_5E3DE477CCFA12B8') == false) {
$this->addSql('ALTER TABLE skill ADD CONSTRAINT FK_5E3DE477CCFA12B8 FOREIGN KEY (profile_id) REFERENCES skill_level_profile (id);');
}
if ($table->hasIndex('IDX_5E3DE477CCFA12B8') == false) {
$this->addSql('CREATE INDEX IDX_5E3DE477CCFA12B8 ON skill (profile_id);');
}
}
// Skill
if ($schema->hasTable('skill')) {
$this->addSql('ALTER TABLE skill CHANGE name name VARCHAR(255) NOT NULL, CHANGE short_code short_code VARCHAR(100) NOT NULL, CHANGE description description LONGTEXT NOT NULL, CHANGE icon icon VARCHAR(255) NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL;');
}
// skill_rel_user
if ($schema->hasTable('skill_rel_user')) {
$table = $schema->getTable('skill_rel_user');
$this->addSql('ALTER TABLE skill_rel_user CHANGE acquired_skill_at acquired_skill_at DATETIME NOT NULL, CHANGE argumentation argumentation LONGTEXT NOT NULL, CHANGE argumentation_author_id argumentation_author_id INT NOT NULL;');
$this->addSql('UPDATE skill_rel_user SET course_id = NULL WHERE course_id = 0');
$this->addSql('UPDATE skill_rel_user SET skill_id = NULL WHERE skill_id = 0');
$this->addSql('UPDATE skill_rel_user SET user_id = NULL WHERE user_id = 0');
$this->addSql('UPDATE skill_rel_user SET session_id = NULL WHERE session_id = 0');
$this->addSql('UPDATE skill_rel_user SET acquired_level = NULL WHERE acquired_level = 0');
if ($table->hasForeignKey('FK_79D3D95AA76ED395') == false) {
$this->addSql('ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id);');
}
if ($table->hasForeignKey('FK_79D3D95A5585C142') == false) {
$this->addSql('ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A5585C142 FOREIGN KEY (skill_id) REFERENCES skill (id);');
}
if ($table->hasForeignKey('FK_79D3D95A591CC992') == false) {
$this->addSql('ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A591CC992 FOREIGN KEY (course_id) REFERENCES course (id);');
}
if ($table->hasForeignKey('FK_79D3D95A613FECDF') == false) {
$this->addSql('ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95A613FECDF FOREIGN KEY (session_id) REFERENCES session (id);');
}
if ($table->hasForeignKey('FK_79D3D95AF68F11CE') == false) {
$this->addSql('ALTER TABLE skill_rel_user ADD CONSTRAINT FK_79D3D95AF68F11CE FOREIGN KEY (acquired_level) REFERENCES skill_level (id);');
}
if ($table->hasIndex('IDX_79D3D95AA76ED395') == false) {
$this->addSql('CREATE INDEX IDX_79D3D95AA76ED395 ON skill_rel_user(user_id);');
}
if ($table->hasIndex('IDX_79D3D95A5585C142') == false) {
$this->addSql('CREATE INDEX IDX_79D3D95A5585C142 ON skill_rel_user(skill_id);');
}
if ($table->hasIndex('IDX_79D3D95A591CC992') == false) {
$this->addSql('CREATE INDEX IDX_79D3D95A591CC992 ON skill_rel_user(course_id);');
}
if ($table->hasIndex('IDX_79D3D95A613FECDF') == false) {
$this->addSql('CREATE INDEX IDX_79D3D95A613FECDF ON skill_rel_user(session_id);');
}
if ($table->hasIndex('IDX_79D3D95AF68F11CE') == false) {
$this->addSql('CREATE INDEX IDX_79D3D95AF68F11CE ON skill_rel_user (acquired_level);');
}
if ($table->hasIndex('IDX_79D3D95AF68F11CE') == false) {
$this->addSql('CREATE INDEX idx_select_s_c_u ON skill_rel_user (session_id, course_id, user_id);');
}
if ($table->hasIndex('IDX_79D3D95AF68F11CE') == false) {
$this->addSql('CREATE INDEX idx_select_sk_u ON skill_rel_user(skill_id, user_id);');
}
}
// skill_level
if ($schema->hasTable('skill_level')) {
$table = $schema->getTable('skill_level');
$this->addSql('ALTER TABLE skill_level CHANGE profile_id profile_id INT DEFAULT NULL, CHANGE position position INT NOT NULL, CHANGE short_name short_name VARCHAR(255) NOT NULL;');
if ($table->hasForeignKey('FK_BFC25F2FCCFA12B8') == false) {
$this->addSql('ALTER TABLE skill_level ADD CONSTRAINT FK_BFC25F2FCCFA12B8 FOREIGN KEY (profile_id) REFERENCES skill_level_profile (id);');
}
if ($table->hasIndex('IDX_BFC25F2FCCFA12B8') == false) {
$this->addSql('CREATE INDEX IDX_BFC25F2FCCFA12B8 ON skill_level (profile_id);');
}
}
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql(
'ALTER TABLE skill_rel_user DROP COLUMN acquired_level, DROP COLUMN argumentation, DROP COLUMN argumentation_author_id, MODIFY course_id INT NOT NULL, MODIFY session_id INT NOT NULL'
);
$this->addSql(
'ALTER TABLE skill DROP COLUMN profile_id'
);
$this->addSql('DROP TABLE skill_level');
$this->addSql('DROP TABLE skill_level_profile');
}
}

View File

@@ -0,0 +1,34 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160418093800
* Add save_correct_answers column to c_quiz table
* @package Application\Migrations\Schema\V111
*/
class Version20160418093800 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$cQuizTable = $schema->getTable('c_quiz');
$cQuizTable->addColumn('save_correct_answers', Type::BOOLEAN);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,31 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160418113000
*/
class Version20160418113000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE user ADD address VARCHAR(250) DEFAULT NULL;');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql('ALTER TABLE user DROP COLUMN address');
}
}

View File

@@ -0,0 +1,70 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version_a
* Remove enable_nanogong and enable_wami_record settings and create enable_record_audio
* @package Application\Migrations\Schema\V111
*/
class Version20160421112900 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$em = $this->getEntityManager();
$enableNanogong = $em
->getRepository('ChamiloCoreBundle:SettingsCurrent')
->findOneBy(['variable' => 'enable_nanogong']);
$enableWami = $em
->getRepository('ChamiloCoreBundle:SettingsCurrent')
->findOneBy(['variable' => 'enable_wami_record']);
$enableRecordAudioValue = 'true';
if ($enableNanogong->getSelectedValue() === 'false' && $enableWami->getSelectedValue() === 'false') {
$enableRecordAudioValue = 'false';
}
$this->addSettingCurrent(
'enable_record_audio',
null,
'radio',
'Course',
$enableRecordAudioValue,
'EnableRecordAudioTitle',
'EnableRecordAudioComment',
null,
'',
1,
true,
false,
[
['value' => 'false', 'text' => 'No'],
['value' => 'true', 'text' => 'Yes']
]
);
$em->remove($enableNanogong);
$em->remove($enableWami);
$em->flush();
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,37 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160519201900
* Update the subkeytext of some settings, previously preventing translations
* @package Application\Migrations\Schema\V111
*/
class Version20160519201900 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("UPDATE settings_current SET subkeytext = 'Name' WHERE variable = 'profile' AND subkey = 'name'");
$this->addSql("UPDATE settings_current SET subkeytext = 'OfficialCode' WHERE variable = 'profile' AND subkey = 'officialcode'");
$this->addSql("UPDATE settings_current SET subkeytext = 'Phone' WHERE variable = 'profile' AND subkey = 'phone'");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql("UPDATE settings_current SET subkeytext = 'name' WHERE variable = 'profile' AND subkey = 'name'");
$this->addSql("UPDATE settings_current SET subkeytext = 'officialcode' WHERE variable = 'profile' AND subkey = 'officialcode'");
$this->addSql("UPDATE settings_current SET subkeytext = 'phone' WHERE variable = 'profile' AND subkey = 'phone'");
}
}

View File

@@ -0,0 +1,43 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160603113100
* Add association mapping for Language class
* @package Application\Migrations\Schema\V111
*/
class Version20160603113100 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE language MODIFY id INT');
$this->addSql('ALTER TABLE language MODIFY parent_id INT');
$this->addSql('ALTER TABLE language ADD CONSTRAINT language_parent FOREIGN KEY (parent_id) REFERENCES language (id)');
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$languageTable = $schema->getTable('language');
$languageTable->removeForeignKey('language_parent');
$languageTable
->getColumn('parent_id')
->setType(Type::getType(Type::BOOLEAN))
->setNotnull(false);
}
}

View File

@@ -0,0 +1,92 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160610142700
* Integrate the Skype plugin and create new settings current to enable it
* @package Application\Migrations\Schema\V111
*/
class Version20160610142700 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (1, 1, 'skype', 'Skype', 1, 1, NOW())
");
}
$sql = "SELECT id FROM extra_field WHERE variable = 'skype' AND extra_field_type = 1";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("
INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at)
VALUES (1, 1, 'linkedin_url', 'LinkedInUrl', 1, 1, NOW())"
);
}
$this->addSettingCurrent(
'allow_show_skype_account',
null,
'radio',
'Platform',
'true',
'AllowShowSkypeAccountTitle',
'AllowShowSkypeAccountComment',
null,
null,
1,
true,
false,
[
['value' => 'false', 'text' => 'No'],
['value' => 'true', 'text' => 'Yes']
]
);
$this->addSettingCurrent(
'allow_show_linkedin_url',
null,
'radio',
'Platform',
'true',
'AllowShowLinkedInUrlTitle',
'AllowShowLinkedInUrlComment',
null,
null,
1,
true,
false,
[
['value' => 'false', 'text' => 'No'],
['value' => 'true', 'text' => 'Yes']
]
);
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160623143200
* Remove chatcall_date, chatcall_text, chatcall_user_id from User table
* @package Application\Migrations\Schema\V111
*/
class Version20160623143200 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$schema
->getTable('user')
->dropColumn('chatcall_user_id')
->dropColumn('chatcall_date')
->dropColumn('chatcall_text');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,47 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160628220000
* Integrate the Skype plugin and create new settings current to enable it
* @package Application\Migrations\Schema\V111
*/
class Version20160628220000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'dokeos_chapter'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'dokeos_module'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'chapter'");
$this
->connection
->executeQuery("UPDATE c_lp_item SET item_type = 'dir' WHERE item_type = 'module'");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160701110000
* Add option to remove splash screen on course creation
* @package Application\Migrations\Schema\V111
*/
class Version20160701110000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('course_creation_splash_screen',NULL,'radio','Course','true','CourseCreationSplashScreenTitle','CourseCreationSplashScreenComment','',NULL, 1)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('course_creation_splash_screen','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('course_creation_splash_screen','false','No') ");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("DELETE FROM settings_current WHERE variable = 'course_creation_splash_screen'");
$this->addSql("DELETE FROM settings_options WHERE variable = 'course_creation_splash_screen'");
}
}

View File

@@ -0,0 +1,36 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160705190000
* Add accumulate scorm time to c_lp table
* @package Application\Migrations\Schema\V111
*/
class Version20160705190000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("ALTER TABLE c_lp ADD COLUMN accumulate_scorm_time INT NOT NULL DEFAULT 1");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("ALTER TABLE c_lp DROP COLUMN accumulate_scorm_time");
}
}

View File

@@ -0,0 +1,46 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160705192000
* Add accumulate scorm time to c_lp table
* @package Application\Migrations\Schema\V111
*/
class Version20160705192000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$em = $this->getEntityManager();
$result = $em
->getRepository('ChamiloCoreBundle:SettingsCurrent')
->findOneBy(['variable' => 'scorm_cumulative_session_time']);
$cumulativeScormTime = 1;
if ($result->getSelectedValue() === 'false') {
$cumulativeScormTime = 0;
}
$this->addSql("UPDATE c_lp SET accumulate_scorm_time = $cumulativeScormTime");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160706145000
* Add tag extra field for skills
* @package Application\Migrations\Schema\V111
*/
class Version20160706145000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$connection = $this->connection;
$sql = "SELECT id FROM extra_field WHERE variable = 'tags'";
$result = $connection->executeQuery($sql)->fetchAll();
if (empty($result)) {
$this->addSql("INSERT INTO extra_field (extra_field_type, field_type, variable, display_text, visible, changeable, created_at) VALUES (8, 10, 'tags', 'Tags', 1, 1, NOW())");
}
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("DELETE FROM extra_field WHERE extra_field_type = 8 AND field_type = 10 AND variable = 'tags'");
}
}

View File

@@ -0,0 +1,42 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160706182000
* Add new table to save user visibility on courses in the catalogue
* @package Application\Migrations\Schema\V111
*/
class Version20160706182000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql(
'CREATE TABLE IF NOT EXISTS course_rel_user_catalogue (id int NOT NULL AUTO_INCREMENT, user_id int DEFAULT NULL, c_id int DEFAULT NULL, visible int NOT NULL, PRIMARY KEY (id), KEY (user_id), KEY (c_id), CONSTRAINT FOREIGN KEY (c_id) REFERENCES course (id) ON DELETE CASCADE, CONSTRAINT FOREIGN KEY (user_id) REFERENCES user (id) ON DELETE CASCADE) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci'
);
}
/**
* @param Schema $schema
*
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql(
'DROP TABLE course_rel_user_catalogue'
);
}
}

View File

@@ -0,0 +1,39 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160712150000
* Add option to use SVG icons instead of their PNG version
* @package Application\Migrations\Schema\V111
*/
class Version20160712150000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('icons_mode_svg', NULL, 'radio', 'Tuning', 'false', 'IconsModeSVGTitle','IconsModeSVGComment','',NULL, 1)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('icons_mode_svg','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('icons_mode_svg','false','No') ");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("DELETE FROM settings_current WHERE variable = 'icons_mode_svg'");
$this->addSql("DELETE FROM settings_options WHERE variable = 'icons_mode_svg'");
}
}

View File

@@ -0,0 +1,38 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160713180000
* Add option to use SVG icons instead of their PNG version
* @package Application\Migrations\Schema\V111
*/
class Version20160713180000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql("DELETE FROM settings_current WHERE variable = 'allow_browser_sniffer'");
$this->addSql("DELETE FROM settings_options WHERE variable = 'allow_browser_sniffer'");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("INSERT INTO settings_current (variable, subkey, type, category, selected_value, title, comment, scope, subkeytext, access_url_changeable) VALUES ('allow_browser_sniffer', NULL, 'radio', 'Tuning', 'false', 'AllowBrowserSnifferTitle','AllowBrowserSnifferComment',NULL,NULL, 0)");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_browser_sniffer','true','Yes') ");
$this->addSql("INSERT INTO settings_options (variable, value, display_text) VALUES ('allow_browser_sniffer','false','No') ");
}
}

View File

@@ -0,0 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160715122300
* Add association mapping between Session and CStudentPublication
* @package Application\Migrations\Schema\V111
*/
class Version20160715122300 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSql('ALTER TABLE c_student_publication CHANGE session_id session_id INT DEFAULT NULL');
$this->addSql('UPDATE c_student_publication SET session_id = NULL WHERE session_id = 0');
// Fix not existing session id
$this->addSql('DELETE FROM c_student_publication WHERE session_id <> NULL AND session_id not in (SELECT id FROM session)');
$this->addSql('ALTER TABLE c_student_publication ADD CONSTRAINT fk_session FOREIGN KEY (session_id) REFERENCES session (id)');
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$studentPublication = $schema->getTable('c_student_publication');
$studentPublication->removeForeignKey('fk_session');
$studentPublication->getColumn('session_id')->setNotnull(true);
}
}

View File

@@ -0,0 +1,35 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160727122700
* Add missing index to c_lp
* @package Application\Migrations\Schema\V111
*/
class Version20160727122700 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$schema
->getTable('c_lp')
->addIndex(['session_id'], 'session');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$schema
->getTable('c_lp')
->dropIndex('session');
}
}

View File

@@ -0,0 +1,50 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Chamilo\CoreBundle\Entity\BranchSync;
/**
* Class Version20160727155600
* Add an initial branch_sync
* @package Application\Migrations\Schema\V111
*/
class Version20160727155600 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$sql = "SELECT COUNT(id) as count FROM branch_sync";
$result = $this->connection->executeQuery($sql)->fetch();
$count = $result['count'];
if (!$count) {
$unique = sha1(uniqid());
$sql = "INSERT INTO branch_sync (branch_name, unique_id, access_url_id) VALUES ('localhost', '$unique', '1')";
$this->addSql($sql);
}
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$em = $this->getEntityManager();
$branchSync = $em
->getRepository('ChamiloCoreBundle:BranchSync')
->findOneBy([
'branchName' => 'localhost',
'accessUrlId' => 1
]);
$em->remove($branchSync);
$em->flush();
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,48 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160808154200
* Set ponderation and destination for questions and answers
* @package Application\Migrations\Schema\V111
*/
class Version20160808154200 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$question = $schema->getTable('c_quiz_question');
$question
->getColumn('ponderation')
->setDefault(0);
$answer = $schema->getTable('c_quiz_answer');
$answer
->getColumn('ponderation')
->setDefault(0);
$answer
->getColumn('destination')
->setNotnull(false)
->setDefault(null);
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$answer = $schema->getTable('c_quiz_answer');
$answer
->getColumn('destination')
->setNotnull(true)
->setDefault(0);
}
}

View File

@@ -0,0 +1,31 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160808160000
* Set ponderation and destination for questions and answers
* @package Application\Migrations\Schema\V111
*/
class Version20160808160000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
$this->addSql("UPDATE c_quiz_answer SET destination = NULL WHERE TRIM(destination) = ''");
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql("UPDATE c_quiz_answer SET destination = '' WHERE destination IS NULL");
}
}

View File

@@ -0,0 +1,54 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20160825155200
* Add option to allow download documents with the api key
* @package Application\Migrations\Schema\V111
*/
class Version20160825155200 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
$this->addSettingCurrent(
'allow_download_documents_by_api_key',
null,
'radio',
'WebServices',
'false',
'AllowDownloadDocumentsByApiKeyTitle',
'AllowDownloadDocumentsByApiKeyComment',
null,
null,
1,
true,
true,
[
['value' => 'false', 'text' => 'No'],
['value' => 'true', 'text' => 'Yes']
]
);
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
$this->addSql("DELETE FROM settings_current WHERE variable = 'allow_download_documents_by_api_key'");
$this->addSql("DELETE FROM settings_options WHERE variable = 'allow_download_documents_by_api_key'");
}
}

View File

@@ -0,0 +1,242 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160907140300
* Change tables engine to InnoDB
* @package Application\Migrations\Schema\V111
*/
class Version20160907140300 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20160907140300');
$data = [
'career' => [
'created_at',
'updated_at',
],
'chat' => [
'sent',
],
'course' => [
'last_visit',
'last_edit',
'creation_date',
'expiration_date',
],
'course_request' => [
'request_date',
],
'gradebook_certificate' => [
'created_at',
],
'gradebook_evaluation' => [
'created_at',
],
'gradebook_link' => [
'created_at',
],
'gradebook_linkeval_log' => [
'created_at',
],
'gradebook_result' => [
'created_at',
],
'gradebook_result_log' => [
'created_at',
],
'message' => [
'send_date',
],
'notification' => [
'sent_at'
],
'promotion' => [
'created_at',
'updated_at',
],
'shared_survey' => [
'creation_date',
],
'sequence_value' => [
'success_date',
'available_start_date',
'available_end_date',
],
'session_rel_user' => [
'moved_at',
'registered_at',
],
'skill' => [
'updated_at',
],
'sys_announcement' => [
'date_start',
'date_end',
],
'track_e_attempt_recording' => [
'insert_date',
],
'track_e_course_access' => [
'login_course_date',
'logout_course_date',
],
'track_e_downloads' => [
'down_date',
],
'track_e_exercises' => [
'start_date',
'exe_date',
],
'track_e_hotpotatoes' => [
'exe_date',
],
'track_e_item_property' => [
'lastedit_date',
],
'track_e_links' => [
'links_date',
],
'track_e_login' => [
'logout_date',
],
'track_e_online' => [
'login_date',
],
'track_e_open' => [
'open_date',
],
'track_e_uploads' => [
'upload_date',
],
'user_api_key' => [
'created_date',
'validity_start_date',
'validity_end_date',
],
'user_rel_user' => [
'last_edit',
],
'c_attendance_calendar' => [
'date_time',
],
'c_attendance_sheet_log' => [
'calendar_date_value',
],
'c_blog' => [
'date_creation',
],
'c_blog_comment' => [
'date_creation',
],
'c_blog_post' => [
'date_creation',
],
'c_blog_task_rel_user' => [
'target_date',
],
'c_chat_connected' => [
'last_connection',
],
'c_dropbox_feedback' => [
'feedback_date',
],
'c_dropbox_file' => [
'upload_date',
'last_upload_date',
],
'c_dropbox_post' => [
'feedback_date',
],
'c_forum_post' => [
'post_date',
],
'c_forum_thread' => [
'thread_date',
'thread_close_date',
],
'c_forum_thread_qualify' => [
'qualify_time',
],
'c_forum_thread_qualify_log' => [
'qualify_time',
],
'c_lp' => [
'created_on',
'modified_on',
],
'c_notebook' => [
'creation_date',
'update_date',
],
'c_online_connected' => [
'last_connection',
],
'c_survey' => [
'creation_date',
],
'c_survey_invitation' => [
'invitation_date',
'reminder_date',
],
'c_userinfo_content' => [
'edition_time'
],
'c_wiki_discuss' => [
'dtime',
],
];
// Needed to update 0000-00-00 00:00:00 values
$this->addSql('SET sql_mode = ""');
// In case this one didn't work, also try this
$this->addSql('SET SESSION sql_mode = ""');
// The whole point of this version is to ensure that all tricky (or most)
// tricky datetime fields are null if = 0000-00-00 00:00:00, because
// this value is not tolerated in NO_ZERO_DATE mode nor to convert
// the table to InnoDB, and we want all tables to be converted to
// InnoDB (that's the point of the following migration)
// To try and avoid errors to the maximum, we first convert the fields
// to a non-DATETIME type, then change the value of zero-valued times
// to NULL, then change the field back to DATETIME
foreach ($data as $table => $fields) {
foreach ($fields as $field) {
error_log("$table . $field");
$this->addSql("ALTER TABLE $table CHANGE $field $field char(19)");
$this->addSql("UPDATE $table SET $field = NULL WHERE $field = '0000-00-00 00:00:00'");
$this->addSql("UPDATE $table SET $field = NULL WHERE $field = '0000-00-00 23:59:59'");
$this->addSql("ALTER TABLE $table CHANGE $field $field DATETIME");
}
}
// Same with DATE instead of DATETIME
$data = [
'c_announcement' => [
'end_date',
],
];
foreach ($data as $table => $fields) {
foreach ($fields as $field) {
error_log("$table . $field");
$this->addSql("ALTER TABLE $table CHANGE $field $field char(10)");
$this->addSql("UPDATE $table SET $field = NULL WHERE $field = '0000-00-00'");
$this->addSql("ALTER TABLE $table CHANGE $field $field DATE");
}
}
}
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,216 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160907150300
* Change tables engine to InnoDB
* @package Application\Migrations\Schema\V111
*/
class Version20160907150300 extends AbstractMigrationChamilo
{
private $names = [
'access_url_rel_session',
'access_url_rel_user',
'admin',
'announcement_rel_group',
'block',
'c_announcement',
'c_announcement_attachment',
'c_attendance',
'c_attendance_calendar',
'c_attendance_result',
'c_attendance_sheet',
'c_attendance_sheet_log',
'c_blog',
'c_blog_attachment',
'c_blog_comment',
'c_blog_post',
'c_blog_rating',
'c_blog_rel_user',
'c_blog_task',
'c_blog_task_rel_user',
'c_calendar_event_attachment',
'c_calendar_event_repeat',
'c_calendar_event_repeat_not',
'c_chat_connected',
'c_course_description',
'c_course_setting',
'c_document',
'c_dropbox_category',
'c_dropbox_feedback',
'c_dropbox_file',
'c_dropbox_person',
'c_dropbox_post',
'c_forum_attachment',
'c_forum_category',
'c_forum_forum',
'c_forum_mailcue',
'c_forum_notification',
'c_forum_post',
'c_forum_thread',
'c_forum_thread_qualify',
'c_forum_thread_qualify_log',
'c_glossary',
'c_group_category',
'c_group_rel_tutor',
'c_group_rel_user',
'c_link',
'c_link_category',
'c_lp',
'c_lp_item',
'c_lp_item_view',
'c_lp_iv_interaction',
'c_lp_iv_objective',
'c_lp_view',
'c_notebook',
'c_online_connected',
'c_online_link',
'c_permission_group',
'c_permission_task',
'c_permission_user',
'c_quiz',
'c_quiz_question_category',
'c_quiz_question_option',
'c_quiz_question_rel_category',
'c_quiz_rel_question',
'c_resource',
'c_role',
'c_role_group',
'c_role_permissions',
'c_role_user',
'c_student_publication',
'c_student_publication_assignment',
'c_survey',
'c_survey_answer',
'c_survey_group',
'c_survey_invitation',
'c_survey_question',
'c_survey_question_option',
'c_thematic',
'c_thematic_plan',
'c_tool',
'c_tool_intro',
'c_userinfo_content',
'c_userinfo_def',
'c_wiki',
'c_wiki_conf',
'c_wiki_discuss',
'c_wiki_mailcue',
'career',
'chat',
'class_user',
'course_category',
'course_module',
'course_rel_class',
'course_request',
'course_type',
'event_email_template',
'event_sent',
'grade_components',
'grade_model',
'gradebook_category',
'gradebook_certificate',
'gradebook_evaluation',
'gradebook_link',
'gradebook_linkeval_log',
'gradebook_result',
'gradebook_result_log',
'gradebook_score_display',
'language',
'legal',
'message',
'message_attachment',
'notification',
'openid_association',
'personal_agenda',
'personal_agenda_repeat',
'personal_agenda_repeat_not',
'promotion',
'search_engine_ref',
'shared_survey',
'shared_survey_question',
'shared_survey_question_option',
'skill',
'skill_profile',
'skill_rel_gradebook',
'skill_rel_profile',
'skill_rel_skill',
'skill_rel_user',
'specific_field',
'specific_field_values',
'sys_announcement',
'sys_calendar',
'system_template',
'tag',
'templates',
'track_course_ranking',
'track_e_access',
'track_e_attempt',
'track_e_attempt_coeff',
'track_e_attempt_recording',
'track_e_course_access',
'track_e_default',
'track_e_downloads',
'track_e_exercises',
'track_e_hotpotatoes',
'track_e_hotspot',
'track_e_item_property',
'track_e_lastaccess',
'track_e_links',
'track_e_login',
'track_e_online',
'track_e_open',
'track_e_uploads',
'track_stored_values',
'track_stored_values_stack',
'user_api_key',
'user_course_category',
'user_friend_relation_type',
'user_rel_course_vote',
'user_rel_event_type',
'user_rel_tag',
'user_rel_user',
'usergroup_rel_course',
'usergroup_rel_question',
'usergroup_rel_session'
];
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
error_log('Version20160907150300');
foreach ($this->names as $name) {
if (!$schema->hasTable($name)) {
continue;
}
$sql = "ALTER TABLE $name ENGINE=InnoDB";
$this->addSql($sql);
error_log($sql);
}
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
foreach ($this->names as $name) {
if (!$schema->hasTable($name)) {
continue;
}
$this->addSql("ALTER TABLE $name ENGINE=MyISAM");
}
}
}

View File

@@ -0,0 +1,42 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160929120000
* Change tables engine to InnoDB
* @package Application\Migrations\Schema\V111
*/
class Version20160929120000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema)
{
error_log('Version20160929120000');
$this->addSql("ALTER TABLE c_tool ADD INDEX idx_ctool_name (name(20))");
}
/**
* @param Schema $schema
* @throws \Doctrine\DBAL\DBALException
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function down(Schema $schema)
{
foreach ($this->names as $name) {
if (!$schema->hasTable($name)) {
continue;
}
$this->addSql("ALTER TABLE c_tool DROP INDEX idx_ctool_name");
}
}
}

View File

@@ -0,0 +1,53 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20160930144400
* Fix track_e_hotspot ussing c_quiz_answer iid
* @package Application\Migrations\Schema\V111
*/
class Version20160930144400 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20160930144400');
$this->addSql('
UPDATE track_e_hotspot h
SET h.hotspot_answer_id = (
SELECT qa.iid
FROM c_quiz_answer qa
WHERE h.c_id = qa.c_id AND
h.hotspot_question_id = qa.question_id AND
h.hotspot_answer_id = qa.id
)
');
$this->addSql('ALTER TABLE extra_field ADD visible_to_others TINYINT(1) DEFAULT 0, CHANGE visible visible_to_self TINYINT(1) DEFAULT 0');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$this->addSql('
UPDATE track_e_hotspot h
SET h.hotspot_answer_id = (
SELECT qa.id
FROM c_quiz_answer qa
WHERE
h.c_id = qa.c_id AND
h.hotspot_question_id = qa.question_id AND
h.hotspot_answer_id = qa.iid
)
');
}
}

View File

@@ -0,0 +1,60 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20161028123400
* Add primary key as auto increment in c_student_publication_comment
* @package Application\Migrations\Schema\V111
*/
class Version20161028123400 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20161028123400');
$iidColumn = $schema
->getTable('c_student_publication_comment')
->getColumn('iid');
if (!$iidColumn->getAutoincrement()) {
$iidColumn->setAutoincrement(true);
}
// Deleting users that don't exist anymore
$sql = 'DELETE FROM access_url_rel_user WHERE user_id NOT IN (SELECT user_id from user)';
$this->addSql($sql);
$table = $schema->getTable('personal_agenda');
if ($table->hasIndex('id')) {
$this->addSql('ALTER TABLE personal_agenda DROP INDEX id');
$this->addSql('ALTER TABLE personal_agenda DROP INDEX idx_personal_agenda_user');
$this->addSql('ALTER TABLE personal_agenda DROP INDEX idx_personal_agenda_parent');
$this->addSql('ALTER TABLE personal_agenda modify id INT NOT NULL');
if ($table->hasPrimaryKey()) {
$this->addSql('ALTER TABLE personal_agenda drop primary key ');
}
$this->addSql('ALTER TABLE personal_agenda CHANGE id id INT AUTO_INCREMENT NOT NULL PRIMARY KEY');
$this->addSql('CREATE INDEX idx_personal_agenda_user ON personal_agenda (user)');
$this->addSql('CREATE INDEX idx_personal_agenda_parent ON personal_agenda (parent_event_id)');
}
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$schema
->getTable('c_student_publication_comment')
->getColumn('iid')
->setAutoincrement(false);
}
}

View File

@@ -0,0 +1,38 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20170522120000
* Remove track_e_attempt.course_code which is deleted between 1.9 and 1.10
* but somehow still existed in the 1.10 entity (and it is not deleted from
* 1.10 to 1.11)
* @package Application\Migrations\Schema\V111
*/
class Version20170522120000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20170522120000');
$trackEAttempt = $schema->getTable('track_e_attempt');
if ($trackEAttempt->hasColumn('course_code')) {
$this->addSql("ALTER TABLE track_e_attempt DROP COLUMN course_code");
}
}
/**
* Down does not do anything in this case because the field shouldn't
* have been there in the first place
* @param Schema $schema
*/
public function down(Schema $schema)
{
}
}

View File

@@ -0,0 +1,41 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Type;
/**
* Class Version20170608164500
*
* Fix c_quiz_question changing data type of type field to integer
*
* @package Application\Migrations\Schema\V111
*/
class Version20170608164500 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20170608164500');
$schema
->getTable('c_quiz_question')
->getColumn('type')
->setType(Type::getType(Type::INTEGER));
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$schema
->getTable('c_quiz_question')
->getColumn('type')
->setType(Type::getType(Type::BOOLEAN));
}
}

View File

@@ -0,0 +1,58 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20171213092400
*
* Fix some missing queries for migration from 1.10 to 1.11 (GH#2214)
* These are minor changes caused by the move from static SQL to ORM entities
*
* @package Application\Migrations\Schema\V111
*/
class Version20171213092400 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20171213092400');
$table = $schema->getTable('extra_field_values');
$hasIndex = $table->hasIndex('idx_efv_fiii');
if (!$hasIndex) {
$this->addSql('CREATE INDEX idx_efv_fiii ON extra_field_values (field_id, item_id)');
}
$this->addSql('ALTER TABLE language CHANGE parent_id parent_id INT DEFAULT NULL');
$table = $schema->getTable('c_quiz_answer');
$hasIndex = $table->hasIndex('idx_cqa_q');
if (!$hasIndex) {
$this->addSql('CREATE INDEX idx_cqa_q ON c_quiz_answer (question_id)');
}
$this->addSql('ALTER TABLE c_quiz CHANGE start_time start_time DATETIME DEFAULT NULL');
$this->addSql('ALTER TABLE c_quiz CHANGE end_time end_time DATETIME DEFAULT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
$table = $schema->getTable('c_quiz_answer');
$hasIndex = $table->hasIndex('idx_cqa_q');
if ($hasIndex) {
$this->addSql('DROP INDEX idx_cqa_q ON c_quiz_answer');
}
$table = $schema->getTable('language');
$this->addSql('ALTER TABLE language CHANGE parent_id parent_id TINYINT DEFAULT NULL');
$table = $schema->getTable('extra_field_values');
$hasIndex = $table->hasIndex('idx_efv_fiii');
if ($hasIndex) {
$this->addSql('DROP INDEX idx_efv_fiii ON extra_field_values');
}
}
}

View File

@@ -0,0 +1,87 @@
<?php
/* For licensing terms, see /license.txt */
namespace Application\Migrations\Schema\V111;
use Application\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20171227120000
*
* Fix more missing queries for migration from 1.10 to 1.11 (GH#2214)
* These are minor changes caused by the move from static SQL to ORM entities
*
* @package Application\Migrations\Schema\V111
*/
class Version20171227120000 extends AbstractMigrationChamilo
{
/**
* @param Schema $schema
*/
public function up(Schema $schema)
{
error_log('Version20171227120000');
$this->addSql('ALTER TABLE access_url CHANGE description description LONGTEXT NOT NULL');
$this->addSql('ALTER TABLE career CHANGE created_at created_at DATETIME NOT NULL, CHANGE updated_at updated_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE chat CHANGE sent sent DATETIME NOT NULL');
$this->addSql('ALTER TABLE course_category CHANGE auth_course_child auth_course_child VARCHAR(40) DEFAULT NULL');
$this->addSql('ALTER TABLE course_request CHANGE request_date request_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE extra_field CHANGE visible_to_self visible_to_self TINYINT DEFAULT NULL, CHANGE visible_to_others visible_to_others TINYINT DEFAULT NULL');
$this->addSql('ALTER TABLE gradebook_certificate CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE gradebook_evaluation CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE gradebook_link CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE gradebook_linkeval_log CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE gradebook_result CHANGE created_at created_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE gradebook_result_log CHANGE created_at created_at DATETIME NOT NULL');
// Fails because of FK on id field
//$this->addSql('ALTER TABLE language CHANGE id id INT AUTO_INCREMENT NOT NULL');
$this->addSql('ALTER TABLE message CHANGE send_date send_date DATETIME NOT NULL');
$this->addSql('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');
$this->addSql('ALTER TABLE session CHANGE name name VARCHAR(150) NOT NULL');
$this->addSql('ALTER TABLE session_rel_user CHANGE registered_at registered_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE shared_survey CHANGE creation_date creation_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE skill CHANGE updated_at updated_at DATETIME NOT NULL');
$this->addSql('ALTER TABLE skill_rel_user_comment CHANGE skill_rel_user_id skill_rel_user_id INT DEFAULT NULL, CHANGE feedback_giver_id feedback_giver_id INT DEFAULT NULL, CHANGE feedback_text feedback_text LONGTEXT NOT NULL, CHANGE feedback_value feedback_value INT DEFAULT 1, CHANGE feedback_datetime feedback_datetime DATETIME NOT NULL');
$this->addSql('ALTER TABLE sys_announcement CHANGE date_start date_start DATETIME NOT NULL, CHANGE date_end date_end DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_attempt_recording CHANGE insert_date insert_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_course_access CHANGE login_course_date login_course_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_downloads CHANGE down_date down_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_date exe_date DATETIME NOT NULL, CHANGE start_date start_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_date exe_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_item_property CHANGE lastedit_date lastedit_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_links CHANGE links_date links_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_online CHANGE login_date login_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_open CHANGE open_date open_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE track_e_uploads CHANGE upload_date upload_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE user CHANGE email_canonical email_canonical VARCHAR(100) NOT NULL, CHANGE credentials_expired credentials_expired TINYINT(1) NOT NULL');
$this->addSql('ALTER TABLE c_attendance_calendar CHANGE date_time date_time DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_blog CHANGE date_creation date_creation DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_blog_comment CHANGE date_creation date_creation DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_blog_post CHANGE date_creation date_creation DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_blog_task_rel_user CHANGE target_date target_date DATE NOT NULL');
$this->addSql('ALTER TABLE c_chat_connected CHANGE last_connection last_connection DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_dropbox_feedback CHANGE feedback_date feedback_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_dropbox_file CHANGE upload_date upload_date DATETIME NOT NULL, CHANGE last_upload_date last_upload_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_dropbox_post CHANGE feedback_date feedback_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_item_property CHANGE visibility visibility INT NOT NULL');
$this->addSql('ALTER TABLE c_lp CHANGE created_on created_on DATETIME NOT NULL, CHANGE modified_on modified_on DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_notebook CHANGE creation_date creation_date DATETIME NOT NULL, CHANGE update_date update_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_online_connected CHANGE last_connection last_connection DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_quiz CHANGE hide_question_title hide_question_title TINYINT(1) DEFAULT NULL');
$this->addSql('ALTER TABLE c_quiz_rel_category CHANGE category_id category_id INT DEFAULT NULL, CHANGE count_questions count_questions INT DEFAULT NULL');
$this->addSql('ALTER TABLE c_survey CHANGE creation_date creation_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_survey_invitation CHANGE invitation_date invitation_date DATETIME NOT NULL, CHANGE reminder_date reminder_date DATETIME NOT NULL');
$this->addSql('ALTER TABLE c_wiki_discuss CHANGE dtime dtime DATETIME NOT NULL');
$this->addSql('ALTER TABLE skill_level CHANGE profile_id profile_id INT DEFAULT NULL, CHANGE position position INT NOT NULL, CHANGE short_name short_name VARCHAR(255) NOT NULL');
}
/**
* @param Schema $schema
*/
public function down(Schema $schema)
{
// No need to revert those database changes as they are minor.
// There would be no real use to that
}
}