You are here

function block_machine_name_update_7100 in Block Machine Name 7

Add the 'module' field to block_machine_name_boxes and set its values to 'block'.

File

./block_machine_name.install, line 49
Install, uninstall and schema functions for the Block Machine Name module.

Code

function block_machine_name_update_7100(&$sandbox) {

  // Add a 'module' field
  $spec = array(
    'type' => 'varchar',
    'description' => "Module",
    'length' => 255,
    'not null' => TRUE,
    'default' => '',
  );
  db_add_field('block_machine_name_boxes', 'module', $spec);

  // All entries in this table up to now would have come from the block module, so set all values for 'module' to 'block'
  db_query("UPDATE {block_machine_name_boxes} SET module = 'block'");

  // The primary key for this table is no longer really unique, multiple module's may have the same block delta
  db_drop_primary_key('block_machine_name_boxes');

  // Rename 'bid' to 'delta', since it's really a more accurate name
  $spec = array(
    'description' => 'Unique ID for block within a module.',
    'type' => 'int',
    'unsigned' => TRUE,
    'not null' => TRUE,
    'default' => 0,
    'no export' => FALSE,
  );
  db_change_field('block_machine_name_boxes', 'bid', 'delta', $spec);
}