[Ovirt-devel] [PATCH server] BUG#467099: Fixes a uniqueness constraint bug in bondings_nics.

Darryl L. Pierce dpierce at redhat.com
Thu Oct 23 12:20:51 UTC 2008


It moves the uniqueness constraint from being on the pair (bonding_id, nic_id)
to being only on nic_id. The goal is just to ensure that a nic is only mapped
once to any bonding.

You will need to run a migration with this patch.

Signed-off-by: Darryl L. Pierce <dpierce at redhat.com>
---
 ...ll.rb => 026_allow_nic_boot_type_to_be_null.rb} |    0 
 ..._fix_uniqueness_constraints_in_bondings_nics.rb |   11 +++++++++++
 2 files changed, 11 insertions(+), 0 deletions(-)
 rename src/db/migrate/{025_allow_nic_boot_type_to_be_null.rb => 026_allow_nic_boot_type_to_be_null.rb} (100%)
 create mode 100644 src/db/migrate/027_fix_uniqueness_constraints_in_bondings_nics.rb

diff --git a/src/db/migrate/025_allow_nic_boot_type_to_be_null.rb b/src/db/migrate/026_allow_nic_boot_type_to_be_null.rb
similarity index 100%
rename from src/db/migrate/025_allow_nic_boot_type_to_be_null.rb
rename to src/db/migrate/026_allow_nic_boot_type_to_be_null.rb
diff --git a/src/db/migrate/027_fix_uniqueness_constraints_in_bondings_nics.rb b/src/db/migrate/027_fix_uniqueness_constraints_in_bondings_nics.rb
new file mode 100644
index 0000000..0daa210
--- /dev/null
+++ b/src/db/migrate/027_fix_uniqueness_constraints_in_bondings_nics.rb
@@ -0,0 +1,11 @@
+class FixUniquenessConstraintsInBondingsNics < ActiveRecord::Migration
+  def self.up
+    remove_index :bondings_nics, [:bonding_id, :nic_id]
+    add_index :bondings_nics, :nic_id, :unique => true
+  end
+
+  def self.down
+    remove_index :bondings_nics, :nic_id
+    add_index :bondings_nics, [:bonding_id, :nic_id], :unique => true
+  end
+end
-- 
1.5.5.1




More information about the ovirt-devel mailing list