MDL-18577 drop enums support - step2: enums out from editor, dbmanager and all upgrade scripts.
This commit is contained in:
@@ -124,8 +124,8 @@ class view_table_php extends XMLDBAction {
|
||||
$optionspacer . 'change_field_precision',
|
||||
$optionspacer . 'change_field_unsigned',
|
||||
$optionspacer . 'change_field_notnull',
|
||||
$optionspacer . 'change_field_enum',
|
||||
$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',
|
||||
@@ -229,9 +229,9 @@ class view_table_php extends XMLDBAction {
|
||||
$o.= $this->str['mustselectonefield'];
|
||||
}
|
||||
break;
|
||||
case 'change_field_enum':
|
||||
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->change_field_enum_php($structure, $tableparam, $fieldkeyindexparam));
|
||||
$o.= s($this->drop_enum_from_field_php($structure, $tableparam, $fieldkeyindexparam));
|
||||
} else {
|
||||
$o.= $this->str['mustselectonefield'];
|
||||
}
|
||||
@@ -648,14 +648,19 @@ class view_table_php extends XMLDBAction {
|
||||
|
||||
/**
|
||||
* This function will generate all the PHP code needed to
|
||||
* change the enum values (check constraint) of one field
|
||||
* 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 change_field_enum_php($structure, $table, $field) {
|
||||
function drop_enum_from_field_php($structure, $table, $field) {
|
||||
|
||||
$result = '';
|
||||
/// Validate if we can do it
|
||||
@@ -669,22 +674,19 @@ class view_table_php extends XMLDBAction {
|
||||
return false;
|
||||
}
|
||||
|
||||
/// Calculate the enum tip text
|
||||
$enum = $field->getEnum() ? implode(', ', $field->getEnumValues()) : 'none';
|
||||
|
||||
/// Add the standard PHP header
|
||||
$result .= XMLDB_PHP_HEADER;
|
||||
|
||||
/// Add contents
|
||||
$result .= XMLDB_LINEFEED;
|
||||
$result .= ' /// Changing list of values (enum) of field ' . $field->getName() . ' on table ' . $table->getName() . ' to ' . $enum . 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 change of list of values for field ' . $field->getName() . XMLDB_LINEFEED;
|
||||
$result .= ' $dbman->change_field_enum($table, $field);' . 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);
|
||||
|
||||
Reference in New Issue
Block a user