fix TeleAPI import (what kind of crack was Christopher smoking that he couldn't fix...
[freeside.git] / FS / FS / radius_attr.pm
index cc03b4d..1b7df2e 100644 (file)
@@ -1,9 +1,11 @@
 package FS::radius_attr;
+use base qw( FS::Record );
 
 use strict;
-use base qw( FS::Record );
-use FS::Record qw( qsearch qsearchs );
 use vars qw( $noexport_hack );
+use FS::Record qw( qsearch dbh );
+
+$noexport_hack = 0;
 
 =head1 NAME
 
@@ -174,13 +176,6 @@ sub check {
 
 Returns the L<FS::radius_group> object to which this attribute applies.
 
-=cut
-
-sub radius_group {
-  my $self = shift;
-  qsearchs('radius_group', { 'groupnum' => $self->groupnum });
-}
-
 =back
 
 =head1 CLASS METHODS
@@ -207,6 +202,21 @@ sub ops {
 
 =back
 
+=cut
+
+sub _upgrade_schema {
+  my ($class, %opts) = @_;
+
+  my $sql = '
+    DELETE FROM radius_attr WHERE NOT EXISTS
+      ( SELECT 1 FROM radius_group WHERE radius_group.groupnum = radius_attr.groupnum )
+  ';
+
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+  '';
+}
+
 =head1 BUGS
 
 =head1 SEE ALSO