From 35659e9343b94942e5907c65e07f520d962b7ce5 Mon Sep 17 00:00:00 2001
From: Mark Wells <mark@freeside.biz>
Date: Tue, 30 Aug 2016 12:55:54 -0700
Subject: [PATCH] fix password_history schema upgrade from pre-3.8 versions,
 #72265

---
 FS/FS/password_history.pm | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/FS/FS/password_history.pm b/FS/FS/password_history.pm
index a34f6169b..13d16010d 100644
--- a/FS/FS/password_history.pm
+++ b/FS/FS/password_history.pm
@@ -161,9 +161,14 @@ 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) )";
-- 
2.20.1