View Issue Details

IDProjectCategoryView StatusLast Update
1999RackTablesdefaultpublic2020-11-26 14:42
Reporteraclru Assigned Toinfrastation  
PrioritynormalSeveritymajorReproducibilityalways
Status closedResolutionfixed 
Product Version0.21.5 
Summary1999: Errors when upgrading from 0.20.10 to 0.21.5
DescriptionWhen upgrading from version 0.20.10 to 0.21.5, the upgrade is in progress but errors occur.
Steps To ReproduceInstall 0.20.10
Upgrade from 0.20.10 to 0.21.5
Additional InformationExecuting batch '0.21.2' The following queries failed:
INSERT INTO Chapter (`id`, `sticky`, `name`) VALUES (39,'no','UPS models') -- Duplicate entry 'UPS models' for key 'name'
INSERT INTO AttributeMap (`objtype_id`,`attr_id`,`chapter_id`) VALUES (12,2,39) -- Duplicate entry '12-2' for key 'objtype_id'
Executing batch 'dictionary'


The following queries failed:
INSERT INTO Dictionary (dict_key, chapter_id, dict_value, dict_sticky) VALUES (3689, 39, '[[APC%GPASS%SMT1500RMI2U | http://www.apc.com/products/resource/include/techspec_index.cfm?base_sku=SMT1500RMI2U]]', 'yes'), (3690, 39, '[[APC%GPASS%SMT1500RMI2UNC | http://www.apc.com/products/resource/include/techspec_index.cfm?base_sku=SMT1500RMI2UNC]]', 'yes'), (3691, 12, '[[NETGEAR%GPASS%GS108 | https://www.netgear.com/business/products/switches/unmanaged/GS108.aspx]]', 'yes'), (3692, 12, '[[NETGEAR%GPASS%GS105 | https://www.netgear.com/business/products/switches/unmanaged/GS105.aspx]]', 'yes'), (3693, 13, '[[PROXMOX%GSKIP%Proxmox VE 3.4 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_3.4]]', 'yes'), (3694, 13, '[[PROXMOX%GSKIP%Proxmox VE 4.0 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_4.0]]', 'yes'), (3695, 13, '[[PROXMOX%GSKIP%Proxmox VE 4.1 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_4.1]]', 'yes'), (3696, 13, '[[PROXMOX%GSKIP%Proxmox VE 4.2 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_4.2]]', 'yes'), (3697, 13, '[[PROXMOX%GSKIP%Proxmox VE 4.3 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_4.3]]', 'yes'), (3698, 13, '[[PROXMOX%GSKIP%Proxmox VE 4.4 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_4.4]]', 'yes'), (3699, 13, '[[PROXMOX%GSKIP%Proxmox VE 5.0 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_5.0]]', 'yes'), (3700, 13, '[[PROXMOX%GSKIP%Proxmox VE 5.1 | http://pve.proxmox.com/wiki/Roadmap#Proxmox_VE_5.1]]', 'yes'), (3701, 12, '[[TP-Link%GPASS%T1600G-18TS | https://www.tp-link.com/en/products/details/cat-40_T1600G-18TS.html]]', 'yes'), (3702, 27, '[[Raritan%GPASS%PX3-5514U | http://cdn.raritan.com/product-selector/pdus/PX3-5514U/MPX3-5514U.pdf]]', 'yes'), (3703, 12, '[[HP Aruba%GPASS%3810M 16SFP+ 2-slot (JL075A) | http://duckduckgo.com/?q=JL075A+manual ]]', 'yes'), (3704, 13, 'VMWare Hypervisor%GSKIP%VMware ESXi 6.5', 'yes'), (3705, 17, '[[ Fortinet%GPASS%Fortigate 600D | http://www.fortinet.com/content/dam/fortinet/assets/data-sheets/FortiGate_600D.pdf ]]', 'yes'), (3706, 13, 'Ubuntu%GSKIP%Ubuntu 18.04 LTS', 'yes'), (3707, 12, 'MikroTik%GPASS%CRS328-4C-20S-4S+RM', 'yes'), (3708, 12, 'MikroTik%GPASS%CRS328-24P-4S+RM', 'yes'), (3709, 13, '[[Debian%GSKIP%Debian 9 (Stretch) | http://debian.org/releases/stretch/]]', 'yes'), (3710, 12, 'Arista%GPASS%7170-32C', 'yes'), (3711, 12, 'Arista%GPASS%7170-64C', 'yes'), (3712, 12, 'Arista%GPASS%7060SX2-48YC6', 'yes'), (3713, 12, 'Arista%GPASS%7260CX3-64', 'yes') -- Cannot add or update a child row: a foreign key constraint fails (`racktables_v20_8`.`Dictionary`, CONSTRAINT `Dictionary-FK-chapter_id` FOREIGN KEY (`chapter_id`) REFERENCES `Chapter` (`id`))
Summary Upgrade complete, it is Ok to enter the system.
TagsNo tags attached.

Activities

aclru

aclru

2020-11-16 13:28

reporter  

2020-11-16_17-16-22.png (25,766 bytes)   
2020-11-16_17-16-22.png (25,766 bytes)   
infrastation

infrastation

2020-11-23 23:30

administrator   ~0004205

SELECT * FROM Chapter WHERE name = 'UPS models';
aclru

aclru

2020-11-24 04:22

reporter   ~0004207

