Please could you update DynamicField::deleteField() with an option to keep the table column intact on the database. This is desirable for some things, for example if you are enabling or disabling a feature that makes use of a custom column, and want to keep the data intact when disabling the feature.
I propose updating the function with the following, which has been filed in the Sugar bug tracker under #39776:
PHP Code:function deleteField($widget, $drop_column = true)
{
require_once('modules/DynamicFields/templates/Fields/TemplateField.php');
global $beanList;
if (!($widget instanceof TemplateField)) {
$field_name = $widget;
$widget = new TemplateField();
$widget->name = $field_name;
}
$object_name = $beanList[$this->module];
if ($object_name == 'aCase')
$object_name = 'Case';
$GLOBALS['db']->query("DELETE FROM fields_meta_data WHERE id='{$this->module}{$widget->name}'; ");
if($drop_column)
{
$sql = $widget->get_db_delete_alter_table( $this->bean->table_name . "_cstm" ) ;
if (! empty( $sql ) )
{
$GLOBALS['db']->query( $sql );
$GLOBALS['log']->debug("deleted column from {$this->bean->table_name}_cstm");
}
}
VardefManager::clearVardef();
VardefManager::refreshVardefs($this->module, $object_name);
}


LinkBack URL
About LinkBacks



Reply With Quote
Bookmarks