X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=FS%2FFS%2Fpassword_history.pm;h=1915a2185da15f5018a14bdadca8d0c98b985222;hb=691de38ac2ca6c54b37feb50e1332bab6268773f;hp=a34f6169b137ce6a8aea60018721a0953b6af833;hpb=d22baa4e71bfa9e153c1fe1152ff4c748f1d935c;p=freeside.git diff --git a/FS/FS/password_history.pm b/FS/FS/password_history.pm index a34f6169b..1915a2185 100644 --- a/FS/FS/password_history.pm +++ b/FS/FS/password_history.pm @@ -161,13 +161,19 @@ sub password_equals { } sub _upgrade_schema { + my $class = shift; + # if the table doesn't exist yet then nothing needs to happen here + my $dbdef_table = $class->dbdef_table + or return; + # clean up history records where linked_acct has gone away my @where; - for my $fk ( grep /__/, __PACKAGE__->dbdef_table->columns ) { + for my $fk ( grep /__/, $dbdef_table->columns ) { my ($table, $key) = split(/__/, $fk); push @where, " ( $fk IS NOT NULL AND NOT EXISTS(SELECT 1 FROM $table WHERE $table.$key = $fk) )"; } + return '' unless @where; my @recs = qsearch({ 'table' => 'password_history', 'extra_sql' => ' WHERE ' . join(' AND ', @where),