MariaDB [racktables_db]> SELECT * FROM Chapter WHERE name = 'UPS models';
+-------+--------+------------+
| id | sticky | name |
+-------+--------+------------+
| 10001 | no | ups models |
+-------+--------+------------+
1 row in set (0.001 sec)

MariaDB [racktables_db]>
infrastation

infrastation

2020-11-24 12:56

administrator   ~0004209

UPDATE Chapter SET name = 'UPS models custom' WHERE id = 10001;
INSERT INTO Chapter (`id`, `sticky`, `name`) VALUES (39,'no','UPS models');

(then the long "INSERT INTO Dictionary" that failed before)

SELECT * FROM AttributeMap WHERE chapter_id = 10001;
SELECT COUNT(*) FROM Dictionary WHERE chapter_id = 10001;
SELECT COUNT(*) FROM AttributeValue WHERE object_tid = 12 AND attr_id = 2;
aclru

aclru

2020-11-25 14:26

reporter   ~0004211

---------------
MariaDB [(none)]> use racktables_db;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [racktables_db]> UPDATE Chapter SET name = 'UPS models custom' WHERE id = 10001;
Query OK, 1 row affected (0.005 sec)
Rows matched: 1 Changed: 1 Warnings: 0

MariaDB [racktables_db]> INSERT INTO Chapter (`id`, `sticky`, `name`) VALUES (39,'no','UPS models');
Query OK, 1 row affected (0.002 sec)

MariaDB [racktables_db]>

MariaDB [racktables_db]> INSERT INTO Dictionary (dict_key, chapter_id, dict_value, dict_sticky) VALUES (3689, 39, '[[APC%GPASS%SMT1500RMI2U
.............
MariaDB [racktables_db]>

++++
Database changed
MariaDB [racktables_db]> SELECT * FROM AttributeMap WHERE chapter_id = 10001;
+------------+---------+------------+--------+
| objtype_id | attr_id | chapter_id | sticky |
+------------+---------+------------+--------+
| 12 | 2 | 10001 | no |
+------------+---------+------------+--------+
1 row in set (0.001 sec)

MariaDB [racktables_db]> SELECT COUNT(*) FROM Dictionary WHERE chapter_id = 10001;
+----------+
| COUNT(*) |
+----------+
| 14 |
+----------+
1 row in set (0.001 sec)

MariaDB [racktables_db]> SELECT COUNT(*) FROM AttributeValue WHERE object_tid = 12 AND attr_id = 2;
+----------+
| COUNT(*) |
+----------+
| 87 |
+----------+
1 row in set (0.001 sec)

MariaDB [racktables_db]>
infrastation

infrastation

2020-11-25 22:54

administrator   ~0004213

The attached script should fix the remaining issues, remember to make a database backup first.
rtmantis1999.php (1,159 bytes)   
#!/usr/bin/env php
<?php

$script_mode = TRUE;
require '/absolute/path/to/racktables/wwwroot/inc/init.php';
define ('MY_OBJTID', 12);
define ('MY_ATTRID', 2);
define ('SYSTEM_CID', 39);
define ('CUSTOM_CID', 10001);
$dbxlink->beginTransaction();

$result = usePreparedSelectBlade
(
	'SELECT dict_key, dict_value FROM Dictionary WHERE chapter_id = ?',
	array (CUSTOM_CID)
);
$custom = $result->fetchAll (PDO::FETCH_ASSOC);
unset ($result);

foreach ($custom as $row)
{
	usePreparedInsertBlade
	(
		'Dictionary',
		array ('chapter_id' => SYSTEM_CID, 'dict_value' => $row['dict_value'])
	);
	$new_id = lastInsertID();
	usePreparedUpdateBlade
	(
		'AttributeValue',
		array ('uint_value' => $new_id),
		array
		(
			'object_tid' => MY_OBJTID,
			'attr_id' => MY_ATTRID,
			'uint_value' => $row['dict_key'],
		)
	);
	usePreparedDeleteBlade ('Dictionary', array ('dict_key' => $row['dict_key']));
}

usePreparedUpdateBlade
(
	'AttributeMap',
	array ('chapter_id' => SYSTEM_CID),
	array
	(
		'objtype_id' => MY_OBJTID,
		'attr_id' => MY_ATTRID,
		'chapter_id' => CUSTOM_CID,
	)
);
usePreparedDeleteBlade ('Chapter', array ('id' => CUSTOM_CID));

$dbxlink->commit();
rtmantis1999.php (1,159 bytes)   
infrastation

infrastation

2020-11-26 14:42

administrator   ~0004215

Closing as resolved.

Issue History

Date Modified Username Field Change
2020-11-16 13:28 aclru New Issue
2020-11-16 13:28 aclru File Added: 2020-11-16_17-16-22.png
2020-11-23 23:30 infrastation Note Added: 0004205
2020-11-24 04:22 aclru Note Added: 0004207
2020-11-24 12:56 infrastation Note Added: 0004209
2020-11-25 14:26 aclru Note Added: 0004211
2020-11-25 22:54 infrastation Note Added: 0004213
2020-11-25 22:54 infrastation File Added: rtmantis1999.php
2020-11-26 14:42 infrastation Assigned To => infrastation
2020-11-26 14:42 infrastation Status new => closed
2020-11-26 14:42 infrastation Resolution open => fixed
2020-11-26 14:42 infrastation Note Added: 0004215