Maor Lipchuk has uploaded a new change for review. Change subject: core: Add fk constraint on vm_interface_statistics ......................................................................
core: Add fk constraint on vm_interface_statistics Once a network interface is being removed from the Data Base its corresponding statistics data in _vm_interface_statistics should be removed also. Currently, when a Storge Domain is being detached from a Data Center, all the data related to it is being removed from the Data Base. Since there is no foreign key between vm_interface and vm_interface_statistics which does cascade delete there are left overs which are left in vm_interface_statistics although the vm_interface was deleted. also, remove redundant vm interface statistic without VM. Changing the test accordingly. Change-Id: I53cf2737ef91cf967c93990fcb237f6c4e12a8f8 Bug-Url: https://bugzilla.redhat.com/1196251 Signed-off-by: Maor Lipchuk <[email protected]> --- M backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkStatisticsDaoTest.java M backend/manager/modules/dal/src/test/resources/fixtures.xml A packaging/dbscripts/upgrade/03_05_1240_add_delete_contraint_vm_interface_statistics.sql 3 files changed, 6 insertions(+), 11 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/43/38243/1 diff --git a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkStatisticsDaoTest.java b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkStatisticsDaoTest.java index cf7d06d..7903655 100644 --- a/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkStatisticsDaoTest.java +++ b/backend/manager/modules/dal/src/test/java/org/ovirt/engine/core/dao/network/VmNetworkStatisticsDaoTest.java @@ -121,7 +121,7 @@ @Test public void testUpdateAll() throws Exception { VmNetworkStatistics existingStats = dao.get(INTERFACE_ID); - VmNetworkStatistics existingStats2 = dao.get(new Guid("e2817b12-f873-4046-b0da-0098293c14fe")); + VmNetworkStatistics existingStats2 = dao.get(new Guid("e2817b12-f873-4046-b0da-0098293c0000")); existingStats.setReceiveDropRate(10.0); existingStats2.setStatus(InterfaceStatus.DOWN); diff --git a/backend/manager/modules/dal/src/test/resources/fixtures.xml b/backend/manager/modules/dal/src/test/resources/fixtures.xml index 3fd8918..d381760 100644 --- a/backend/manager/modules/dal/src/test/resources/fixtures.xml +++ b/backend/manager/modules/dal/src/test/resources/fixtures.xml @@ -5146,16 +5146,6 @@ <null /> </row> <row> - <value>e2817b12-f873-4046-b0da-0098293c14fe</value> - <value>77296e00-0cad-4e5a-9299-008a7b6f4355</value> - <value>0</value> - <value>0</value> - <value>0</value> - <value>0</value> - <value>1</value> - <null /> - </row> - <row> <value>e2817b12-f873-4046-b0da-0098293c0000</value> <value>1b85420c-b84c-4f29-997e-0eb674b40b79</value> <value>0</value> diff --git a/packaging/dbscripts/upgrade/03_05_1240_add_delete_contraint_vm_interface_statistics.sql b/packaging/dbscripts/upgrade/03_05_1240_add_delete_contraint_vm_interface_statistics.sql new file mode 100644 index 0000000..968b76c --- /dev/null +++ b/packaging/dbscripts/upgrade/03_05_1240_add_delete_contraint_vm_interface_statistics.sql @@ -0,0 +1,5 @@ +-- Remove leftovers of vm_interface_statistics orphan childs. +DELETE FROM vm_interface_statistics +WHERE id NOT IN (SELECT id from vm_interface); + +SELECT fn_db_create_constraint('vm_interface_statistics', 'fk_vm_interface_statistics_vm_interface', 'FOREIGN KEY (id) REFERENCES vm_interface(id) ON DELETE CASCADE'); -- To view, visit https://gerrit.ovirt.org/38243 To unsubscribe, visit https://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I53cf2737ef91cf967c93990fcb237f6c4e12a8f8 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Maor Lipchuk <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
