Internal: Fix migration from 1.11.x

pull/3696/head
Julio Montoya 5 years ago
parent acafdd64c2
commit c83bf1fcd1
  1. 61
      public/main/inc/lib/database.lib.php
  2. 9
      public/main/inc/lib/diagnoser.lib.php
  3. 13
      public/main/install/configuration.dist.php
  4. 107
      public/main/install/index.php
  5. 1902
      public/main/install/install.lib.php
  6. 16
      public/main/install/migrations.php
  7. 13
      public/main/install/update-configuration.inc.php
  8. 5
      public/main/install/update-files-1.11.0-2.0.0.inc.php
  9. 19
      public/main/install/version.php
  10. 1030
      src/CoreBundle/Migrations/Schema/V200/Version20.php
  11. 331
      src/CoreBundle/Migrations/Schema/V200/Version20170627122900.php
  12. 91
      src/CoreBundle/Migrations/Schema/V200/Version20170904145500.php
  13. 55
      src/CoreBundle/Migrations/Schema/V200/Version20170904173000.php
  14. 68
      src/CoreBundle/Migrations/Schema/V200/Version20180319145700.php
  15. 78
      src/CoreBundle/Migrations/Schema/V200/Version20180904175500.php
  16. 35
      src/CoreBundle/Migrations/Schema/V200/Version20180927172830.php
  17. 109
      src/CoreBundle/Migrations/Schema/V200/Version20181025064351.php
  18. 30
      src/CoreBundle/Migrations/Schema/V200/Version20181126174500.php
  19. 33
      src/CoreBundle/Migrations/Schema/V200/Version20190110182615.php
  20. 29
      src/CoreBundle/Migrations/Schema/V200/Version20191101132000.php
  21. 18
      src/CoreBundle/Migrations/Schema/V200/Version20191206150000.php
  22. 18
      src/CoreBundle/Migrations/Schema/V200/Version20200505064121.php
  23. 21
      src/CoreBundle/Migrations/Schema/V200/Version20200821224242.php

