better duplicate checking for ip address, #17515
authorMark Wells <mark@freeside.biz>
Thu, 26 Apr 2012 20:25:50 +0000 (13:25 -0700)
committerMark Wells <mark@freeside.biz>
Thu, 26 Apr 2012 20:25:50 +0000 (13:25 -0700)
FS/FS/Schema.pm
FS/FS/svc_broadband.pm

index 3894f65..d42b946 100644 (file)
@@ -2556,7 +2556,7 @@ sub tables_hashref {
         'plan_id',             'varchar', 'NULL', $char_d, '', '',
       ],
       'primary_key' => 'svcnum',
-      'unique'      => [ [ 'mac_addr' ] ],
+      'unique'      => [ [ 'ip_addr' ], [ 'mac_addr' ] ],
       'index'       => [],
     },
 
index 64cc377..8210269 100755 (executable)
@@ -543,9 +543,9 @@ sub _check_ip_addr {
 
 sub _check_duplicate {
   my $self = shift;
-
-  $self->lock_table;
-
+  # Not a reliable check because the table isn't locked, but 
+  # that's why we have a unique index.  This is just to give a
+  # friendlier error message.
   my @dup;
   @dup = $self->find_duplicates('global', 'ip_addr');
   if ( @dup ) {