$this->addSql("ALTER TABLE c_forum_post ADD status INT DEFAULT NULL");
$this->addSql("CREATE TABLE 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))");
$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("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;");
@ -150,25 +155,68 @@ class Version111 extends AbstractMigrationChamilo
$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, 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');
if ($schema->hasTable('plugin_ticket_assigned_log')) {
$this->addSql('RENAME TABLE plugin_ticket_assigned_log TO ticket_assigned_log');
}
if ($schema->hasTable('plugin_ticket_category')) {
$this->addSql('RENAME TABLE plugin_ticket_category TO ticket_category');
}
if ($schema->hasTable('plugin_ticket_message')) {
$this->addSql(
'RENAME TABLE plugin_ticket_message TO ticket_message'
);
}
if ($schema->hasTable('plugin_ticket_message_attachments')) {
$this->addSql(
'RENAME TABLE plugin_ticket_message_attachments TO ticket_message_attachments'
);
}
if ($schema->hasTable('plugin_ticket_priority')) {
$this->addSql(
'RENAME TABLE plugin_ticket_priority TO ticket_priority'
);
}
if ($schema->hasTable('plugin_ticket_project')) {
$this->addSql(
'RENAME TABLE plugin_ticket_project TO ticket_project'
);
}
if ($schema->hasTable('plugin_ticket_status')) {
$this->addSql(
'RENAME TABLE plugin_ticket_status TO ticket_status'
);
}
if ($schema->hasTable('plugin_ticket_ticket')) {
$this->addSql(
'RENAME TABLE plugin_ticket_ticket TO ticket_ticket'
);
}
$this->addSql('RENAME TABLE plugin_ticket_assigned_log TO ticket_assigned_log');
$this->addSql('RENAME TABLE plugin_ticket_category TO ticket_category');
$this->addSql('RENAME TABLE plugin_ticket_category_rel_user TO ticket_category_rel_user');
$this->addSql('RENAME TABLE plugin_ticket_message TO ticket_message');
$this->addSql('RENAME TABLE plugin_ticket_message_attachments TO ticket_message_attachments');
$this->addSql('RENAME TABLE plugin_ticket_priority TO ticket_priority');
$this->addSql('RENAME TABLE plugin_ticket_project TO ticket_project');
$this->addSql('RENAME TABLE plugin_ticket_status TO ticket_status');
$this->addSql('RENAME TABLE plugin_ticket_ticket TO ticket_ticket');
$this->addSql('UPDATE ticket_project SET sys_insert_user_id = 1 WHERE sys_insert_user_id IS NULL');
$this->addSql('UPDATE ticket_project SET sys_insert_datetime = NOW() WHERE sys_insert_datetime IS NULL');
$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('ALTER TABLE 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 ticket_status SET code = status_id ');
$this->addSql('ALTER TABLE ticket_status DROP status_id');
$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;');
$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');
@ -180,20 +228,31 @@ class Version111 extends AbstractMigrationChamilo
$this->addSql('RENAME TABLE plugin_ticket_category_rel_user TO ticket_category_rel_user');
$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;');
$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);');
if ($table->hasIndex('fk_5b8a98712469de2')) {
$table->dropIndex('fk_5b8a98712469de2');
}
if ($table->hasIndex('fk_5b8a987a76ed395')) {
$table->dropIndex('fk_5b8a987a76ed395');
}
} 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_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('UPDATE ticket_ticket SET project_id = 1 WHERE project_id is NULL or project_id = 0');
@ -248,11 +297,8 @@ class Version111 extends AbstractMigrationChamilo
$this->addSql('CREATE INDEX IDX_54B65868A76ED395 ON ticket_assigned_log (user_id);');
$this->addSql('ALTER TABLE ticket_assigned_log RENAME INDEX fk_ticket_assigned_log TO IDX_54B65868700047D2;');
$this->addSql('ALTER TABLE ticket_category_rel_user RENAME INDEX fk_5b8a98712469de2 TO IDX_5B8A98712469DE2;');
$this->addSql('ALTER TABLE ticket_category_rel_user RENAME INDEX fk_5b8a987a76ed395 TO IDX_5B8A987A76ED395;');
$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;');