You are here

function panelizer_update_7101 in Panelizer 7.3

Same name and namespace in other branches
  1. 7.2 panelizer.install \panelizer_update_7101()

Update the panelizer node table to be the panelizer entity table.

File

./panelizer.install, line 393
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.
  $spec = array(
    'description' => 'The type of the entity this panel is attached to.',
    'type' => 'varchar',
    'length' => 255,
  );
  db_add_field('panelizer_entity', 'entity_type', $spec);

  // Rename nid to entity_id.
  $spec = 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', $spec);

  // 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',
  ));
}