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
=item new HASHREF
-Creates a new example. To add the example to the database, see L<"insert">.
+Creates a new record. To add the record to the database, see L<"insert">.
Note that this stores the hash reference, not a distinct copy of the hash it
points to. You can ask the object for a copy with the I<hash> method.
=item check
-Checks all fields to make sure this is a valid example. If there is
+Checks all fields to make sure this is a valid record. If there is
an error, returns the error, otherwise returns false. Called by the insert
and replace methods.
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
=cut
my %ops = (
- C => [ '==', ':=', '+=', '!=', '>', '>=', '<', '<=', '=~', '!~', '=*', '!*' ],
+ C => [ '=', '==', ':=', '+=', '!=', '>', '>=', '<', '<=', '=~', '!~', '=*', '!*' ],
R => [ '=', ':=', '+=' ],
);
=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