[freeside-commits] branch master updated. 9f845218894ad8cf48c5cfe8fb4fb492e174c0f2
Ivan
ivan at 420.am
Fri Feb 24 10:22:28 PST 2017
The branch, master has been updated
via 9f845218894ad8cf48c5cfe8fb4fb492e174c0f2 (commit)
from dc852f26b535edeab92beeca5af3aad69fdf5243 (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
- Log -----------------------------------------------------------------
commit 9f845218894ad8cf48c5cfe8fb4fb492e174c0f2
Author: Ivan Kohler <ivan at freeside.biz>
Date: Fri Feb 24 10:22:27 2017 -0800
fix upgrades when cust_pkg.change_to_pkgnum points to a package that was removed, RT#74825
diff --git a/FS/FS/Upgrade.pm b/FS/FS/Upgrade.pm
index a59dc1f..628b6f2 100644
--- a/FS/FS/Upgrade.pm
+++ b/FS/FS/Upgrade.pm
@@ -567,6 +567,8 @@ sub upgrade_schema_data {
#remove records referencing removed things with their FKs
'pkg_referral' => [],
'cust_bill_pkg_discount' => [],
+ #update records referencing removed things with their FKs
+ 'cust_pkg' => [],
;
\%hash;
diff --git a/FS/FS/cust_pkg.pm b/FS/FS/cust_pkg.pm
index 1d0cc4f..039943e 100644
--- a/FS/FS/cust_pkg.pm
+++ b/FS/FS/cust_pkg.pm
@@ -5560,6 +5560,23 @@ sub forward_emails {
}
# Used by FS::Upgrade to migrate to a new database.
+sub _upgrade_schema { # class method
+ my ($class, %opts) = @_;
+
+ my $sql = '
+ UPDATE cust_pkg SET change_to_pkgnum = NULL
+ WHERE change_to_pkgnum IS NOT NULL
+ AND NOT EXISTS ( SELECT 1 FROM cust_pkg AS ctcp
+ WHERE ctcp.pkgnum = cust_pkg.change_to_pkgnum
+ )
+ ';
+
+ my $sth = dbh->prepare($sql) or die dbh->errstr;
+ $sth->execute or die $sth->errstr;
+ '';
+}
+
+# Used by FS::Upgrade to migrate to a new database.
sub _upgrade_data { # class method
my ($class, %opts) = @_;
$class->_upgrade_otaker(%opts);
-----------------------------------------------------------------------
Summary of changes:
FS/FS/Upgrade.pm | 2 ++
FS/FS/cust_pkg.pm | 17 +++++++++++++++++
2 files changed, 19 insertions(+)
More information about the freeside-commits
mailing list