View source
<?php
function submenutree_schema() {
$schema['node_submenutree'] = array(
'description' => t('The base table for submenutree'),
'fields' => array(
'nid' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'submenutree_enable' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'submenutree_title' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'submenutree_display' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'submenutree_weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'siblingmenutree_enable' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'siblingmenutree_title' => array(
'type' => 'varchar',
'length' => '255',
'not null' => TRUE,
'default' => '',
),
'siblingmenutree_display' => array(
'type' => 'int',
'unsigned' => TRUE,
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'siblingmenutree_weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
),
'primary key' => array(
'nid',
),
);
return $schema;
}
function submenutree_install() {
drupal_install_schema('submenutree');
}
function submenutree_uninstall() {
drupal_uninstall_schema('submenutree');
}
function submenutree_update_5001() {
$ret = array();
switch ($GLOBALS['db_type']) {
case 'mysql':
case 'mysqli':
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD submenutree_enable int(10) unsigned NOT NULL default '0' AFTER nid");
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD submenutree_title varchar(255) NOT NULL default '' AFTER submenutree_enable");
$ret[] = update_sql("ALTER TABLE {node_submenutree} CHANGE display submenutree_display int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {node_submenutree} CHANGE weight submenutree_weight int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_enable int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_title varchar(255) NOT NULL default ''");
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_display int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("ALTER TABLE {node_submenutree} ADD siblingmenutree_weight int(10) unsigned NOT NULL default '0'");
$ret[] = update_sql("UPDATE {node_submenutree} SET submenutree_enable = 1");
break;
}
return $ret;
}
function submenutree_update_6001() {
$fields = array(
'submenutree_weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
'siblingmenutree_weight' => array(
'type' => 'int',
'not null' => TRUE,
'default' => 0,
'disp-width' => '10',
),
);
$ret = array();
foreach ($fields as $field => $spec) {
db_change_field($ret, 'node_submenutree', $field, $field, $spec);
}
return $ret;
}