function panelizer_update_7101 in Panelizer 7.2
Same name and namespace in other branches
- 7.3 panelizer.install \panelizer_update_7101()
Update the panelizer node table to be the panelizer entity table.
File
- ./
panelizer.install, line 242 - Install, update and uninstall functions for the panelizer module.
Code
function panelizer_update_7101() {
// Rename the table.
db_rename_table('panelizer_node', 'panelizer_entity');
// Remove the primary key.
db_drop_primary_key('panelizer_entity');
// Add the entity type.
$entity_type = array(
'description' => 'The type of the entity this panel is attached to.',
'type' => 'varchar',
'length' => 255,
);
db_add_field('panelizer_entity', 'entity_type', $entity_type);
// Rename nid to entity_id.
$entity_id = array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'description' => 'The entity ID this panel is attached to.',
);
db_change_field('panelizer_entity', 'nid', 'entity_id', $entity_id);
// Update the entity_type field to 'node' since all pre-existing
// panelizer objects are nodes.
db_update('panelizer_entity')
->fields(array(
'entity_type' => 'node',
))
->execute();
// Add the new index
db_add_primary_key('panelizer_entity', array(
'entity_type',
'entity_id',
));
}