MDL-87158 tool_xmldb: make generated code to rename field idempotent.
Consistent with similar DDL structure change code generated by this tool, and allows for upgrade steps to be replayed without errors.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
issueNumber: MDL-87158
|
||||
notes:
|
||||
tool_xmldb:
|
||||
- message: >-
|
||||
Generated `rename_field(...)` upgrade step code now checks for field
|
||||
existence, to ensure it can be executed multiple times
|
||||
type: changed
|
||||
@@ -416,8 +416,10 @@ class view_table_php extends XMLDBAction {
|
||||
|
||||
// Launch the proper DDL
|
||||
$result .= XMLDB_LINEFEED;
|
||||
$result .= ' // Launch rename field ' . $field->getName() . '.' . XMLDB_LINEFEED;
|
||||
$result .= ' $dbman->rename_field($table, $field, ' . "'" . 'NEWNAMEGOESHERE' . "'" . ');' . XMLDB_LINEFEED;
|
||||
$result .= ' // Conditionally launch rename field ' . $field->getName() . '.' . XMLDB_LINEFEED;
|
||||
$result .= ' if ($dbman->field_exists($table, $field)) {' . XMLDB_LINEFEED;
|
||||
$result .= ' $dbman->rename_field($table, $field, ' . "'" . 'NEWNAMEGOESHERE' . "'" . ');' . XMLDB_LINEFEED;
|
||||
$result .= ' }' . XMLDB_LINEFEED;
|
||||
|
||||
// Add the proper upgrade_xxxx_savepoint call
|
||||
$result .= $this->upgrade_savepoint_php ($structure);
|
||||
|
||||
Reference in New Issue
Block a user