@ -1,10 +1,12 @@
<?php
/* For licensing terms, see /license.txt */
use Doctrine\Common\Annotations\AnnotationRegistry;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Types\Type;
use Doctrine\ORM\Configuration;
use Doctrine\ORM\EntityManager;
/**
@ -23,13 +25,9 @@ class Database
*
* @param array $params
* @param string $entityRootPath
*
* @throws \Doctrine\ORM\ORMException
*/
public function connect(
$params = [],
$entityRootPath = ''
) {
public function connect($params = [], $entityRootPath = '')
{
$config = self::getDoctrineConfig($entityRootPath);
$config->setAutoGenerateProxyClasses(true);
$config->setEntityNamespaces(
@ -41,21 +39,34 @@ class Database
);
$params['charset'] = 'utf8';
$entityManager = EntityManager::create($params, $config);
$connection = $entityManager->getConnection();
//$sysPath = !empty($sysPath) ? $sysPath : api_get_path(SYS_PATH);
$sysPath = api_get_path(SYMFONY_SYS_PATH);
AnnotationRegistry::registerFile(
$sysPath."vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntity.php"
$cache = new Doctrine\Common\Cache\ArrayCache();
// standard annotation reader
$annotationReader = new Doctrine\Common\Annotations\AnnotationReader();
$cachedAnnotationReader = new Doctrine\Common\Annotations\CachedReader(
$annotationReader, // use reader
$cache // and a cache driver
);
// Registering gedmo extensions
AnnotationRegistry::registerAutoloadNamespace(
'Gedmo\Mapping\Annotation',
$sysPath."vendor/gedmo/doctrine-extensions/lib"
$evm = new \Doctrine\Common\EventManager();
$timestampableListener = new Gedmo\Timestampable\TimestampableListener();
$timestampableListener->setAnnotationReader($cachedAnnotationReader);
$evm->addEventSubscriber($timestampableListener);
$driverChain = new \Doctrine\Persistence\Mapping\Driver\MappingDriverChain();
// load superclass metadata mapping only, into driver chain
// also registers Gedmo annotations.NOTE: you can personalize it
Gedmo\DoctrineExtensions::registerAbstractMappingIntoDriverChainORM(
$driverChain, // our metadata driver chain, to hook into
$cachedAnnotationReader // our cached annotation reader
);
$entityManager = EntityManager::create($params, $config, $evm);
$connection = $entityManager->getConnection();
AnnotationRegistry::registerFile(
$sysPath.'vendor/symfony/doctrine-bridge/Validator/Constraints/UniqueEntity.php'
);
$this->setConnection($connection);
$this->setManager($entityManager);
}
@ -630,41 +641,29 @@ class Database
*
* @param string $path
*
* @return \Doctrine\ORM\Configuration
* @return Configuration
*/
public static function getDoctrineConfig($path)
{
$isDevMode = true; // Forces doctrine to use ArrayCache instead of apc/xcache/memcache/redis
$isSimpleMode = false; // related to annotations @Entity
$cache = null;
$path = !empty($path) ? $path : api_get_path(SYS_PATH);
$path = !empty($path) ? $path : api_get_path(SYMFONY_SYS_PATH);
$paths = [
//$path.'src/Chamilo/ClassificationBundle/Entity',
//$path.'src/Chamilo/MediaBundle/Entity',
//$path.'src/Chamilo/PageBundle/Entity',
$path.'src/Chamilo/CoreBundle/Entity',
//$path.'src/Chamilo/UserBundle/Entity',
$path.'src/Chamilo/CourseBundle/Entity',
$path.'src/Chamilo/TicketBundle/Entity',
$path.'src/Chamilo/SkillBundle/Entity',
$path.'src/Chamilo/PluginBundle/Entity',
//$path.'vendor/sonata-project/user-bundle/Entity',
//$path.'vendor/sonata-project/user-bundle/Model',
//$path.'vendor/friendsofsymfony/user-bundle/FOS/UserBundle/Entity',
];
$proxyDir = $path.'var/cache/';
$config = \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
return \Doctrine\ORM\Tools\Setup::createAnnotationMetadataConfiguration(
$paths,
$isDevMode,
$proxyDir,
$cache,
$isSimpleMode
);
return $config;
}
/**

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
@ -11,10 +12,10 @@
*/
class Diagnoser
{
const STATUS_OK = 1;
const STATUS_WARNING = 2;
const STATUS_ERROR = 3;
const STATUS_INFORMATION = 4;
public const STATUS_OK = 1;
public const STATUS_WARNING = 2;
public const STATUS_ERROR = 3;
public const STATUS_INFORMATION = 4;
/**
* Contructor.

@ -16,9 +16,6 @@
// Enable access to database management for platform admins.
$_configuration['db_manager_enabled'] = false;
// Path to the webroot of system, example: /var/www/
$_configuration['root_sys'] = '{ROOT_SYS}';
/**
* Hosting settings - Allows you to set limits to the Chamilo portal when
* hosting it for a third party. These settings can be overwritten by an
@ -87,15 +84,8 @@ $_configuration['cdn'] = [
// copy the line above and modify following your needs
];
/**
* Misc. settings.
*/
// Security word for password recovery
$_configuration['security_key'] = '{SECURITY_KEY}';
// Hash function method
$_configuration['password_encryption'] = '{ENCRYPT_PASSWORD}';
// Session lifetime
$_configuration['session_lifetime'] = SESSION_LIFETIME;
// Activation for multi-url access
// When enabling multi-url, settings can be configured by multi-url using a simple
// sub-element. E.g. $_configuration['session_lifetime'][1] = true; could be turned into
@ -106,9 +96,6 @@ $_configuration['software_name'] = 'Chamilo';
$_configuration['software_url'] = 'https://chamilo.org/';
// Deny the elimination of users
$_configuration['deny_delete_users'] = false;
// Version settings
$_configuration['system_version'] = '{NEW_VERSION}';
$_configuration['system_stable'] = NEW_VERSION_STABLE;
/**
* Settings to be included as settings_current in future versions.

@ -65,7 +65,6 @@ $installationLanguage = 'en';
if (!empty($_POST['language_list'])) {
$search = ['../', '\\0'];
$installationLanguage = str_replace($search, '', urldecode($_POST['language_list']));
//$_SESSION['install_language'] = $installationLanguage;
} else {
// Trying to switch to the browser's language, it is covenient for most of the cases.
$installationLanguage = detect_browser_language();
@ -131,7 +130,7 @@ $installationGuideLink = '../../documentation/installation_guide.html';
error_reporting(E_ALL);
// Upgrading from any subversion of 1.11.x
$update_from_version_8 = [
$upgradeFromVersion = [
'1.11.0',
'1.11.1',
'1.11.2',
@ -155,15 +154,14 @@ if (!empty($_POST['old_version'])) {
$my_old_version = $tmp_version;
}
require_once __DIR__.'/version.php';
$versionData = require __DIR__.'/version.php';
$new_version = $versionData['new_version'];
// A protection measure for already installed systems.
if (isAlreadyInstalledSystem()) {
// The system has already been installed, so block re-installation.
$global_error_code = 6;
/*if (isAlreadyInstalledSystem()) {
echo 'Portal already installed';
exit;
}
}*/
/* STEP 1 : INITIALIZES FORM VARIABLES IF IT IS THE FIRST VISIT */
$badUpdatePath = false;
@ -182,9 +180,10 @@ if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($
$installType = 'update';
if (isset($_POST['step2_update_8'])) {
$emptyUpdatePath = false;
$proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYS_PATH) : $_POST['updatePath']);
$proposedUpdatePath = api_add_trailing_slash(empty($_POST['updatePath']) ? api_get_path(SYMFONY_SYS_PATH) : $_POST['updatePath']);
if (file_exists($proposedUpdatePath)) {
if (in_array($my_old_version, $update_from_version_8)) {
if (in_array($my_old_version, $upgradeFromVersion)) {
$_POST['step2'] = 1;
} else {
$badUpdatePath = true;
@ -203,7 +202,7 @@ if (isset($_POST['step2_install']) || isset($_POST['step2_update_8']) || isset($
$installType = isset($_GET['installType']) ? $_GET['installType'] : '';
$updateFromConfigFile = isset($_GET['updateFromConfigFile']) ? $_GET['updateFromConfigFile'] : false;
}
if ('update' === $installType && in_array($my_old_version, $update_from_version_8)) {
if ('update' === $installType && in_array($my_old_version, $upgradeFromVersion)) {
// This is the main configuration file of the system before the upgrade.
// Old configuration file.
// Don't change to include_once
@ -227,7 +226,7 @@ if (!isset($_GET['running'])) {
$emailForm = $_SERVER['SERVER_ADMIN'];
}
$email_parts = explode('@', $emailForm);
if (isset($email_parts[1]) && 'localhost' == $email_parts[1]) {
if (isset($email_parts[1]) && 'localhost' === $email_parts[1]) {
$emailForm .= '.localdomain';
}
@ -236,7 +235,6 @@ if (!isset($_GET['running'])) {
$institutionUrlForm = 'http://www.chamilo.org';
$languageForm = api_get_interface_language();
$checkEmailByHashSent = 0;
$userMailCanBeEmpty = 1;
$allowSelfReg = 'approval';
$allowSelfRegProf = 1; //by default, a user can register as teacher (but moderation might be in place)
@ -260,11 +258,12 @@ if (!isset($_GET['running'])) {
/* NEXT STEPS IMPLEMENTATION */
$total_steps = 7;
$current_step = 1;
if (!$_POST) {
$current_step = 1;
} elseif (!empty($_POST['language_list']) or !empty($_POST['step1']) || ((!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath or $badUpdatePath))) {
} elseif (!empty($_POST['language_list']) || !empty($_POST['step1']) || ((!empty($_POST['step2_update_8']) || (!empty($_POST['step2_update_6']))) && ($emptyUpdatePath || $badUpdatePath))) {
$current_step = 2;
} elseif (!empty($_POST['step2']) or (!empty($_POST['step2_update_8']) or (!empty($_POST['step2_update_6'])))) {
} elseif (!empty($_POST['step2']) || (!empty($_POST['step2_update_8']) || (!empty($_POST['step2_update_6'])))) {
$current_step = 3;
} elseif (!empty($_POST['step3'])) {
$current_step = 4;
@ -286,16 +285,16 @@ if ('1' == $encryptPassForm) {
}
$form = '';
$instalation_type_label = '';
if ('new' == $installType) {
$instalation_type_label = get_lang('New installation');
} elseif ('update' == $installType) {
$label = '';
if ('new' === $installType) {
$label = get_lang('New installation');
} elseif ('update' === $installType) {
$update_from_version = isset($update_from_version) ? $update_from_version : null;
$instalation_type_label = get_lang('Update from Chamilo').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
$label = get_lang('Update from Chamilo').(is_array($update_from_version) ? implode('|', $update_from_version) : '');
}
if (!empty($instalation_type_label) && empty($_POST['step6'])) {
$form .= '<div class="page-header"><h2>'.$instalation_type_label.'</h2></div>';
if (!empty($label) && empty($_POST['step6'])) {
$form .= '<div class="page-header"><h2>'.$label.'</h2></div>';
}
if (empty($installationProfile)) {
@ -307,7 +306,7 @@ if (empty($installationProfile)) {
$institutionUrlFormResult = api_stristr($institutionUrlForm, 'http://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : api_stristr($institutionUrlForm, 'https://', false) ? api_htmlentities($institutionUrlForm, ENT_QUOTES) : 'http://'.api_htmlentities($institutionUrlForm, ENT_QUOTES);
$form .= '<input type="hidden" name="updatePath" value="'.(!$badUpdatePath ? api_htmlentities($proposedUpdatePath, ENT_QUOTES) : '').'" />';
$form .= '<input type="hidden" name="updatePath" value="'.(!$badUpdatePath ? api_htmlentities($proposedUpdatePath, ENT_QUOTES) : '').'" />';
$form .= '<input type="hidden" name="urlAppendPath" value="'.api_htmlentities($urlAppendPath, ENT_QUOTES).'"/>';
$form .= '<input type="hidden" name="pathForm" value="'.api_htmlentities($pathForm, ENT_QUOTES).'"/>';
$form .= '<input type="hidden" name="urlForm" value="'.api_htmlentities($urlForm, ENT_QUOTES).'"/>';
@ -360,7 +359,6 @@ if (isset($_POST['step2'])) {
ob_end_clean();
} elseif (isset($_POST['step4'])) {
//STEP 5 : CONFIGURATION SETTINGS
//if update, try getting settings from the database...
if ('update' === $installType) {
$db_name = $dbNameForm;
$database = connectToDatabase(
@ -465,7 +463,7 @@ if (isset($_POST['step2'])) {
</div>
<?php
if ('new' == $installType) {
if ('new' === $installType) {
echo get_lang('Administrator login').' : <strong>'.$loginForm.'</strong><br />';
echo get_lang('Administrator password (<font color="red">you may want to change this</font>)').' : <strong>'.$passForm.'</strong><br /><br />'; /* TODO: Maybe this password should be hidden too? */
}
@ -478,7 +476,7 @@ if (isset($_POST['step2'])) {
<?php echo get_lang('Port').' : '.$dbPortForm; ?><br />
<?php echo get_lang('Database Login').' : '.$dbUsernameForm; ?><br />
<?php echo get_lang('Database Password').' : '.str_repeat('*', api_strlen($dbPassForm)); ?><br />
<?php echo get_lang('Main Chamilo database (DB)').' : <strong>'.$dbNameForm; ?></strong><br />
<?php echo get_lang('Chamilo database (DB)').' : <strong>'.$dbNameForm; ?></strong><br />
<?php echo get_lang('Allow self-registration').' : '.$allowSelfRegistrationLiteral; ?><br />
<?php echo get_lang('Encryption method').' : ';
echo $encryptPassForm; ?>
@ -488,11 +486,12 @@ if (isset($_POST['step2'])) {
<?php echo get_lang('URL of this company').' : '.$institutionUrlForm; ?><br />
<?php echo get_lang('Chamilo URL').' : '.$urlForm; ?><br /><br />
<?php
if ('new' == $installType) {
if ('new' === $installType) {
echo Display::return_message(
'<h4 style="text-align: center">'.get_lang(
'Warning'
).'</h4>'.get_lang('The install script will erase all tables of the selected database. We heavily recommend you do a full backup of them before confirming this last install step.'),
).'</h4>'.
get_lang('The install script will erase all tables of the selected database. We heavily recommend you do a full backup of them before confirming this last install step.'),
'warning',
false
);
@ -507,7 +506,11 @@ if (isset($_POST['step2'])) {
<td align="right">
<input type="hidden" name="is_executable" id="is_executable" value="-" />
<input type="hidden" name="step6" value="1" />
<button id="button_step6" class="btn btn-success" type="submit" name="button_step6" value="<?php echo get_lang('Install chamilo'); ?>">
<button
id="button_step6"
class="btn btn-success"
type="submit"
name="button_step6" value="<?php echo get_lang('Install Chamilo'); ?>">
<em class="fa fa-floppy-o"> </em>
<?php echo get_lang('Install chamilo'); ?>
</button>
@ -527,18 +530,25 @@ if (isset($_POST['step2'])) {
$msg = get_lang('Update process execution');
}
$form .= '<div class="RequirementHeading">
<h3>'.display_step_sequence().$msg.'</h3>';
<h3>'.display_step_sequence().$msg.'</h3>';
if (!empty($installationProfile)) {
$form .= ' <h3>('.$installationProfile.')</h3>';
}
$form .= '<div id="pleasewait" class="alert alert-success">'.get_lang('Please wait. This could take a while...').'
<div class="progress">
<div class="progress-bar progress-bar-striped active" role="progressbar" aria-valuenow="100" aria-valuemin="0" aria-valuemax="100" style="width: 100%">
<span class="sr-only">100% Complete</span>
</div>
</div>
</div>
</div>';
$form .= '<div id="pleasewait" class="alert alert-success">'.
get_lang('Please wait. This could take a while...').'
<div class="progress">
<div
class="progress-bar progress-bar-striped active"
role="progressbar"
aria-valuenow="100"
aria-valuemin="0"
aria-valuemax="100"
style="width: 100%">
<span class="sr-only">100% Complete</span>
</div>
</div>
</div>
</div>';
if ('update' === $installType) {
$database = connectToDatabase(
@ -549,10 +559,13 @@ if (isset($_POST['step2'])) {
$dbPortForm
);
$manager = $database->getManager();
$perm = api_get_permissions_for_new_directories();
$perm_file = api_get_permissions_for_new_files();
//$perm = api_get_permissions_for_new_directories();
//$perm_file = api_get_permissions_for_new_files();
// @todo fix permissions.
$perm = octdec('0777');
$perm_file = octdec('0777');
migrateSwitch($my_old_version, $manager);
exit;
// Create .env.local file
$envFile = api_get_path(SYMFONY_SYS_PATH).'.env.local';
$distFile = api_get_path(SYMFONY_SYS_PATH).'.env';
@ -695,8 +708,9 @@ if (isset($_POST['step2'])) {
if (empty($proposedUpdatePath)) {
$proposedUpdatePath = $_POST['updatePath'];
}
ob_start();
display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $update_from_version_8);
display_requirements($installType, $badUpdatePath, $proposedUpdatePath, $upgradeFromVersion);
$form .= ob_get_contents();
ob_end_clean();
} else {
@ -707,7 +721,10 @@ if (isset($_POST['step2'])) {
if (!empty($_GET['profile'])) {
$installationProfile = api_htmlentities($_GET['profile'], ENT_QUOTES);
}
echo '<input type="hidden" name="installationProfile" value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
echo '<input
type="hidden"
name="installationProfile"
value="'.api_htmlentities($installationProfile, ENT_QUOTES).'" />';
$form .= ob_get_contents();
ob_end_clean();
}
@ -716,11 +733,11 @@ $poweredBy = 'Powered by <a href="http://www.chamilo.org" target="_blank"> Chami
?>
<!DOCTYPE html>
<head>
<title>&mdash; <?php echo $translator->trans('Chamilo installation').' &mdash; '.$translator->trans('Version').' '.$new_version; ?></title>
<title>
&mdash; <?php echo $translator->trans('Chamilo installation').' &mdash; '.$translator->trans('Version').' '.$new_version; ?>
</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="../../build/css/app.css">
<script type="text/javascript" src="../../../build/runtime.js"></script>
<script type="text/javascript" src="../../../build/app.js"></script>

File diff suppressed because it is too large Load Diff

@ -0,0 +1,16 @@
<?php
return [
'table_storage' => [
'table_name' => 'version',
'version_column_name' => 'version',
'version_column_length' => 1024,
'executed_at_column_name' => 'executed_at',
'execution_time_column_name' => 'execution_time',
],
'migrations_paths' => [
'Chamilo\CoreBundle\Migrations\Schema\V200' => '../../../src/CoreBundle/Migrations/Schema/V200',
],
'all_or_nothing' => true,
'check_database_platform' => true,
];

@ -7,8 +7,7 @@
*/
if (defined('SYSTEM_INSTALLATION')) {
error_log('Starting '.basename(__FILE__));
$perm = api_get_permissions_for_new_files();
$newConfFile = api_get_path(CONFIGURATION_PATH).'configuration.php';
$newConfFile = api_get_path(SYMFONY_SYS_PATH).'config/configuration.php';
// Edit the configuration file.
$file = file($newConfFile);
@ -21,7 +20,7 @@ if (defined('SYSTEM_INSTALLATION')) {
$found_software_name = false;
$found_software_url = false;
foreach ($file as $line) {
/*foreach ($file as $line) {
$ignore = false;
if (false !== stripos($line, '$_configuration[\'system_version\']')) {
$found_version = true;
@ -36,15 +35,15 @@ if (defined('SYSTEM_INSTALLATION')) {
$found_software_url = true;
$line = '$_configuration[\'software_url\'] = \''.$GLOBALS['software_url'].'\';'."\r\n";
} elseif (false !== stripos($line, '$userPasswordCrypted')) {
$line = '$_configuration[\'password_encryption\'] = \''.$userPasswordCrypted.'\';'."\r\n";
//$line = '$_configuration[\'password_encryption\'] = \''.$userPasswordCrypted.'\';'."\r\n";
} elseif (false !== stripos($line, '?>')) {
$ignore = true;
}
if (!$ignore) {
fwrite($fh, $line);
}
}
}*/
/*
if (!$found_version) {
fwrite($fh, '$_configuration[\'system_version\'] = \''.$new_version.'\';'."\r\n");
}
@ -56,7 +55,7 @@ if (defined('SYSTEM_INSTALLATION')) {
}
if (!$found_software_url) {
fwrite($fh, '$_configuration[\'software_url\'] = \''.$software_url.'\';'."\r\n");
}
}*/
fclose($fh);
error_log("configuration.php file updated.");

@ -23,6 +23,11 @@ if (defined('SYSTEM_INSTALLATION')) {
@rrmdir($ltiPluginPath);
}
// Copy configuration.php from app/config/configuration.php to config/configuration.php
$old = api_get_path(SYMFONY_SYS_PATH).'app/config/configuration.php';
$new = api_get_path(SYMFONY_SYS_PATH).'config/configuration.php';
copy($old, $new);
error_log('Finish script '.basename(__FILE__));
} else {
echo 'You are not allowed here !'.__FILE__;

@ -1,4 +1,5 @@
<?php
/* For licensing terms, see /license.txt */
/**
* This script lists the necessary variables that allow the installation
@ -7,14 +8,20 @@
* required from any other process of Chamilo than the installation or upgrade.
* It also helps for automatic packaging of unstable versions.
*/
/**
* Variables used from the main/install/index.php.
*/
$new_version = '2.0.0';
/*$new_version = '2.0.0';
$new_version_status = 'alpha';
$new_version_last_id = 0;
$new_version_stable = false;
$new_version_major = true;
$software_name = 'Chamilo';
$software_url = 'https://chamilo.org/';
$software_url = 'https://chamilo.org/';*/
return [
'new_version' => '2.0.0',
'new_version_status' => 'alpha',
'new_version_last_id' => '0',
'new_version_stable' => false,
'new_version_major' => true,
'software_name' => 'Chamilo',
'software_url' => 'https://chamilo.org/',
];

File diff suppressed because it is too large Load Diff

@ -10,56 +10,317 @@ use Chamilo\CourseBundle\Entity\CSurvey;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20170627122900.
* Settings changes.
*/
class Version20170627122900 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$em = $this->getEntityManager();
$this->addSql("UPDATE settings_current SET selected_value = 'true' WHERE variable = 'decode_utf8'");
$this->addSql('ALTER TABLE settings_current CHANGE access_url access_url INT DEFAULT NULL');
/*if (!api_get_configuration_value('survey_answered_at_field')) {
return;
}*/
$table = $schema->getTable('settings_current');
if (false === $table->hasForeignKey('FK_62F79C3B9436187B')) {
$this->addSql(
'ALTER TABLE settings_current ADD CONSTRAINT FK_62F79C3B9436187B FOREIGN KEY (access_url) REFERENCES access_url (id);'
);
}
$this->addSql(
'ALTER TABLE settings_current CHANGE variable variable VARCHAR(190) DEFAULT NULL, CHANGE subkey subkey VARCHAR(190) DEFAULT NULL, CHANGE selected_value selected_value LONGTEXT DEFAULT NULL;'
);
$this->addSql(
'ALTER TABLE settings_options CHANGE variable variable VARCHAR(190) DEFAULT NULL, CHANGE value value VARCHAR(190) DEFAULT NULL'
);
$connection = $this->getEntityManager()->getConnection();
$result = $connection
->executeQuery(
"SELECT COUNT(1) FROM settings_current WHERE variable = 'exercise_invisible_in_session' AND category = 'Session'"
);
$count = $result->fetchNumeric()[0];
if (empty($count)) {
$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')"
);
}
/** @var ExtraField $extraField */
$extraField = $em->getRepository(ExtraField::class)
->findOneBy([
'variable' => 'is_mandatory',
'extraFieldType' => ExtraField::SURVEY_FIELD_TYPE,
]);
$result = $connection->executeQuery(
"SELECT COUNT(1) FROM settings_current WHERE variable = 'configure_exercise_visibility_in_course' AND category = 'Session'"
);
$count = $result->fetchNumeric()[0];
if (!$extraField) {
return;
if (empty($count)) {
$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')"
);
}
$surveys = $em
->createQuery('
SELECT s FROM ChamiloCourseBundle:CSurvey s
INNER JOIN ChamiloCoreBundle:ExtraFieldValues efv WITH s.iid = efv.item_id
INNER JOIN ChamiloCoreBundle:ExtraField ef WITH efv.field = ef
WHERE ef.variable = :variable
AND ef.extraFieldType = :ef_type
AND efv.value = 1
')
->setParameters([
'variable' => 'is_mandatory',
'ef_type' => ExtraField::SURVEY_FIELD_TYPE,
])
->getResult();
if (!$surveys) {
return;
// 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', 'LearningPath')"
);
$this->addSql(
"INSERT INTO settings_options (variable, value, display_text) VALUES ('show_glossary_in_extra_tools', 'exercise_and_lp', 'ExerciseAndLearningPath')"
);
// Update settings variable name
$settings = [
'Institution' => 'institution',
'SiteName' => 'site_name',
'InstitutionUrl' => 'institution_url',
'registration' => 'required_profile_fields',
'profile' => 'changeable_options',
'timezone_value' => 'timezone',
'stylesheets' => 'theme',
'platformLanguage' => 'platform_language',
'languagePriority1' => 'language_priority_1',
'languagePriority2' => 'language_priority_2',
'languagePriority3' => 'language_priority_3',
'languagePriority4' => 'language_priority_4',
'gradebook_score_display_coloring' => 'my_display_coloring',
'document_if_file_exists_option' => 'if_file_exists_option',
'ProfilingFilterAddingUsers' => 'profiling_filter_adding_users',
'course_create_active_tools' => 'active_tools_on_create',
'EmailAdministrator' => 'administrator_email',
'administratorSurname' => 'administrator_surname',
'administratorName' => 'administrator_name',
'administratorTelephone' => 'administrator_phone',
'registration.soap.php.decode_utf8' => 'decode_utf8',
'show_toolshortcuts' => 'show_tool_shortcuts',
];
foreach ($settings as $oldSetting => $newSetting) {
$sql = "UPDATE settings_current SET variable = '$newSetting'
WHERE variable = '$oldSetting'";
$this->addSql($sql);
}
// Update settings category
$settings = [
'cookie_warning' => 'platform',
'donotlistcampus' => 'platform',
'administrator_email' => 'admin',
'administrator_surname' => 'admin',
'administrator_name' => 'admin',
'administrator_phone' => 'admin',
'exercise_max_ckeditors_in_page' => 'exercise',
'allow_hr_skills_management' => 'skill',
'accessibility_font_resize' => 'display',
'account_valid_duration' => 'profile',
'allow_global_chat' => 'chat',
'allow_lostpassword' => 'registration',
'allow_registration' => 'registration',
'allow_registration_as_teacher' => 'registration',
'allow_skills_tool' => 'skill',
'allow_students_to_browse_courses' => 'display',
'allow_terms_conditions' => 'registration',
'allow_users_to_create_courses' => 'course',
'auto_detect_language_custom_pages' => 'language',
'course_validation' => 'course',
'course_validation_terms_and_conditions_url' => 'course',
'display_categories_on_homepage' => 'display',
'display_coursecode_in_courselist' => 'course',
'display_teacher_in_courselist' => 'course',
'drh_autosubscribe' => 'registration',
'drh_page_after_login' => 'registration',
'enable_help_link' => 'display',
'example_material_course_creation' => 'course',
'login_is_email' => 'profile',
'noreply_email_address' => 'mail',
'page_after_login' => 'registration',
'pdf_export_watermark_by_course' => 'document',
'pdf_export_watermark_enable' => 'document',
'pdf_export_watermark_text' => 'document',
'platform_unsubscribe_allowed' => 'registration',
'send_email_to_admin_when_create_course' => 'course',
'show_admin_toolbar' => 'display',
'show_administrator_data' => 'display',
'show_back_link_on_top_of_tree' => 'display',
'show_closed_courses' => 'display',
'show_email_addresses' => 'display',
'show_empty_course_categories' => 'display',
'show_full_skill_name_on_skill_wheel' => 'skill',
'show_hot_courses' => 'display',
'show_link_bug_notification' => 'display',
'show_number_of_courses' => 'display',
'show_teacher_data' => 'display',
'showonline' => 'display',
'student_autosubscribe' => 'registration',
'student_page_after_login' => 'registration',
'student_view_enabled' => 'course',
'teacher_autosubscribe' => 'registration',
'teacher_page_after_login' => 'registration',
'time_limit_whosonline' => 'display',
'user_selected_theme' => 'profile',
'hide_global_announcements_when_not_connected' => 'announcement',
'hide_home_top_when_connected' => 'display',
'hide_logout_button' => 'display',
'institution_address' => 'platform',
'redirect_admin_to_courses_list' => 'admin',
'decode_utf8' => 'webservice',
'use_custom_pages' => 'platform',
'allow_group_categories' => 'group',
'allow_user_headings' => 'display',
'default_document_quotum' => 'document',
'default_forum_view' => 'forum',
'default_group_quotum' => 'document',
'enable_quiz_scenario' => 'exercise',
'exercise_max_score' => 'exercise',
'exercise_min_score' => 'exercise',
'pdf_logo_header' => 'platform',
'show_glossary_in_documents' => 'document',
'show_glossary_in_extra_tools' => 'glossary',
//'show_toolshortcuts' => '',
'survey_email_sender_noreply' => 'survey',
'allow_coach_feedback_exercises' => 'exercise',
'sessionadmin_autosubscribe' => 'registration',
'sessionadmin_page_after_login' => 'registration',
'show_tutor_data' => 'display',
'chamilo_database_version' => 'platform',
'add_gradebook_certificates_cron_task_enabled' => 'gradebook',
'icons_mode_svg' => 'display',
'server_type' => 'platform',
'show_official_code_whoisonline' => 'profile',
'show_terms_if_profile_completed' => 'ticket',
'enable_record_audio' => 'course',
'add_users_by_coach' => 'session',
'allow_captcha' => 'security',
'allow_coach_to_edit_course_session' => 'session',
'allow_delete_attendance' => 'attendance',
'allow_download_documents_by_api_key' => 'webservice',
'allow_email_editor' => 'editor',
'allow_message_tool' => 'message',
'allow_send_message_to_all_platform_users' => 'message',
'allow_personal_agenda' => 'agenda',
'allow_show_linkedin_url' => 'profile',
'allow_show_skype_account' => 'profile',
'allow_social_tool' => 'social',
'allow_students_to_create_groups_in_social' => 'social',
'allow_use_sub_language' => 'language',
'allow_user_course_subscription_by_course_admin' => 'course',
'allow_users_to_change_email_with_no_password' => 'profile',
'display_groups_forum_in_general_tool' => 'forum',
'documents_default_visibility_defined_in_course' => 'document',
'dropbox_allow_group' => 'dropbox',
'dropbox_allow_just_upload' => 'dropbox',
'dropbox_allow_mailing' => 'dropbox',
'dropbox_allow_overwrite' => 'dropbox',
'dropbox_allow_student_to_student' => 'dropbox',
'dropbox_hide_course_coach' => 'dropbox',
'dropbox_hide_general_coach' => 'dropbox',
'dropbox_max_filesize' => 'dropbox',
'email_alert_manager_on_new_quiz' => 'exercise',
'enable_webcam_clip' => 'document',
'enabled_support_pixlr' => 'editor',
'enabled_support_svg' => 'editor',
'enabled_text2audio' => 'document',
'extend_rights_for_coach' => 'session',
'extend_rights_for_coach_on_survey' => 'survey',
'hide_course_group_if_no_tools_available' => 'group',
'hide_dltt_markup' => 'language',
'if_file_exists_option' => 'document',
'language_priority_1' => 'language',
'language_priority_2' => 'language',
'language_priority_3' => 'language',
'language_priority_4' => 'language',
'lp_show_reduced_report' => 'course',
'message_max_upload_filesize' => 'message',
'messaging_allow_send_push_notification' => 'webservice',
'messaging_gdc_api_key' => 'webservice',
'messaging_gdc_project_number' => 'webservice',
'permanently_remove_deleted_files' => 'document',
'permissions_for_new_directories' => 'document',
'permissions_for_new_files' => 'document',
'platform_language' => 'language',
'registered' => 'platform',
'show_chat_folder' => 'chat',
'show_default_folders' => 'document',
'show_different_course_language' => 'language',
'show_documents_preview' => 'document',
'show_link_ticket_notification' => 'display',
'show_official_code_exercise_result_list' => 'exercise',
'show_users_folders' => 'document',
'split_users_upload_directory' => 'profile',
'students_download_folders' => 'document',
'students_export2pdf' => 'document',
'tool_visible_by_default_at_creation' => 'document',
'upload_extensions_blacklist' => 'document',
'upload_extensions_list_type' => 'document',
'upload_extensions_replace_by' => 'document',
'upload_extensions_skip' => 'document',
'upload_extensions_whitelist' => 'document',
'use_users_timezone' => 'profile',
'users_copy_files' => 'document',
'timezone' => 'platform',
'enable_profile_user_address_geolocalization' => 'profile',
'theme' => 'platform',
];
foreach ($settings as $variable => $category) {
$sql = "UPDATE settings_current SET category = '$category'
WHERE variable = '$variable'";
$this->addSql($sql);
}
// Update settings value
$settings = [
'upload_extensions_whitelist' => 'htm;html;jpg;jpeg;gif;png;swf;avi;mpg;mpeg;mov;flv;doc;docx;xls;xlsx;ppt;pptx;odt;odp;ods;pdf;webm;oga;ogg;ogv;h264',
];
foreach ($settings as $variable => $value) {
$sql = "UPDATE settings_current SET selected_value = '$value'
WHERE variable = '$variable'";
$this->addSql($sql);
}
/** @var CSurvey $survey */
foreach ($surveys as $survey) {
$survey->setIsMandatory(true);
// Delete settings
$settings = [
'use_session_mode',
'show_toolshortcuts',
'show_tabs',
'display_mini_month_calendar',
'number_of_upcoming_events',
'facebook_description',
'ldap_description',
'openid_authentication',
'platform_charset',
'shibboleth_description',
'sso_authentication',
'sso_authentication_domain',
'sso_authentication_auth_uri',
'sso_authentication_unauth_uri',
'sso_authentication_protocol',
'sso_force_redirect',
'activate_email_template',
];
$em->persist($survey);
foreach ($settings as $setting) {
$sql = "DELETE FROM settings_current WHERE variable = '$setting'";
$this->addSql($sql);
}
$em->flush();
$this->addSql('UPDATE settings_current SET category = LOWER(category)');
}
public function down(Schema $schema): void

@ -8,25 +8,88 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20170904145500.
* Quiz changes.
*/
class Version20170904145500 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->addSql('DELETE FROM c_group_rel_user WHERE user_id NOT IN (SELECT id FROM user)');
$this->addSql('DELETE FROM c_group_rel_user WHERE group_id NOT IN (SELECT iid FROM c_group_info)');
$this->addSql('ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid)');
$this->addSql('CREATE INDEX IDX_C5D3D49FA76ED395 ON c_group_rel_user (user_id)');
$this->addSql('CREATE INDEX IDX_C5D3D49FFE54D947 ON c_group_rel_user (group_id)');
$this->addSql('DELETE FROM c_group_rel_tutor WHERE user_id NOT IN (SELECT id FROM user)');
$this->addSql('DELETE FROM c_group_rel_tutor WHERE group_id NOT IN (SELECT iid FROM c_group_info)');
$this->addSql('ALTER TABLE c_group_rel_tutor ADD CONSTRAINT FK_F6FF71ABA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
$this->addSql('ALTER TABLE c_group_rel_tutor ADD CONSTRAINT FK_F6FF71ABFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid)');
$this->addSql('CREATE INDEX IDX_F6FF71ABA76ED395 ON c_group_rel_tutor (user_id)');
$this->addSql('CREATE INDEX IDX_F6FF71ABFE54D947 ON c_group_rel_tutor (group_id)');
$this->addSql('CREATE TABLE IF NOT EXISTS c_exercise_category (id BIGINT AUTO_INCREMENT NOT NULL, c_id INT NOT NULL, name VARCHAR(255) NOT NULL, description LONGTEXT DEFAULT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, position INT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = InnoDB');
// c_quiz.
$table = $schema->getTable('c_quiz');
if ($table->hasColumn('exercise_category_id')) {
$this->addSql('ALTER TABLE c_quiz CHANGE exercise_category_id exercise_category_id BIGINT DEFAULT NULL;');
} else {
$this->addSql('ALTER TABLE c_quiz ADD COLUMN exercise_category_id BIGINT DEFAULT NULL;');
}
if (!$table->hasColumn('autolaunch')) {
$this->addSql('ALTER TABLE c_quiz ADD autolaunch TINYINT(1) DEFAULT 0');
}
if (false === $table->hasForeignKey('FK_B7A1C35FB48D66')) {
$this->addSql(
'ALTER TABLE c_quiz ADD CONSTRAINT FK_B7A1C35FB48D66 FOREIGN KEY (exercise_category_id) REFERENCES c_exercise_category (id);'
);
}
if (false === $table->hasIndex('IDX_B7A1C35FB48D66')) {
$this->addSql('CREATE INDEX IDX_B7A1C35FB48D66 ON c_quiz (exercise_category_id);');
}
if (false === $table->hasColumn('show_previous_button')) {
$this->addSql(
'ALTER TABLE c_quiz ADD COLUMN show_previous_button TINYINT(1) DEFAULT 1;'
);
}
if (false === $table->hasColumn('notifications')) {
$this->addSql(
'ALTER TABLE c_quiz ADD COLUMN notifications VARCHAR(255) NULL DEFAULT NULL;'
);
}
if (false === $table->hasColumn('page_result_configuration')) {
$this->addSql(
"ALTER TABLE c_quiz ADD page_result_configuration LONGTEXT DEFAULT NULL COMMENT '(DC2Type:array)'"
);
}
$this->addSql('ALTER TABLE c_quiz MODIFY COLUMN save_correct_answers INT NULL DEFAULT NULL');
// c_quiz_question.
$table = $schema->getTable('c_quiz_question');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_quiz_question ADD resource_node_id INT DEFAULT NULL;');
$this->addSql(
'ALTER TABLE c_quiz_question ADD CONSTRAINT FK_9A48A59F1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_9A48A59F1BAD783F ON c_quiz_question (resource_node_id);');
}
if (false === $table->hasColumn('feedback')) {
$this->addSql('ALTER TABLE c_quiz_question ADD feedback LONGTEXT DEFAULT NULL;');
}
// c_quiz_question_category.
$table = $schema->getTable('c_quiz_question_category');
if (false === $table->hasColumn('session_id')) {
$this->addSql('ALTER TABLE c_quiz_question_category ADD session_id INT DEFAULT NULL');
if (false === $table->hasIndex('IDX_1414369D613FECDF')) {
$this->addSql('CREATE INDEX IDX_1414369D613FECDF ON c_quiz_question_category (session_id)');
}
if (false === $table->hasForeignKey('FK_1414369D613FECDF')) {
$this->addSql(
'ALTER TABLE c_quiz_question_category ADD CONSTRAINT FK_1414369D613FECDF FOREIGN KEY (session_id) REFERENCES session (id)'
);
}
}
$this->addSql('ALTER TABLE c_quiz_question_category CHANGE description description LONGTEXT DEFAULT NULL;');
if (false === $table->hasForeignKey('FK_1414369D91D79BD3')) {
$this->addSql(
'ALTER TABLE c_quiz_question_category ADD CONSTRAINT FK_1414369D91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);'
);
}
}
public function down(Schema $schema): void

@ -9,26 +9,53 @@ use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
/**
* Class Version20170904173000.
* Group changes.
*/
class Version20170904173000 extends AbstractMigrationChamilo
{
public function getOrder()
{
return 3;
}
/**
* @throws \Doctrine\DBAL\Schema\SchemaException
*/
public function up(Schema $schema): void
{
$tblQuestion = $schema->getTable('c_survey_question');
$table = $schema->getTable('c_group_rel_user');
if (!$tblQuestion->hasColumn('is_required')) {
$tblQuestion
->addColumn('is_required', Types::BOOLEAN)
->setDefault(false);
$this->addSql('DELETE FROM c_group_rel_user WHERE user_id NOT IN (SELECT id FROM user)');
$this->addSql('DELETE FROM c_group_rel_user WHERE group_id NOT IN (SELECT iid FROM c_group_info)');
if (false === $table->hasForeignKey('FK_C5D3D49FA76ED395')) {
$this->addSql(
'ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'
);
}
if (false === $table->hasForeignKey('FK_C5D3D49FFE54D947')) {
$this->addSql(
'ALTER TABLE c_group_rel_user ADD CONSTRAINT FK_C5D3D49FFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid)'
);
}
if (false === $table->hasIndex('IDX_C5D3D49FA76ED395')) {
$this->addSql('CREATE INDEX IDX_C5D3D49FA76ED395 ON c_group_rel_user (user_id)');
}
if (false === $table->hasIndex('IDX_C5D3D49FFE54D947')) {
$this->addSql('CREATE INDEX IDX_C5D3D49FFE54D947 ON c_group_rel_user (group_id)');
}
$this->addSql('DELETE FROM c_group_rel_tutor WHERE user_id NOT IN (SELECT id FROM user)');
$this->addSql('DELETE FROM c_group_rel_tutor WHERE group_id NOT IN (SELECT iid FROM c_group_info)');
$table = $schema->getTable('c_group_rel_tutor');
if (false === $table->hasForeignKey('FK_F6FF71ABA76ED395')) {
$this->addSql(
'ALTER TABLE c_group_rel_tutor ADD CONSTRAINT FK_F6FF71ABA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'
);
}
if (false === $table->hasForeignKey('FK_F6FF71ABFE54D947')) {
$this->addSql(
'ALTER TABLE c_group_rel_tutor ADD CONSTRAINT FK_F6FF71ABFE54D947 FOREIGN KEY (group_id) REFERENCES c_group_info (iid)'
);
}
if (false === $table->hasIndex('IDX_F6FF71ABA76ED395')) {
$this->addSql('CREATE INDEX IDX_F6FF71ABA76ED395 ON c_group_rel_tutor (user_id)');
}
if (false === $table->hasIndex('IDX_F6FF71ABFE54D947')) {
$this->addSql('CREATE INDEX IDX_F6FF71ABFE54D947 ON c_group_rel_tutor (group_id)');
}
}

@ -4,22 +4,76 @@
namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Entity\ExtraField;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Chamilo\CourseBundle\Entity\CSurvey;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\DBAL\Types\Types;
/**
* Class Version20180319145700.
*
* Add indexes related to course surveys
* Survey changes.
*/
class Version20180319145700 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX idx_survey_q_qid ON c_survey_question (question_id)');
$this->addSql('CREATE INDEX idx_survey_code ON c_survey (code)');
$this->addSql('CREATE INDEX idx_survey_inv_code ON c_survey_invitation (survey_code)');
$this->addSql('CREATE INDEX idx_survey_qo_qid ON c_survey_question_option (question_id)');
$survey = $schema->getTable('c_survey');
if (!$survey->hasColumn('is_mandatory')) {
$this->addSql('ALTER TABLE c_survey ADD COLUMN is_mandatory TINYINT(1) DEFAULT "0" NOT NULL');
}
/*if (!$survey->hasIndex('idx_survey_code')) {
$this->addSql('CREATE INDEX idx_survey_code ON c_survey (code)');
}*/
$this->addSql('ALTER TABLE c_survey_invitation CHANGE reminder_date reminder_date DATETIME DEFAULT NULL');
$this->addSql(
'UPDATE c_survey_invitation SET reminder_date = NULL WHERE CAST(reminder_date AS CHAR(20)) = "0000-00-00 00:00:00"'
);
$table = $schema->getTable('c_survey_invitation');
if (false === $table->hasColumn('answered_at')) {
$this->addSql('ALTER TABLE c_survey_invitation ADD answered_at DATETIME DEFAULT NULL;');
}
if (false === $table->hasIndex('idx_survey_inv_code')) {
$this->addSql('CREATE INDEX idx_survey_inv_code ON c_survey_invitation (survey_code)');
}
$table = $schema->getTable('c_survey_question');
if (!$table->hasColumn('is_required')) {
$table
->addColumn('is_required', Types::BOOLEAN)
->setDefault(false);
}
if (false === $table->hasIndex('idx_survey_q_qid')) {
$this->addSql('CREATE INDEX idx_survey_q_qid ON c_survey_question (question_id)');
}
$table = $schema->getTable('c_survey_question_option');
if (false === $table->hasIndex('idx_survey_qo_qid')) {
$this->addSql('CREATE INDEX idx_survey_qo_qid ON c_survey_question_option (question_id)');
}
$em = $this->getEntityManager();
$sql = 'SELECT s.* FROM c_survey s
INNER JOIN extra_field_values efv
ON s.iid = efv.item_id
INNER JOIN extra_field ef
ON efv.field_id = ef.id
WHERE
ef.variable = "is_mandatory" AND
ef.extra_field_type = '.ExtraField::SURVEY_FIELD_TYPE.' AND
efv.value = 1
';
$result = $em->getConnection()->executeQuery($sql);
$data = $result->fetchAllAssociative();
if ($data) {
foreach ($data as $item) {
$id = $item['iid'];
$this->addSql("UPDATE c_survey SET is_mandatory = 1 WHERE iid = $id");
}
}
}
public function down(Schema $schema): void

@ -8,17 +8,83 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20180904175500.
*
* Add foreign key from message
* Track changes.
*/
class Version20180904175500 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->addSql('CREATE INDEX IDX_B68FF524537A1329 ON message_attachment (message_id)');
$this->addSql('ALTER TABLE message_attachment CHANGE message_id message_id BIGINT NOT NULL');
$this->addSql('ALTER TABLE message_attachment ADD CONSTRAINT FK_B68FF524537A1329 FOREIGN KEY (message_id) REFERENCES message (id)');
$this->addSql('DELETE FROM track_e_exercises WHERE exe_user_id = 0 OR exe_user_id IS NULL');
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_user_id exe_user_id INT NOT NULL');
$this->addSql('UPDATE track_e_exercises SET session_id = 0 WHERE session_id IS NULL');
$this->addSql('ALTER TABLE track_e_exercises CHANGE session_id session_id INT NOT NULL');
$table = $schema->getTable('track_e_login');
if (!$table->hasIndex('idx_track_e_login_date')) {
$this->addSql('CREATE INDEX idx_track_e_login_date ON track_e_login (login_date)');
}
$table = $schema->getTable('track_e_default');
if (!$table->hasIndex('idx_default_user_id')) {
$this->addSql('CREATE INDEX idx_default_user_id ON track_e_default (default_user_id)');
}
$table = $schema->getTable('track_e_course_access');
if (!$table->hasIndex('user_course_session_date')) {
$this->addSql(
'CREATE INDEX user_course_session_date ON track_e_course_access (user_id, c_id, session_id, login_course_date)'
);
}
$table = $schema->getTable('track_e_access');
if (!$table->hasIndex('user_course_session_date')) {
$this->addSql(
'CREATE INDEX user_course_session_date ON track_e_access (access_user_id, c_id, access_session_id, access_date)'
);
}
$table = $schema->hasTable('track_e_access_complete');
if (false === $table) {
$this->addSql(
'CREATE TABLE track_e_access_complete (id INT AUTO_INCREMENT NOT NULL, user_id INT NOT NULL, date_reg DATETIME NOT NULL, tool VARCHAR(255) NOT NULL, tool_id INT NOT NULL, tool_id_detail INT NOT NULL, action VARCHAR(255) NOT NULL, action_details VARCHAR(255) NOT NULL, current_id INT NOT NULL, ip_user VARCHAR(255) NOT NULL, user_agent VARCHAR(255) NOT NULL, session_id INT NOT NULL, c_id INT NOT NULL, ch_sid VARCHAR(255) NOT NULL, login_as INT NOT NULL, info LONGTEXT NOT NULL, url LONGTEXT NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;'
);
}
//$this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_result score SMALLINT NOT NULL');
//$this->addSql('ALTER TABLE track_e_hotpotatoes CHANGE exe_weighting max_score SMALLINT NOT NULL');
$table = $schema->getTable('track_e_exercises');
if ($table->hasColumn('exe_weighting')) {
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_weighting max_score DOUBLE PRECISION NOT NULL');
}
if ($table->hasColumn('exe_result')) {
$this->addSql('ALTER TABLE track_e_exercises CHANGE exe_result score DOUBLE PRECISION NOT NULL');
}
$table = $schema->getTable('track_e_hotspot');
if (false === $table->hasForeignKey('FK_A89CC3B691D79BD3')) {
$this->addSql(
'ALTER TABLE track_e_hotspot ADD CONSTRAINT FK_A89CC3B691D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'
);
}
if (false === $table->hasIndex('IDX_A89CC3B691D79BD3')) {
$this->addSql('CREATE INDEX IDX_A89CC3B691D79BD3 ON track_e_hotspot (c_id)');
}
$table = $schema->getTable('track_e_attempt');
if (false === $table->hasColumn('c_id')) {
$this->addSql('ALTER TABLE track_e_attempt CHANGE c_id c_id INT DEFAULT NULL');
if (false === $table->hasForeignKey('FK_F8C342C391D79BD3')) {
$this->addSql(
'ALTER TABLE track_e_attempt ADD CONSTRAINT FK_F8C342C391D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'
);
}
}
if (!$table->hasIndex('idx_track_e_attempt_tms')) {
$this->addSql('CREATE INDEX idx_track_e_attempt_tms ON track_e_attempt (tms)');
}
}
public function down(Schema $schema): void

@ -8,22 +8,43 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20180927172830.
*
* Add foreing keys between forum category - forum - forum thread - forum post
* Forums.
*/
class Version20180927172830 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$table = $schema->getTable('c_forum_post');
if (!$table->hasIndex('c_id_visible_post_date')) {
$this->addSql('CREATE INDEX c_id_visible_post_date ON c_forum_post (c_id, visible, post_date)');
}
if (!$table->hasForeignKey('FK_B5BEF559E2904019')) {
$this->addSql(
'ALTER TABLE c_forum_post ADD CONSTRAINT FK_B5BEF559E2904019 FOREIGN KEY (thread_id) REFERENCES c_forum_thread (iid)'
);
}
$this->addSql('UPDATE c_forum_post SET thread_id = NULL WHERE thread_id NOT IN (SELECT iid FROM c_forum_thread)');
$this->addSql('UPDATE c_forum_thread SET forum_id = NULL WHERE forum_id NOT IN (SELECT iid FROM c_forum_forum)');
$this->addSql('UPDATE c_forum_forum SET forum_category = NULL WHERE forum_category NOT IN (SELECT iid FROM c_forum_category)');
$this->addSql('ALTER TABLE c_forum_post ADD CONSTRAINT FK_B5BEF559E2904019 FOREIGN KEY (thread_id) REFERENCES c_forum_thread (iid)');
$this->addSql('ALTER TABLE c_forum_forum ADD CONSTRAINT FK_47A9C9921BF9426 FOREIGN KEY (forum_category) REFERENCES c_forum_category (iid)');
$this->addSql('CREATE INDEX IDX_47A9C9921BF9426 ON c_forum_forum (forum_category)');
$this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C29CCBAD0 FOREIGN KEY (forum_id) REFERENCES c_forum_forum (iid)');
$table = $schema->getTable('c_forum_forum');
if (!$table->hasForeignKey('FK_47A9C9921BF9426')) {
$this->addSql(
'ALTER TABLE c_forum_forum ADD CONSTRAINT FK_47A9C9921BF9426 FOREIGN KEY (forum_category) REFERENCES c_forum_category (iid)'
);
}
if (!$table->hasIndex('IDX_47A9C9921BF9426')) {
$this->addSql('CREATE INDEX IDX_47A9C9921BF9426 ON c_forum_forum (forum_category)');
}
$table = $schema->getTable('c_forum_thread');
if (!$table->hasForeignKey('FK_5DA7884C29CCBAD0')) {
$this->addSql('ALTER TABLE c_forum_thread ADD CONSTRAINT FK_5DA7884C29CCBAD0 FOREIGN KEY (forum_id) REFERENCES c_forum_forum (iid)');
}
}
public function down(Schema $schema): void

@ -8,22 +8,109 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Audit tables.
* GradeBook.
*/
class Version20181025064351 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE session_audit (id INT NOT NULL, rev INT NOT NULL, id_coach INT DEFAULT NULL, session_category_id INT DEFAULT NULL, name VARCHAR(150) DEFAULT NULL, description LONGTEXT DEFAULT NULL, show_description TINYINT(1) DEFAULT NULL, duration INT DEFAULT NULL, nbr_courses SMALLINT DEFAULT NULL, nbr_users INT DEFAULT NULL, nbr_classes INT DEFAULT NULL, session_admin_id INT DEFAULT NULL, visibility INT DEFAULT NULL, promotion_id INT DEFAULT NULL, display_start_date DATETIME DEFAULT NULL, display_end_date DATETIME DEFAULT NULL, access_start_date DATETIME DEFAULT NULL, access_end_date DATETIME DEFAULT NULL, coach_access_start_date DATETIME DEFAULT NULL, coach_access_end_date DATETIME DEFAULT NULL, position INT DEFAULT 0, send_subscription_notification TINYINT(1) DEFAULT "0", revtype VARCHAR(4) NOT NULL, INDEX rev_627da30b8f560d22bdca080472e41ebe_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE resource_link_audit (id INT NOT NULL, rev INT NOT NULL, resource_node_id INT DEFAULT NULL, session_id INT DEFAULT NULL, user_id INT DEFAULT NULL, c_id INT DEFAULT NULL, group_id INT DEFAULT NULL, usergroup_id INT DEFAULT NULL, visibility INT DEFAULT NULL, start_visibility_at DATETIME DEFAULT NULL, end_visibility_at DATETIME DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_b8ad249e8a6ede1472e0b8fa1db234bb_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE resource_right_audit (id INT NOT NULL, rev INT NOT NULL, resource_link_id INT DEFAULT NULL, role VARCHAR(255) DEFAULT NULL, mask INT DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_f869fbbdbb21a8a17a08e1b0657703c8_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE resource_node_audit (id INT NOT NULL, rev INT NOT NULL, resource_type_id INT DEFAULT NULL, resource_file_id INT DEFAULT NULL, creator_id INT DEFAULT NULL, parent_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, description LONGTEXT DEFAULT NULL, level INT DEFAULT NULL, path VARCHAR(3000) DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_b34616f57e0b75a07aa461581aa506d4_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE resource_type_audit (id INT NOT NULL, rev INT NOT NULL, tool_id INT DEFAULT NULL, name VARCHAR(255) DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_964270a12a79cf2336c43ffe3857923e_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE resource_file_audit (id INT NOT NULL, rev INT NOT NULL, media_id INT DEFAULT NULL, enabled TINYINT(1) DEFAULT NULL, created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_459120c2e3f50443f638e1a03a14377a_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE c_group_info_audit (iid INT NOT NULL, rev INT NOT NULL, c_id INT DEFAULT NULL, id INT DEFAULT NULL, name VARCHAR(100) DEFAULT NULL, status TINYINT(1) DEFAULT NULL, category_id INT DEFAULT NULL, description LONGTEXT DEFAULT NULL, max_student INT DEFAULT NULL, doc_state TINYINT(1) DEFAULT NULL, calendar_state TINYINT(1) DEFAULT NULL, work_state TINYINT(1) DEFAULT NULL, announcements_state TINYINT(1) DEFAULT NULL, forum_state TINYINT(1) DEFAULT NULL, wiki_state TINYINT(1) DEFAULT NULL, chat_state TINYINT(1) DEFAULT NULL, secret_directory VARCHAR(255) DEFAULT NULL, self_registration_allowed TINYINT(1) DEFAULT NULL, self_unregistration_allowed TINYINT(1) DEFAULT NULL, session_id INT DEFAULT NULL, document_access INT DEFAULT 0, revtype VARCHAR(4) NOT NULL, INDEX rev_473376fc1576bc20dac0e905c268d4e4_idx (rev), PRIMARY KEY(iid, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE c_document_audit (iid INT NOT NULL, rev INT NOT NULL, c_id INT DEFAULT NULL, session_id INT DEFAULT NULL, resource_node_id INT DEFAULT NULL, id INT DEFAULT NULL, path VARCHAR(255) DEFAULT NULL, comment LONGTEXT DEFAULT NULL, title VARCHAR(255) DEFAULT NULL, filetype VARCHAR(10) DEFAULT NULL, size INT DEFAULT NULL, readonly TINYINT(1) DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_3a0fcc30badda0288cf283b2af66dfe1_idx (rev), PRIMARY KEY(iid, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE user_audit (id INT NOT NULL, rev INT NOT NULL, enabled TINYINT(1) DEFAULT NULL, salt VARCHAR(255) DEFAULT NULL, password VARCHAR(255) DEFAULT NULL, last_login DATETIME DEFAULT NULL, confirmation_token VARCHAR(180) DEFAULT NULL, password_requested_at DATETIME DEFAULT NULL, roles LONGTEXT DEFAULT NULL COMMENT "(DC2Type:array)", created_at DATETIME DEFAULT NULL, updated_at DATETIME DEFAULT NULL, date_of_birth DATETIME DEFAULT NULL, firstname VARCHAR(64) DEFAULT NULL, lastname VARCHAR(64) DEFAULT NULL, website VARCHAR(64) DEFAULT NULL, biography VARCHAR(1000) DEFAULT NULL, gender VARCHAR(1) DEFAULT NULL, locale VARCHAR(8) DEFAULT NULL, timezone VARCHAR(64) DEFAULT NULL, phone VARCHAR(64) DEFAULT NULL, facebook_uid VARCHAR(255) DEFAULT NULL, facebook_name VARCHAR(255) DEFAULT NULL, facebook_data LONGTEXT DEFAULT NULL COMMENT "(DC2Type:json)", twitter_uid VARCHAR(255) DEFAULT NULL, twitter_name VARCHAR(255) DEFAULT NULL, twitter_data LONGTEXT DEFAULT NULL COMMENT "(DC2Type:json)", gplus_uid VARCHAR(255) DEFAULT NULL, gplus_name VARCHAR(255) DEFAULT NULL, gplus_data LONGTEXT DEFAULT NULL COMMENT "(DC2Type:json)", token VARCHAR(255) DEFAULT NULL, two_step_code VARCHAR(255) DEFAULT NULL, user_id INT DEFAULT NULL, locked TINYINT(1) DEFAULT NULL, expired TINYINT(1) DEFAULT NULL, credentials_expired TINYINT(1) DEFAULT NULL, credentials_expire_at DATETIME DEFAULT NULL, expires_at DATETIME DEFAULT NULL, address VARCHAR(250) DEFAULT NULL, profile_completed TINYINT(1) DEFAULT NULL, auth_source VARCHAR(50) DEFAULT NULL, status INT DEFAULT NULL, official_code VARCHAR(40) DEFAULT NULL, picture_uri VARCHAR(250) DEFAULT NULL, creator_id INT DEFAULT NULL, competences LONGTEXT DEFAULT NULL, diplomas LONGTEXT DEFAULT NULL, openarea LONGTEXT DEFAULT NULL, teach LONGTEXT DEFAULT NULL, productions VARCHAR(250) DEFAULT NULL, language VARCHAR(40) DEFAULT NULL, registration_date DATETIME DEFAULT NULL, expiration_date DATETIME DEFAULT NULL, active TINYINT(1) DEFAULT NULL, openid VARCHAR(255) DEFAULT NULL, theme VARCHAR(255) DEFAULT NULL, hr_dept_id SMALLINT DEFAULT NULL, username VARCHAR(100) DEFAULT NULL, email VARCHAR(100) DEFAULT NULL, email_canonical VARCHAR(100) DEFAULT NULL, username_canonical VARCHAR(180) DEFAULT NULL, revtype VARCHAR(4) NOT NULL, INDEX rev_e06395edc291d0719bee26fd39a32e8a_idx (rev), PRIMARY KEY(id, rev)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$this->addSql('CREATE TABLE revisions (id INT AUTO_INCREMENT NOT NULL, timestamp DATETIME NOT NULL, username VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;');
$table = $schema->getTable('gradebook_result_log');
if ($table->hasColumn('id_result')) {
$this->addSql('DELETE FROM gradebook_result_log WHERE id_result IS NULL');
$this->addSql('ALTER TABLE gradebook_result_log CHANGE id_result result_id INT NOT NULL');
}
$this->addSql('ALTER TABLE gradebook_category CHANGE user_id user_id INT DEFAULT NULL');
$this->addSql(
'DELETE FROM gradebook_category WHERE user_id IS NOT NULL AND user_id NOT IN (SELECT id FROM user)'
);
$table = $schema->getTable('gradebook_category');
if (false === $table->hasColumn('c_id')) {
$this->addSql('ALTER TABLE gradebook_category ADD c_id INT DEFAULT NULL');
$this->addSql('UPDATE gradebook_category SET c_id = (SELECT id FROM course WHERE code = course_code)');
$this->addSql('ALTER TABLE gradebook_category DROP course_code');
$this->addSql(
'ALTER TABLE gradebook_category ADD CONSTRAINT FK_96A4C70591D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);'
);
$this->addSql('CREATE INDEX IDX_96A4C70591D79BD3 ON gradebook_category (c_id);');
}
if (false === $table->hasColumn('depends')) {
$this->addSql('ALTER TABLE gradebook_category ADD depends LONGTEXT DEFAULT NULL');
}
if (false === $table->hasColumn('minimum_to_validate')) {
$this->addSql('ALTER TABLE gradebook_category ADD minimum_to_validate INT DEFAULT NULL');
}
if (false === $table->hasColumn('gradebooks_to_validate_in_dependence')) {
$this->addSql('ALTER TABLE gradebook_category ADD gradebooks_to_validate_in_dependence INT DEFAULT NULL');
}
if (false === $table->hasIndex('idx_gb_cat_parent')) {
$this->addSql('CREATE INDEX idx_gb_cat_parent ON gradebook_category (parent_id)');
}
if (false === $table->hasForeignKey('FK_96A4C705A76ED395')) {
$this->addSql(
'ALTER TABLE gradebook_category ADD CONSTRAINT FK_96A4C705A76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'
);
}
if (false === $table->hasIndex('IDX_96A4C705A76ED395')) {
$this->addSql('CREATE INDEX IDX_96A4C705A76ED395 ON gradebook_category (user_id)');
}
// Evaluation.
$table = $schema->getTable('gradebook_evaluation');
if (false === $table->hasColumn('c_id')) {
$this->addSql('ALTER TABLE gradebook_evaluation ADD c_id INT DEFAULT NULL');
$this->addSql('UPDATE gradebook_evaluation SET c_id = (SELECT id FROM course WHERE code = course_code)');
$this->addSql('ALTER TABLE gradebook_evaluation DROP course_code');
$this->addSql(
'ALTER TABLE gradebook_evaluation ADD CONSTRAINT FK_DDDED80491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);'
);
$this->addSql('CREATE INDEX IDX_DDDED80491D79BD3 ON gradebook_evaluation (c_id)');
//$this->addSql('ALTER TABLE gradebook_evaluation RENAME INDEX fk_ddded80491d79bd3 TO IDX_DDDED80491D79BD3;');
}
if (false === $table->hasIndex('idx_ge_cat')) {
$this->addSql('CREATE INDEX idx_ge_cat ON gradebook_evaluation (category_id)');
}
$table = $schema->getTable('gradebook_link');
if (false === $table->hasColumn('c_id')) {
$this->addSql('ALTER TABLE gradebook_link ADD c_id INT DEFAULT NULL');
$this->addSql('UPDATE gradebook_link SET c_id = (SELECT id FROM course WHERE code = course_code)');
$this->addSql('ALTER TABLE gradebook_link DROP course_code');
$this->addSql(
'ALTER TABLE gradebook_link ADD CONSTRAINT FK_4F0F595F91D79BD3 FOREIGN KEY (c_id) REFERENCES course (id);'
);
$this->addSql('CREATE INDEX IDX_4F0F595F91D79BD3 ON gradebook_link (c_id);');
}
if (false === $table->hasIndex('idx_gl_cat')) {
$this->addSql('CREATE INDEX idx_gl_cat ON gradebook_link (category_id)');
}
$table = $schema->getTable('gradebook_result');
if (false === $table->hasIndex('idx_gb_uid_eid')) {
$this->addSql('CREATE INDEX idx_gb_uid_eid ON gradebook_result (user_id, evaluation_id)');
}
$table = $schema->getTable('gradebook_certificate');
if (false === $table->hasColumn('downloaded_at')) {
$this->addSql('ALTER TABLE gradebook_certificate ADD downloaded_at DATETIME DEFAULT NULL;');
$this->addSql(
'UPDATE gradebook_certificate gc SET downloaded_at = (
SELECT value from extra_field e
INNER JOIN extra_field_values v on v.field_id = e.id
WHERE variable = "downloaded_at" and extra_field_type = 11 and item_id = gc.id
)'
);
}
$table = $schema->hasTable('gradebook_result_attempt');
if (false === $table) {
$this->addSql(
'CREATE TABLE gradebook_result_attempt (id INT AUTO_INCREMENT NOT NULL, comment LONGTEXT DEFAULT NULL, score DOUBLE PRECISION DEFAULT NULL, result_id INT NOT NULL, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC;'
);
}
}
public function down(Schema $schema): void

@ -8,7 +8,7 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20181126174500.
* LTI.
*/
class Version20181126174500 extends AbstractMigrationChamilo
{
@ -20,8 +20,9 @@ class Version20181126174500 extends AbstractMigrationChamilo
return;
}
$this->addSql(
'CREATE TABLE lti_external_tool (
if (false === $schema->hasTable('lti_external_tool')) {
$this->addSql(
'CREATE TABLE lti_external_tool (
id INT AUTO_INCREMENT NOT NULL,
c_id INT DEFAULT NULL,
gradebook_eval_id INT DEFAULT NULL,
@ -39,18 +40,17 @@ class Version20181126174500 extends AbstractMigrationChamilo
INDEX IDX_DB0E04E4727ACA70 (parent_id),
PRIMARY KEY(id)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id)
REFERENCES gradebook_evaluation (id) ON DELETE SET NULL;'
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id)
REFERENCES lti_external_tool (id);'
);
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E491D79BD3 FOREIGN KEY (c_id) REFERENCES course (id)'
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E482F80D8B FOREIGN KEY (gradebook_eval_id) REFERENCES gradebook_evaluation (id) ON DELETE SET NULL;'
);
$this->addSql(
'ALTER TABLE lti_external_tool ADD CONSTRAINT FK_DB0E04E4727ACA70 FOREIGN KEY (parent_id) REFERENCES lti_external_tool (id);'
);
}
}
public function down(Schema $schema): void

@ -8,26 +8,29 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20190110182615.
* LPs.
*/
class Version20190110182615 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->addSql(
'ALTER TABLE resource_link DROP FOREIGN KEY FK_398C394BFE54D947;');
$this->addSql(
'ALTER TABLE resource_link ADD CONSTRAINT FK_398C394BFE54D947
FOREIGN KEY (group_id) REFERENCES c_group_info (iid) ON DELETE CASCADE;'
);
$this->addSql(
'ALTER TABLE resource_right DROP
FOREIGN KEY FK_9F710F26F004E599;'
);
$this->addSql(
'ALTER TABLE resource_right ADD CONSTRAINT FK_9F710F26F004E599
FOREIGN KEY (resource_link_id) REFERENCES resource_link (id) ON DELETE CASCADE;'
);
$this->addSql('ALTER TABLE c_lp CHANGE author author LONGTEXT NOT NULL');
$table = $schema->getTable('c_lp');
if (false === $table->hasColumn('resource_node_id')) {
$this->addSql('ALTER TABLE c_lp ADD resource_node_id INT DEFAULT NULL;');
$this->addSql(
'ALTER TABLE c_lp ADD CONSTRAINT FK_F67ABBEB1BAD783F FOREIGN KEY (resource_node_id) REFERENCES resource_node (id) ON DELETE CASCADE;'
);
$this->addSql('CREATE UNIQUE INDEX UNIQ_F67ABBEB1BAD783F ON c_lp (resource_node_id);');
}
$table = $schema->getTable('c_lp_item_view');
if (false == $table->hasIndex('idx_c_lp_item_view_cid_id_view_count')) {
/*$this->addSql(
'CREATE INDEX idx_c_lp_item_view_cid_id_view_count ON c_lp_item_view (c_id, id, view_count)'
);*/
}
}
public function down(Schema $schema): void

@ -7,21 +7,30 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20191101132000.
*/
class Version20191101132000 extends AbstractMigrationChamilo
{
public function up(Schema $schema): void
{
$this->getEntityManager();
// Update iso
$sql = 'UPDATE course SET course_language = (SELECT isocode FROM language WHERE english_name = course_language);';
$this->addSql($sql);
$this->addSql('ALTER TABLE course ADD category_id INT DEFAULT NULL;');
$this->addSql('UPDATE course co SET co.category_id = (SELECT cat.id FROM course_category cat WHERE cat.code = co.category_code)');
$this->addSql('DROP INDEX category_code ON course');
$this->addSql('ALTER TABLE course DROP category_code');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB912469DE2 FOREIGN KEY (category_id) REFERENCES course_category (id)');
$this->addSql('CREATE INDEX IDX_169E6FB912469DE2 ON course (category_id)');
if (false === $schema->hasTable('course_rel_category')) {
$this->addSql('CREATE TABLE course_rel_category (course_id INT NOT NULL, course_category_id INT NOT NULL, INDEX IDX_8EB34CC5591CC992 (course_id), INDEX IDX_8EB34CC56628AD36 (course_category_id), PRIMARY KEY(course_id, course_category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC');
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC5591CC992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC56628AD36 FOREIGN KEY (course_category_id) REFERENCES course_category (id) ON DELETE CASCADE');
$courseTable = $schema->getTable('course');
if ($courseTable->hasForeignKey('FK_169E6FB912469DE2')) {
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB912469DE2');
}
if ($courseTable->hasForeignKey('IDX_169E6FB912469DE2')) {
$this->addSql('DROP INDEX IDX_169E6FB912469DE2 ON course');
}
if ($courseTable->hasColumn('category_id')) {
$this->addSql('ALTER TABLE course DROP category_id');
}
}
}
public function down(Schema $schema): void

@ -8,7 +8,7 @@ use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Class Version20191206150000.
* Extra fields.
*/
class Version20191206150000 extends AbstractMigrationChamilo
{
@ -16,10 +16,18 @@ class Version20191206150000 extends AbstractMigrationChamilo
{
$this->getEntityManager();
$this->addSql('ALTER TABLE extra_field ADD helper_text text DEFAULT NULL AFTER display_text');
$tableObj = $schema->getTable('personal_agenda');
if ($tableObj->hasColumn('course')) {
$this->addSql('ALTER TABLE personal_agenda DROP course');
$table = $schema->getTable('extra_field');
if (false === $table->hasColumn('helper_text')) {
$this->addSql('ALTER TABLE extra_field ADD helper_text text DEFAULT NULL AFTER display_text');
}
$this->addSql('ALTER TABLE extra_field_values CHANGE value value LONGTEXT DEFAULT NULL;');
if (false === $table->hasColumn('description')) {
$this->addSql('ALTER TABLE extra_field ADD description LONGTEXT DEFAULT NULL');
}
$table = $schema->getTable('extra_field_values');
if (!$table->hasIndex('idx_efv_item')) {
$this->addSql('CREATE INDEX idx_efv_item ON extra_field_values (item_id)');
}
}

@ -5,20 +5,18 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200505064121 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE reset_password_request (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', expires_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_7CE748AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC');
$this->addSql('ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)');
if (false === $schema->hasTable('reset_password_request')) {
$this->addSql(
'CREATE TABLE reset_password_request (id INT AUTO_INCREMENT NOT NULL, user_id INT DEFAULT NULL, selector VARCHAR(20) NOT NULL, hashed_token VARCHAR(100) NOT NULL, requested_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', expires_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', INDEX IDX_7CE748AA76ED395 (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC'
);
$this->addSql(
'ALTER TABLE reset_password_request ADD CONSTRAINT FK_7CE748AA76ED395 FOREIGN KEY (user_id) REFERENCES user (id)'
);
}
}
public function down(Schema $schema): void

@ -5,33 +5,14 @@ namespace Chamilo\CoreBundle\Migrations\Schema\V200;
use Chamilo\CoreBundle\Migrations\AbstractMigrationChamilo;
use Doctrine\DBAL\Schema\Schema;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20200821224242 extends AbstractMigrationChamilo
{
public function getDescription(): string
{
return '';
}
public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE course_rel_category (course_id INT NOT NULL, course_category_id INT NOT NULL, INDEX IDX_8EB34CC5591CC992 (course_id), INDEX IDX_8EB34CC56628AD36 (course_category_id), PRIMARY KEY(course_id, course_category_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB ROW_FORMAT = DYNAMIC');
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC5591CC992 FOREIGN KEY (course_id) REFERENCES course (id) ON DELETE CASCADE');
$this->addSql('ALTER TABLE course_rel_category ADD CONSTRAINT FK_8EB34CC56628AD36 FOREIGN KEY (course_category_id) REFERENCES course_category (id) ON DELETE CASCADE');
$this->addSql('DROP TABLE version');
$this->addSql('ALTER TABLE course DROP FOREIGN KEY FK_169E6FB912469DE2');
$this->addSql('DROP INDEX IDX_169E6FB912469DE2 ON course');
$this->addSql('ALTER TABLE course DROP category_id');
}
public function down(Schema $schema): void
{
$this->addSql('CREATE TABLE version (id INT UNSIGNED AUTO_INCREMENT NOT NULL, version VARCHAR(20) CHARACTER SET utf8mb4 DEFAULT NULL COLLATE `utf8mb4_general_ci`, UNIQUE INDEX version (version), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE `utf8_unicode_ci` ENGINE = InnoDB COMMENT = \'\' ');
$this->addSql('DROP TABLE course_rel_category');
$this->addSql('ALTER TABLE course ADD category_id INT DEFAULT NULL');
$this->addSql('ALTER TABLE course ADD CONSTRAINT FK_169E6FB912469DE2 FOREIGN KEY (category_id) REFERENCES course_category (id)');
$this->addSql('CREATE INDEX IDX_169E6FB912469DE2 ON course (category_id)');
}
}

Loading…
Cancel
Save