block_class.install in Block Class 6
Same filename and directory in other branches
Provides the (un)install and update logic for block_class.
File
block_class.installView source
<?php
/**
* @file
* Provides the (un)install and update logic for block_class.
*/
/**
* Implements hook_schema().
*/
function block_class_schema() {
$schema['block_class'] = array(
'fields' => array(
'module' => array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'The module to which the block belongs.',
),
'delta' => array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The ID of the module's block.",
),
'css_class' => array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'String containing the classes for the block.',
),
),
'primary key' => array(
'module',
'delta',
),
);
return $schema;
}
/**
* Implements hook_install().
*/
function block_class_install() {
drupal_install_schema('block_class');
}
/**
* Implements hook_uninstall().
*/
function block_class_uninstall() {
drupal_uninstall_schema('block_class');
}
/**
* Alters the structure of {block_class} schema.
*/
function block_class_update_6100() {
$ret = array();
// Removed. This schema update made new installations of post-6.x-1.3
// snapshots fail due to a too long primary key index. As many users updated
// to it anyway, the corrected schema change has been moved to
// block_class_update_6101() now.
return $ret;
}
/**
* Fix too long primary key length in {block_class}.
*/
function block_class_update_6101() {
$ret = array();
// Drop current primary key.
db_drop_primary_key($ret, 'block_class');
db_change_field($ret, 'block_class', 'module', 'module', array(
'type' => 'varchar',
'length' => 64,
'not null' => TRUE,
'description' => 'The module to which the block belongs.',
));
db_change_field($ret, 'block_class', 'delta', 'delta', array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'description' => "The ID of the module's block.",
));
db_change_field($ret, 'block_class', 'css_class', 'css_class', array(
'type' => 'varchar',
'length' => 255,
'not null' => TRUE,
'description' => 'String containing the classes for the block.',
));
// Create new primary key.
db_add_primary_key($ret, 'block_class', array(
'module',
'delta',
));
return $ret;
}
Functions
Name | Description |
---|---|
block_class_install | Implements hook_install(). |
block_class_schema | Implements hook_schema(). |
block_class_uninstall | Implements hook_uninstall(). |
block_class_update_6100 | Alters the structure of {block_class} schema. |
block_class_update_6101 | Fix too long primary key length in {block_class}. |