function panelizer_update_7105 in Panelizer 7.3
Add the view mode field.
File
- ./
panelizer.install, line 496 - Install, update and uninstall functions for the panelizer module.
Code
function panelizer_update_7105() {
$spec = array(
'type' => 'varchar',
'length' => '128',
'description' => 'Contains the view mode this panelizer is for.',
'not null' => TRUE,
'default' => 'page_manager',
);
// Update both of the Panelizer tables.
foreach (array(
'panelizer_defaults',
'panelizer_entity',
) as $table) {
if (db_field_exists($table, 'view_mode')) {
// Update all existing records so they have a valid "view_mode" value.
db_update($table)
->fields(array(
'view_mode' => 'page_manager',
))
->execute();
// Providing a code path for sites that errored out when running a
// previous version of this update hook.
db_change_field($table, 'view_mode', 'view_mode', $spec);
}
else {
db_add_field($table, 'view_mode', $spec);
}
// Remove the default value; default was set only to allow tables with
// existing data to run this update nicely.
db_field_set_no_default($table, 'view_mode');
}
}