MDL-29514 drop support for enum data types

This commit is contained in:
Petr Skoda
2012-03-10 21:36:48 +01:00
parent 23778a4dfa
commit 05aae0a571
20 changed files with 2 additions and 776 deletions
@@ -277,40 +277,6 @@ class main_view extends XMLDBAction {
}
}
}
// TODO: Drop this check in Moodle 2.1
// Intercept loaded structure here and look for ENUM fields
if (isset($dbdir->xml_file)) {
if ($structure =& $dbdir->xml_file->getStructure()) {
if ($tables = $structure->getTables()) {
foreach ($tables as $table) {
if ($fields = $table->getFields()) {
foreach ($fields as $field) {
if (!empty($field->hasenums)) {
if ($hithis) {
$o .= '<tr class="highlight"><td class="error cell" colspan="10">';
} else {
$o .= '<tr class="r' . $row . '"><td class="error cell" colspan="10">';
}
$o .= 'Table ' . $table->getName() . ', field ' . $field->getName() . ' has ENUM info';
if (!empty($field->hasenumsenabled)) {
$o .= ' that seems to be active (true). ENUMs support has been dropped in Moodle 2.0, ' .
' the XMLDB Editor will delete any ENUM reference next time you save this file' .
' and you MUST provide one upgrade block in your code to drop them from DB. See' .
' <a href="http://docs.moodle.org/dev/DB_layer_2.0_migration_docs#The_changes">' .
' Moodle Docs</a> for more info and examples.';
} else {
$o .= ' that seem to be inactive (false). ENUMs support has been dropped in Moodle 2.0,' .
' the XMLDB Editor will, simply, delete any ENUM reference next time you save this file.' .
' No further action is necessary.';
}
$o .= '</td></tr>';
}
}
}
}
}
}
}
// If there are changes pending to be saved, but the file cannot be written... inform here
if ($dbdir->path_exists &&
file_exists($key . '/install.xml') &&
@@ -127,7 +127,6 @@ class view_table_php extends XMLDBAction {
$optionspacer . 'change_field_precision',
$optionspacer . 'change_field_notnull',
$optionspacer . 'change_field_default',
$optionspacer . 'drop_enum_from_field', // TODO: Moodle 2.1 - Drop drop_enum_from_field
'Keys',
$optionspacer . 'add_key',
$optionspacer . 'drop_key',
@@ -224,13 +223,6 @@ class view_table_php extends XMLDBAction {
$o.= $this->str['mustselectonefield'];
}
break;
case 'drop_enum_from_field': // TODO: Moodle 2.1 - Drop drop_enum_from_field
if ($fieldkeyindexinitial == 'f') { // Only if we have got one field
$o.= s($this->drop_enum_from_field_php($structure, $tableparam, $fieldkeyindexparam));
} else {
$o.= $this->str['mustselectonefield'];
}
break;
case 'change_field_default':
if ($fieldkeyindexinitial == 'f') { // Only if we have got one field
$o.= s($this->change_field_default_php($structure, $tableparam, $fieldkeyindexparam));
@@ -593,57 +585,6 @@ class view_table_php extends XMLDBAction {
return $result;
}
/**
* This function will generate all the PHP code needed to
* drop the enum values (check constraint) of one field
* using XMLDB objects and functions
*
* Note this function is here as part of the process of
* dropping enums completely from Moodle 2.0: MDL-18577
* and will be out in Moodle 2.1
* TODO: Moodle 2.1 - Drop drop_enum_from_field_php
*
* @param xmldb_structure structure object containing all the info
* @param string table table name
* @param string field field name to change its enum
*/
function drop_enum_from_field_php($structure, $table, $field) {
$result = '';
// Validate if we can do it
if (!$table = $structure->getTable($table)) {
return false;
}
if (!$field = $table->getField($field)) {
return false;
}
if ($table->getAllErrors()) {
return false;
}
// Add the standard PHP header
$result .= XMLDB_PHP_HEADER;
// Add contents
$result .= XMLDB_LINEFEED;
$result .= ' // Drop list of values (enum) from field ' . $field->getName() . ' on table ' . $table->getName() . XMLDB_LINEFEED;
$result .= ' $table = new xmldb_table(' . "'" . $table->getName() . "'" . ');' . XMLDB_LINEFEED;
$result .= ' $field = new xmldb_field(' . "'" . $field->getName() . "', " . $field->getPHP(true) . ');' . XMLDB_LINEFEED;
// Launch the proper DDL
$result .= XMLDB_LINEFEED;
$result .= ' // Launch drop of list of values from field ' . $field->getName() . XMLDB_LINEFEED;
$result .= ' $dbman->drop_enum_from_field($table, $field);' . XMLDB_LINEFEED;
// Add the proper upgrade_xxxx_savepoint call
$result .= $this->upgrade_savepoint_php ($structure);
// Add standard PHP footer
$result .= XMLDB_PHP_FOOTER;
return $result;
}
/**
* This function will generate all the PHP code needed to
* change the default of one field using XMLDB objects and functions