Skip to content

Commit

Permalink
Fix for vdef table creation
Browse files Browse the repository at this point in the history
Tables were not created because primary key was: KEY PRIMARY 'id' Instead of PRIMARY KEY 'id

Saw some weird behaviour when switching between 0.8.8g and 1.0, this was solved when browser was closed between upgrades.

Removed top and bottom header

Issues:
1. the new way of creating tables with db_create_table doesnt give any log output, if it fails it fails silently.
2. after upgrade user are sent to login page but cant login with admin/admin, realm problem?
  • Loading branch information
micke2k committed Mar 24, 2016
1 parent 6671b75 commit d98d266
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
4 changes: 2 additions & 2 deletions cacti.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3669,7 +3669,7 @@ CREATE TABLE vdef (
hash varchar(32) NOT NULL default '',
name varchar(255) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
PRIMARY KEY (id)
) ENGINE=MyISAM;
) ENGINE=MyISAM COMMENT='vdef';

--
-- Dumping data for table `vdef`
Expand All @@ -3696,7 +3696,7 @@ CREATE TABLE vdef_items (
value varchar(150) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL default '',
PRIMARY KEY (id),
KEY vdef_id (vdef_id)
) ENGINE=MyISAM;
) ENGINE=MyISAM COMMENT='vdef items';

--
-- Dumping data for table `vdef_items`
Expand Down
14 changes: 9 additions & 5 deletions install/0_8_8g_to_1_0_0.php
Original file line number Diff line number Diff line change
Expand Up @@ -1232,27 +1232,31 @@ function upgrade_to_1_0_0() {
ADD COLUMN legend_direction varchar(10) DEFAULT NULL AFTER t_legend_direction');

/* create new table VDEF */
unset($data);
$data = array();
$data['columns'][] = array('name' => 'id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'auto_increment' => true);
$data['columns'][] = array('name' => 'hash', 'type' => 'varchar(32)', 'NULL' => false, 'default' => '');
$data['columns'][] = array('name' => 'name', 'type' => 'varchar(255)', 'NULL' => false, 'default' => '');
$data['keys'][] = array('name' => 'PRIMARY', 'columns' => 'id', 'primary' => true);
$data['primary'] = 'id';
$data['comment'] = 'vdef';
$data['type'] = 'MyISAM';
db_table_create('vdef', $data);

/* create new table VDEF_ITEMS */
unset($data);
$data = array();
$data['columns'][] = array('name' => 'id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'auto_increment' => true);
$data['columns'][] = array('name' => 'hash', 'type' => 'varchar(32)', 'NULL' => false, 'default' => '');
$data['columns'][] = array('name' => 'vdef_id', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'default' => 0);
$data['columns'][] = array('name' => 'sequence', 'type' => 'mediumint(8)', 'unsigned' => 'unsigned', 'NULL' => false, 'default' => 0);
$data['columns'][] = array('name' => 'type', 'type' => 'tinyint(2)', 'NULL' => false, 'default' => 0);
$data['columns'][] = array('name' => 'value', 'type' => 'varchar(150)', 'NULL' => false, 'default' => '');
$data['keys'][] = array('name' => 'PRIMARY', 'columns' => 'id', 'primary' => true);
$data['primary'] = 'id';
$data['keys'][] = array('name' => 'vdef_id', 'columns' => 'vdef_id');
$data['comment'] = 'vdef items';
$data['type'] = 'MyISAM';
db_table_create('vdef_items', $data);



/* fill table VDEF */
db_install_execute("1.0.0", "REPLACE INTO `vdef` VALUES (1, 'e06ed529238448773038601afb3cf278', 'Maximum');");
db_install_execute("1.0.0", "REPLACE INTO `vdef` VALUES (2, 'e4872dda82092393d6459c831a50dc3b', 'Minimum');");
Expand Down Expand Up @@ -1353,7 +1357,7 @@ function upgrade_to_1_0_0() {

db_install_execute('1.0.0', "REPLACE INTO data_source_profiles_cf
(data_source_profile_id, consolidation_function_id)
SELECT '$id' AS data_source_profile_id, consolidation_function_id FROM rra_cf WHERE id=" . $r);
SELECT '$id' AS data_source_profile_id, consolidation_function_id FROM rra_cf WHERE rra_id=" . $r);
}

db_install_execute('1.0.0', "UPDATE data_template_data
Expand Down
12 changes: 5 additions & 7 deletions install/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,7 @@

include_once('../include/global.php');

top_header();

api_plugin_hook('console_before');

/* allow the upgrade script to run for as long as it needs to */
ini_set('max_execution_time', '0');
Expand Down Expand Up @@ -877,6 +875,11 @@ function install_file_paths () {
</select>
</p>

<?php if ($default_install_type == '3') {
print '<p> <font color="#FF0000">WARNING - If you are upgrading from a previous version please close all Cacti browser sessions and clear cache before continuing</font></p>';
}
?>

<p>The following information has been determined from Cacti's configuration file.
If it is not correct, please edit 'include/config.php' before continuing.</p>

Expand Down Expand Up @@ -1136,8 +1139,3 @@ function install_file_paths () {
</form>

<?php

api_plugin_hook('console_after');

bottom_footer();

0 comments on commit d98d266

Please sign in to comment.