Migrate {block_custom} to {custom_block}.
Note this table now resides in custom_block_schema() but for 7.x to 8.x upgrades, changes must be made from block module as custom_block module is only enabled during upgrade process.
function block_update_8007() {
// Populate the {custom_block} and {custom_block_revision} table.
$results = db_select('block_custom', 'bc')
->fields('bc')
->execute();
$uuid = new Uuid();
$execute = FALSE;
$block_insert = db_insert('custom_block')
->fields(array(
'id',
'uuid',
'info',
'revision_id',
'langcode',
'type',
));
$revision_insert = db_insert('custom_block_revision')
->fields(array(
'id',
'revision_id',
'log',
'info',
));
foreach ($results as $block) {
$custom_block = array(
'id' => $block->bid,
'uuid' => $uuid
->generate(),
'info' => $block->info,
'revision_id' => $block->bid,
'langcode' => Language::LANGCODE_NOT_SPECIFIED,
'type' => 'basic',
);
$revision = array(
'id' => $block->bid,
'revision_id' => $block->bid,
'info' => $block->info,
'log' => 'Initial value from 7.x to 8.x upgrade',
);
$block_insert
->values($custom_block);
$revision_insert
->values($revision);
// We have something to execute.
$execute = TRUE;
}
if ($execute) {
$block_insert
->execute();
$revision_insert
->execute();
}
}