Merge "Refactor the value field size in field_property_list module"

This commit is contained in:
Jenkins 2015-02-04 16:29:31 +00:00 committed by Gerrit Code Review
commit d2c0051c0e
1 changed files with 37 additions and 1 deletions

View File

@ -7,7 +7,7 @@
function field_property_list_field_schema($field) {
$columns = array(
'key' => array('type' => 'varchar', 'length' => 32, 'not null' => TRUE),
'value' => array('type' => 'varchar', 'length' => 128, 'not null' => FALSE),
'value' => array('type' => 'varchar', 'length' => 256, 'not null' => FALSE),
);
$indexes = array(
'key' => array('key'),
@ -17,3 +17,39 @@ function field_property_list_field_schema($field) {
'indexes' => $indexes,
);
}
/**
* Returns all fields created on the system of the type defined in field_property_list.
*/
function field_property_list_get_field_property_list_fields() {
$types = array_keys(field_property_list_field_info()); // field types defined in mymodule
$fields = array();
foreach (field_info_fields() as $field) {
if (in_array($field['type'], $types)) {
$fields[] = $field;
}
}
return $fields;
}
/**
* Change field schema's value.length to 256.
*/
function field_property_list_update_7000() {
$fields = field_property_list_get_field_property_list_fields();
foreach ($fields as $field) {
$table_prefixes = array(
_field_sql_storage_tablename($field),
_field_sql_storage_revision_tablename($field)
);
foreach ($table_prefixes as $table_prefix) {
$field_name = $field['field_name'];
$table = $table_prefix;
$column = $field_name . '_value';
$spec = array('type' => 'varchar', 'length' => 256, 'not null' => FALSE);
db_change_field($table, $column, $column, $spec);
}
}
return array();
}