function boxes_update_6100 in Boxes 7
Same name and namespace in other branches
- 6 boxes.install \boxes_update_6100()
Make boxes content pluggable, move body/format into a serialized options array, add plugin key field.
File
- ./
boxes.install, line 80 - Install, update and uninstall functions for the boxes module.
Code
function boxes_update_6100() {
$ret = array();
$result = db_query("SELECT delta, body, format FROM {custom_block}");
while ($box = db_fetch_object($result)) {
$body = array(
'body' => $box->body,
'format' => $box->format,
);
$box->body = serialize($body);
drupal_write_record('box', $box, 'delta');
}
$spec = array(
'type' => 'text',
'not null' => FALSE,
'size' => 'big',
'serialize' => TRUE,
'description' => 'Block content configuration.',
);
db_change_field('box', 'body', 'options', $spec);
db_drop_field('box', 'format');
$spec = array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => "The plugin responsible for this block.",
);
db_add_field('box', 'plugin_key', $spec);
// TODO Please review the conversion of this statement to the D7 database API syntax.
/* db_query("UPDATE {custom_block} SET plugin_key = 'simple'") */
db_update('custom_block')
->fields(array(
'plugin_key' => 'simple',
))
->execute();
// hook_update_N() no longer returns a $ret array. Instead, return
// nothing or a translated string indicating the update ran successfully.
// See http://drupal.org/node/224333#update_sql.
return t('TODO Add a descriptive string here to show in the UI.');
}