r3689 make AttributeValue-FK-object_id ON DELETE CASCADE
authorDenis Ovsienko <infrastation@yandex.ru>
Sun, 30 May 2010 13:41:36 +0000 (13:41 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Sun, 30 May 2010 13:41:36 +0000 (13:41 +0000)
inc/database.php
install/init-structure.sql
upgrade.php

index dd120cb..8b55632 100644 (file)
@@ -650,7 +650,6 @@ function commitDeleteObject ($object_id = 0)
        global $dbxlink;
        releaseFiles ('object', $object_id);
        destroyTagsForEntity ('object', $object_id);
-       $dbxlink->query("DELETE FROM AttributeValue WHERE object_id = ${object_id}");
        $dbxlink->query("DELETE FROM IPv4LB WHERE object_id = ${object_id}");
        $dbxlink->query("DELETE FROM IPv4Allocation WHERE object_id = ${object_id}");
        $dbxlink->query("DELETE FROM Link WHERE porta IN (SELECT id FROM Port WHERE object_id = ${object_id}) OR portb IN (SELECT id FROM Port WHERE object_id = ${object_id})");
index b300b82..047cfb4 100644 (file)
@@ -31,7 +31,7 @@ CREATE TABLE `AttributeValue` (
   `uint_value` int(10) unsigned default NULL,
   `float_value` float default NULL,
   UNIQUE KEY `object_id` (`object_id`,`attr_id`),
-  CONSTRAINT `AttributeValue-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`)
+  CONSTRAINT `AttributeValue-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE
 ) ENGINE=InnoDB;
 
 CREATE TABLE `CachedPAV` (
index 1987a8f..c01265a 100644 (file)
@@ -661,6 +661,8 @@ CREATE TABLE `VLANValidID` (
                        $query[] = "ALTER TABLE RackRow ENGINE=InnoDB";
                        $query[] = "ALTER TABLE RackSpace ENGINE=InnoDB";
                        $query[] = "ALTER TABLE Script ENGINE=InnoDB";
+                       $query[] = "ALTER TABLE AttributeValue DROP FOREIGN KEY `AttributeValue-FK-object_id`";
+                       $query[] = "ALTER TABLE AttributeValue ADD CONSTRAINT `AttributeValue-FK-object_id` FOREIGN KEY (`object_id`) REFERENCES `RackObject` (`id`) ON DELETE CASCADE";
                        $query[] = "UPDATE Config SET varvalue = '0.18.1' WHERE varname = 'DB_VERSION'";
                        break;
                default: