Commit 2a88f626 authored by stronk7's avatar stronk7
Browse files

MDL-18577 drop enums support - step2: enums out from editor, dbmanager and all upgrade scripts.

parent 3ece3e42
......@@ -155,16 +155,6 @@ class edit_field extends XMLDBAction {
$sequenceoptions = array (0 => $this->str['no'], 1 => 'auto-numbered');
$o.= ' <tr valign="top"><td><label for="menusequence" accesskey="s">Sequence:</label></td>';
$o.= ' <td colspan="2">' . choose_from_menu($sequenceoptions, 'sequence', $field->getSequence(), '', '', '', true) . '</td></tr>';
/// xmldb_field Enum and enumvalues
$enumoptions = array (0 => $this->str['no'], 1 => $this->str['yes']);
$o.= ' <tr valign="top"><td><label for="menuenum" accesskey="s">Enum:</label></td>';
$o.= ' <td>' . choose_from_menu($enumoptions, 'enum', $field->getEnum(), '', '', '', true) . '</td>';
if (is_array($field->getEnumValues())) {
$enumvalues = implode(', ', $field->getEnumValues());
} else {
$enumvalues = '';
}
$o.= ' <td><textarea name="enumvalues" rows="3" cols="70" id="enumvalues">' . s($enumvalues) . '</textarea></td></tr>';
/// xmldb_field Default
$o.= ' <tr valign="top"><td><label for="default" accesskey="d">Default:</label></td>';
$o.= ' <td colspan="2"><input type="text" name="default" size="30" maxlength="80" id="default" value="' . s($field->getDefault()) . '" /></td></tr>';
......
......@@ -7,7 +7,7 @@
// Moodle - Modular Object-Oriented Dynamic Learning Environment //
// http://moodle.com //
// //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// Copyright (C) 1999 onwards Martin Dougiamas http://dougiamas.com //
// (C) 2001-3001 Eloy Lafuente (stronk7) http://contiento.com //
// //
// This program is free software; you can redistribute it and/or modify //
......@@ -34,19 +34,16 @@
/// Get the required fields
var typeField = document.getElementById('menutype');
var sequenceField = document.getElementById('menusequence');
var enumField = document.getElementById('menuenum');
/// Register the rest of events
if (typeField.addEventListener) {
/// Standard
typeField.addEventListener('change', transformForm, false);
sequenceField.addEventListener('change', transformForm, false);
enumField.addEventListener('change', transformForm, false);
} else {
/// IE 5.5
typeField.attachEvent('onchange', transformForm);
sequenceField.attachEvent('onchange', transformForm);
enumField.attachEvent('onchange', transformForm);
}
}
......@@ -62,8 +59,6 @@ function transformForm(event) {
var unsignedField = document.getElementById('menuunsigned');
var notnullField = document.getElementById('menunotnull');
var sequenceField = document.getElementById('menusequence');
var enumField = document.getElementById('menuenum');
var enumvaluesField = document.getElementById('enumvalues');
var defaultField = document.getElementById('default');
var lengthTip = document.getElementById('lengthtip');
......@@ -74,16 +69,8 @@ function transformForm(event) {
unsignedField.disabled = false;
notnullField.disabled = false;
sequenceField.disabled = false;
enumField.disabled = false;
enumvaluesField.disabled = false;
defaultField.disabled = false;
/// Based on enum, disable some items
if (enumField.value == '0') {
enumvaluesField.disabled = true;
enumvaluesField.value = '';
};
/// Based on sequence, disable some items
if (sequenceField.value == '1') {
unsignedField.disabled = true;
......@@ -92,10 +79,6 @@ function transformForm(event) {
notnullField.value = '1';
defaultField.disabled = true;
defaultField.value = '';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
}
......@@ -106,26 +89,14 @@ function transformForm(event) {
decimalsTip.innerHTML = '';
decimalsField.disabled = true;
decimalsField.value = '';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
break;
case '2': // XMLDB_TYPE_NUMBER
lengthTip.innerHTML = ' 1...20';
decimalsTip.innerHTML = ' 0...length or empty';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
break;
case '3': // XMLDB_TYPE_FLOAT
lengthTip.innerHTML = ' 1...20 or empty';
decimalsTip.innerHTML = ' 0...length or empty';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
break;
case '4': // XMLDB_TYPE_CHAR
lengthTip.innerHTML = ' 1...255';
......@@ -158,10 +129,6 @@ function transformForm(event) {
unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
defaultField.disabled = true;
defaultField.value = '';
break;
......@@ -176,10 +143,6 @@ function transformForm(event) {
unsignedField.value = '0';
sequenceField.disabled = true;
sequenceField.value = '0';
enumField.disabled = true;
enumField.value = '0';
enumvaluesField.disabled = true;
enumvaluesField.value = '';
defaultField.disabled = true;
defaultField.value = '';
break;
......
......@@ -49,8 +49,6 @@ class edit_field_save extends XMLDBAction {
'binaryincorrectlength' => 'xmldb',
'numberincorrectdecimals' => 'xmldb',
'floatincorrectdecimals' => 'xmldb',
'enumvaluesincorrect' => 'xmldb',
'wronglengthforenum' => 'xmldb',
'defaultincorrect' => 'xmldb',
'administration' => ''
));
......@@ -96,9 +94,6 @@ class edit_field_save extends XMLDBAction {
$unsigned = optional_param('unsigned', false, PARAM_BOOL);
$notnull = optional_param('notnull', false, PARAM_BOOL);
$sequence = optional_param('sequence', false, PARAM_BOOL);
$enum = optional_param('enum', false, PARAM_BOOL);
$enumvalues = optional_param('enumvalues', 0, PARAM_CLEAN);
$enumvalues = trim($enumvalues);
$default = optional_param('default', NULL, PARAM_PATH);
$default = trim($default);
......@@ -114,21 +109,14 @@ class edit_field_save extends XMLDBAction {
if ($sequence) {
$unsigned = true;
$notnull = true;
$enum = false;
$default = NULL;
}
if ($type != XMLDB_TYPE_NUMBER && $type != XMLDB_TYPE_FLOAT) {
$decimals = NULL;
}
if ($type != XMLDB_TYPE_CHAR && $type != XMLDB_TYPE_TEXT) {
$enum = false;
}
if ($type == XMLDB_TYPE_BINARY) {
$default = NULL;
}
if (!$enum) {
$enumvalues = NULL;
}
if ($default === '') {
$default = NULL;
}
......@@ -232,43 +220,6 @@ class edit_field_save extends XMLDBAction {
$errors[] = $this->str['binaryincorrectlength'];
}
}
/// Enum checks
if ($enum) {
$enumerr = false;
$enumarr = explode(',',$enumvalues);
$maxlength = 0;
if ($enumarr) {
foreach ($enumarr as $key => $enumelement) {
/// Clear some spaces
$enumarr[$key] = trim($enumelement);
$enumelement = trim($enumelement);
/// Calculate needed length
$le = strlen(str_replace("'", '', $enumelement));
if ($le > $maxlength) {
$maxlength = $le;
}
/// Skip if under error
if ($enumerr) {
continue;
}
/// Look for quoted strings
if (substr($enumelement, 0, 1) != "'" ||
substr($enumelement, -1, 1) != "'") {
$enumerr = true;
}
}
} else {
$enumerr = true;
}
if ($enumerr) {
$errors[] = $this->str['enumvaluesincorrect'];
} else {
$enumvalues = $enumarr;
}
if ($length < $maxlength) {
$errors[] = $this->str['wronglengthforenum'];
}
}
if (!empty($errors)) {
$tempfield = new xmldb_field($name);
......@@ -278,8 +229,6 @@ class edit_field_save extends XMLDBAction {
$tempfield->setUnsigned($unsigned);
$tempfield->setNotNull($notnull);
$tempfield->setSequence($sequence);
$tempfield->setEnum($enum);
$tempfield->setEnumValues($enumvalues);
$tempfield->setDefault($default);
/// Prepare the output
$site = get_site();
......@@ -323,8 +272,6 @@ class edit_field_save extends XMLDBAction {
$field->setUnsigned($unsigned);
$field->setNotNull($notnull);
$field->setSequence($sequence);
$field->setEnum($enum);
$field->setEnumValues($enumvalues);
$field->setDefault($default);
/// If the hash has changed from the old one, change the version
......
......@@ -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);
......
......@@ -620,8 +620,8 @@ if ( !is_object($PHPCAS_CLIENT) ) {
/// Define table user to be created
$table = new xmldb_table('tmp_extuser');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_index('username', XMLDB_INDEX_UNIQUE, array('mnethostid', 'username'));
......
......@@ -553,8 +553,8 @@ class auth_plugin_ldap extends auth_plugin_base {
/// Define table user to be created
$table = new xmldb_table('tmp_extuser');
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null, null, null);
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null, null, null);
$table->add_field('id', XMLDB_TYPE_INTEGER, '10', XMLDB_UNSIGNED, XMLDB_NOTNULL, XMLDB_SEQUENCE, null);
$table->add_field('username', XMLDB_TYPE_CHAR, '100', null, XMLDB_NOTNULL, null, null);
$table->add_key('primary', XMLDB_KEY_PRIMARY, array('id'));
$table->add_index('username', XMLDB_INDEX_UNIQUE, array('mnethostid', 'username'));
......
......@@ -47,7 +47,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
/// Changing precision of field transid on table enrol_authorize to (20)
$table = new xmldb_table('enrol_authorize');
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, null, null, '0', 'userid');
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, XMLDB_NOTNULL, null, '0', 'userid');
$dbman->change_field_precision($table, $field);
/// Launch add index transid again
......@@ -65,7 +65,7 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
/// Changing precision of field transid on table enrol_authorize_refunds to (20)
$table = new xmldb_table('enrol_authorize_refunds');
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, null, null, '0', 'amount');
$field = new xmldb_field('transid', XMLDB_TYPE_INTEGER, '20', XMLDB_UNSIGNED, null, null, '0', 'amount');
$dbman->change_field_precision($table, $field);
/// Launch add index transid again
......@@ -79,10 +79,10 @@ function xmldb_enrol_authorize_upgrade($oldversion) {
/// Changing list of values (enum) of field paymentmethod on table enrol_authorize to none
$table = new xmldb_table('enrol_authorize');
$field = new xmldb_field('paymentmethod', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, null, null, 'cc', 'id');
$field = new xmldb_field('paymentmethod', XMLDB_TYPE_CHAR, '6', null, XMLDB_NOTNULL, null, 'cc', 'id');
/// Launch change of list of values for field paymentmethod
$dbman->change_field_enum($table, $field);
$dbman->drop_enum_from_field($table, $field);
}
return $result;
......
......@@ -195,7 +195,6 @@ $string['ddlfieldnotexist'] = 'Field \"$a->fieldname\" does not exist in table \
$string['ddltablealreadyexists'] = 'Table \"$a\" already exists';
$string['ddltablenotexist'] = 'Table \"$a\" does not exist';
$string['ddlunknownerror'] = 'Unknown DDL library error';
$string['ddlunsupportedenums'] = 'Field \"$a\" contains enum info. Enums support has been dropped in Moodle 2.0. Please modify your code to avoid them completely. If you are already using them, please use \$dbman->change_field_enum(\$table, \$field); in your upgrade scripts to drop them ASAP';
$string['ddlxmlfileerror'] = 'XML database file errors found';
$string['dmlreadexception'] = 'Error reading from database';
$string['dmlwriteexception'] = 'Error writing to database';
......
This diff is collapsed.
......@@ -468,14 +468,6 @@ class database_manager {
throw new ddl_exception('ddltablealreadyexists', $xmldb_table->getName());
}
/// Iterate over all fields in table, finding any attempt to add one field with enum info, throw exception
$xmldb_fields = $xmldb_table->getFields();
foreach ($xmldb_fields as $xmldb_field) {
if ($xmldb_field->getEnum()) {
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
}
}
if (!$sqlarr = $this->generator->getCreateTableSQL($xmldb_table)) {
throw new ddl_exception('ddlunknownerror', null, 'table create sql not generated');
}
......@@ -501,14 +493,6 @@ class database_manager {
$this->drop_temp_table($xmldb_table);
}
/// Iterate over all fields in table, finding any attempt to add one field with enum info, throw exception
$xmldb_fields = $xmldb_table->getFields();
foreach ($xmldb_fields as $xmldb_field) {
if ($xmldb_field->getEnum()) {
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
}
}
if (!$sqlarr = $this->generator->getCreateTempTableSQL($xmldb_table)) {
throw new ddl_exception('ddlunknownerror', null, 'temp table create sql not generated');
}
......@@ -599,11 +583,6 @@ class database_manager {
' cannot be added. Not null fields added to non empty tables require default value. Create skipped');
}
/// Detect any attempt to add one field with enum info, throw exception
if ($xmldb_field->getEnum()) {
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
}
if (!$sqlarr = $this->generator->getAddFieldSQL($xmldb_table, $xmldb_field)) {
throw new ddl_exception('ddlunknownerror', null, 'addfield sql not generated');
}
......@@ -693,13 +672,15 @@ class database_manager {
}
/**
* This function will change the enum status of the field in the table passed as arguments
* This function will drop the existing enum of the field in the table passed as arguments
*
* TODO: Moodle 2.1 - Drop drop_enum_from_field()
*
* @param xmldb_table table object (just the name is mandatory)
* @param xmldb_field field object (full specs are required)
* @return void
*/
public function change_field_enum(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
public function drop_enum_from_field(xmldb_table $xmldb_table, xmldb_field $xmldb_field) {
if (!$this->table_exists($xmldb_table)) {
throw new ddl_table_missing_exception($xmldb_table->getName());
}
......@@ -708,18 +689,13 @@ class database_manager {
throw new ddl_field_missing_exception($xmldb_field->getName(), $xmldb_table->getName());
}
/// If enum is defined, we're going to create it, check it doesn't exist.
if ($xmldb_field->getEnum()) {
throw new ddl_exception('ddlunsupportedenums', $xmldb_table->getName() . '->' . $xmldb_field->getName());
} else { /// Else, we're going to drop it, check it exists
if (!$this->check_constraint_exists($xmldb_table, $xmldb_field)) {
debugging('Enum for ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' does not exist. Delete skipped', DEBUG_DEVELOPER);
return; //Enum does not exist, nothing to delete
}
if (!$this->check_constraint_exists($xmldb_table, $xmldb_field)) {
debugging('Enum for ' . $xmldb_table->getName() . '->' . $xmldb_field->getName() .
' does not exist. Delete skipped', DEBUG_DEVELOPER);
return; //Enum does not exist, nothing to delete
}
if (!$sqlarr = $this->generator->getModifyEnumSQL($xmldb_table, $xmldb_field)) {
if (!$sqlarr = $this->generator->getDropEnumSQL($xmldb_table, $xmldb_field)) {
return; //Empty array = nothing to do = no error
}
......
......@@ -79,9 +79,6 @@ abstract class sql_generator {
public $sequence_name_small = false; //Different name for small (4byte) sequences or false if same
public $sequence_only = false; //To avoid to output the rest of the field specs, leaving only the name and the sequence_name publiciable
public $enum_inline_code = true; //Does the generator need to add inline code in the column definition
public $enum_extra_code = true; //Does the generator need to add extra code to generate code for the enums in the table
public $add_table_comments = true; // Does the generator need to add code for table comments
public $add_after_clause = false; // Does the generator need to add the after clause for fields
......@@ -288,15 +285,6 @@ abstract class sql_generator {
}
}
}
/// Add enum extra code if needed
if ($this->enum_extra_code) {
/// Iterate over fields looking for enums
foreach ($xmldb_fields as $xmldb_field) {
if ($xmldb_field->getEnum()) {
$table .= "\n" . $this->getEnumExtraSQL($xmldb_table, $xmldb_field) . ',';
}
}
}
/// Table footer, trim the latest comma
$table = trim($table,',');
$table .= "\n)";
......@@ -434,13 +422,8 @@ abstract class sql_generator {
$field = $this->getEncQuoted($xmldb_field->getName());
/// The type and length only if we don't want to skip it
if (!$skip_type_clause) {
/// The type and length (if the field isn't enum)
if (!$xmldb_field->getEnum() || $this->enum_inline_code == false) {
$field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
} else {
/// call to custom function
$field .= ' ' . $this->getEnumSQL($xmldb_field);
}
/// The type and length
$field .= ' ' . $this->getTypeSQL($xmldb_field->getType(), $xmldb_field->getLength(), $xmldb_field->getDecimals());
}
/// The unsigned if supported
if ($this->unsigned_allowed && ($xmldb_field->getType() == XMLDB_TYPE_INTEGER ||
......@@ -651,14 +634,6 @@ abstract class sql_generator {
}
$results[] = $altertable;
/// If the DB has extra enum code
if ($this->enum_extra_code) {
/// If it's enum add the extra code
if ($xmldb_field->getEnum()) {
$results[] = 'ALTER TABLE ' . $tablename . ' ADD ' . $this->getEnumExtraSQL($xmldb_table, $xmldb_field);
}
}
return $results;
}
......@@ -713,27 +688,6 @@ abstract class sql_generator {
return $results;
}
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the enum of the field in the table
*/
public function getModifyEnumSQL($xmldb_table, $xmldb_field) {
$results = array();
/// Get the quoted name of the table and field
$tablename = $this->getTableName($xmldb_table);
$fieldname = $this->getEncQuoted($xmldb_field->getName());
/// Decide if we are going to create or to drop the enum (based exclusively in the values passed!)
if (!$xmldb_field->getEnum()) {
$results = $this->getDropEnumSQL($xmldb_table, $xmldb_field); //Drop
} else {
$results = $this->getCreateEnumSQL($xmldb_table, $xmldb_field); //Create/modify
}
return $results;
}
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to modify the default of the field in the table
*/
......@@ -1180,20 +1134,6 @@ abstract class sql_generator {
*/
public abstract function getTypeSQL($xmldb_type, $xmldb_length=null, $xmldb_decimals=null);
/**
* Given one XMLDB Field, return its enum SQL to be added inline with the column definition
*/
public function getEnumSQL($xmldb_field) {
return '';
}
/**
* Returns the code needed to create one enum for the xmldb_table and xmldb_field passes
*/
public function getEnumExtraSQL($xmldb_table, $xmldb_field) {
return '';
}
/**
* Returns the code (array of statements) needed to execute extra statements on field rename
*/
......@@ -1231,15 +1171,11 @@ abstract class sql_generator {
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its enum
* (usually invoked from getModifyEnumSQL()
*
* TODO: Moodle 2.1 - Drop getDropEnumSQL()
*/
public abstract function getDropEnumSQL($xmldb_table, $xmldb_field);
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to add its enum
* (usually invoked from getModifyEnumSQL()
*/
public abstract function getCreateEnumSQL($xmldb_table, $xmldb_field);
/**
* Given one xmldb_table and one xmldb_field, return the SQL statements needded to drop its default
* (usually invoked from getModifyDefaultSQL()
......
<!ELEMENT FIELD EMPTY >
<!ATTLIST FIELD DECIMALS NMTOKEN #IMPLIED >
<!ATTLIST FIELD DEFAULT NMTOKEN #IMPLIED >
<!ATTLIST FIELD ENUM ( false | true ) #REQUIRED >
<!-- TODO: Moodle 2.1 - Drop ENUM and ENUMVALUES attributes -->
<!ATTLIST FIELD ENUM ( false | true ) #IMPLIED >
<!ATTLIST FIELD ENUMVALUES CDATA #IMPLIED >
<!ATTLIST FIELD LENGTH NMTOKEN #REQUIRED >
<!ATTLIST FIELD NAME NMTOKEN #REQUIRED >
......
......@@ -72,6 +72,7 @@
<xs:attribute name="NOTNULL" type="trueFalse" use="required" />
<xs:attribute name="DECIMALS" type="xs:positiveInteger" use="optional" />
<xs:attribute name="UNSIGNED" type="trueFalse" use="optional" />
<!-- TODO: Moodle 2.1 - Drop ENUM and ENUMVALUES attributes -->
<xs:attribute name="ENUM" type="trueFalse" use="optional" />
<xs:attribute name="ENUMVALUES" type="xs:string" use="optional" />
<xs:attribute name="DEFAULT" type="xs:string" use="optional" />
......@@ -199,4 +200,4 @@
</xs:complexType>
</xs:element>
</xs:schema>
\ No newline at end of file
</xs:schema>
......@@ -63,7 +63,6 @@
define ('XMLDB_UNSIGNED', true); //If the field is going to be unsigned
define ('XMLDB_NOTNULL', true); //If the field is going to be not null