I have a custom module which defines a custom entity. Now I would like to add a new field to this entity without reinstalling my module. I tried it with the hook_update_N()
function:
/**
* Description
*/
function MY_MODULE_update_7100() {
$spec = array(
'type' => 'int',
'description' => 'Description',
'not null' => FALSE,
);
db_add_field('my_table', 'my_new_field', $spec);
}
in my Module, I updated my existing hook_entity_property_info_alter
to add the definition for this field:
function MY_MODULE_entity_property_info_alter(&$info) {
$props = &$info['my_entity']['properties'];
// snip
$props['my_new_field'] = array(
'label' => t('My Label'),
'type' => 'integer',
'description' => t('My Description'),
'schema field' => 'my_new_field',
);
// snap
}
After updating, I can still create and update the entity, but sadly not my new Field which I created.
What did I wrong?
I looked for an example in the commerce module. But the module is using drupal_write_record
instead of entity_save
.
PS: I already saw this issue but it didn't worked.