View source
<?php
function tb_megamenu_schema() {
$schema = array();
$schema['tb_megamenus'] = array(
'fields' => array(
'menu_name' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
),
'block_config' => array(
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
),
'menu_config' => array(
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
),
'language' => array(
'type' => 'varchar',
'length' => '12',
'not null' => TRUE,
'default' => '',
),
),
'primary key' => array(
'menu_name',
'language',
),
);
return $schema;
}
function tb_megamenu_update_7101(&$sandbox) {
db_query("ALTER TABLE {tb_megamenus} DROP primary key");
$field = array(
'type' => 'varchar',
'length' => 12,
'not null' => TRUE,
'default' => '',
);
$keys_new = array(
'primary key' => array(
'menu_name',
'language',
),
);
db_add_field('tb_megamenus', 'language', $field, $keys_new);
db_query("UPDATE {tb_megamenus} SET language = :language", array(
':language' => $GLOBALS['language']->language,
));
return t('Added language field and set all existing menus to current language');
}
function tb_megamenu_update_7102(&$sandbox) {
}
function tb_megamenu_update_7103(&$sandbox) {
db_change_field('tb_megamenus', 'block_config', 'block_config', array(
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
));
db_change_field('tb_megamenus', 'menu_config', 'menu_config', array(
'type' => 'text',
'size' => 'medium',
'not null' => FALSE,
));
}