[freeside-commits] freeside/FS/FS Upgrade.pm, 1.31.2.8, 1.31.2.9 cust_bill_pkg_detail.pm, 1.10.2.3, 1.10.2.4
Ivan,,,
ivan at wavetail.420.am
Mon Aug 16 13:11:11 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv19529/FS/FS
Modified Files:
Tag: FREESIDE_1_9_BRANCH
Upgrade.pm cust_bill_pkg_detail.pm
Log Message:
fix upgrade with ancient cust_bill_pkg_detail.classnum but new DBIx::DBSchema, RT#9640
Index: cust_bill_pkg_detail.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/cust_bill_pkg_detail.pm,v
retrieving revision 1.10.2.3
retrieving revision 1.10.2.4
diff -u -w -d -r1.10.2.3 -r1.10.2.4
--- cust_bill_pkg_detail.pm 27 Mar 2010 06:21:57 -0000 1.10.2.3
+++ cust_bill_pkg_detail.pm 16 Aug 2010 20:11:09 -0000 1.10.2.4
@@ -231,11 +231,8 @@
}
-# _upgrade_data
-#
-# Used by FS::Upgrade to migrate to a new database.
-
-sub _upgrade_data { # class method
+# Used by FS::Upgrade to migrate to a new database schema
+sub _upgrade_schema { # class method
my ($class, %opts) = @_;
@@ -313,11 +310,12 @@
}
+}
- if ( defined( dbdef->table($class->table)->column('billpkgnum') ) &&
- defined( dbdef->table($class->table)->column('invnum') ) &&
- defined( dbdef->table($class->table)->column('pkgnum') )
- ) {
+# Used by FS::Upgrade to migrate to a new database
+sub _upgrade_data { # class method
+
+ my ($class, %opts) = @_;
warn "$me Checking for unmigrated invoice line item details\n" if $DEBUG;
@@ -357,8 +355,6 @@
} # if @cbpd
- } # if billpkgnum, invnum, and pkgnum columns defined
-
'';
}
Index: Upgrade.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Upgrade.pm,v
retrieving revision 1.31.2.8
retrieving revision 1.31.2.9
diff -u -w -d -r1.31.2.8 -r1.31.2.9
--- Upgrade.pm 28 Jul 2010 02:54:46 -0000 1.31.2.8
+++ Upgrade.pm 16 Aug 2010 20:11:09 -0000 1.31.2.9
@@ -12,7 +12,7 @@
$FS::svc_domain::whois_hack = 1;
@ISA = qw( Exporter );
- at EXPORT_OK = qw( upgrade upgrade_sqlradius );
+ at EXPORT_OK = qw( upgrade_schema upgrade upgrade_sqlradius );
$DEBUG = 1;
@@ -33,7 +33,7 @@
=over 4
-=item
+=item upgrade
=cut
@@ -86,6 +86,9 @@
}
+=item upgrade_data
+
+=cut
sub upgrade_data {
my %opt = @_;
@@ -147,6 +150,67 @@
}
+=item upgrade_schema
+
+=cut
+
+sub upgrade_schema {
+ my %opt = @_;
+
+ my $data = upgrade_schema_data(%opt);
+
+ my $oldAutoCommit = $FS::UID::AutoCommit;
+ local $FS::UID::AutoCommit = 0;
+ local $FS::UID::AutoCommit = 0;
+
+ foreach my $table ( keys %$data ) {
+
+ my $class = "FS::$table";
+ eval "use $class;";
+ die $@ if $@;
+
+ if ( $class->can('_upgrade_schema') ) {
+ warn "Upgrading $table schema...\n";
+
+ my $start = time;
+
+ $class->_upgrade_schema(%opt);
+
+ if ( $oldAutoCommit ) {
+ warn " committing\n";
+ dbh->commit or die dbh->errstr;
+ }
+
+ #warn "\e[1K\rUpgrading $table... done in ". (time-$start). " seconds\n";
+ warn " done in ". (time-$start). " seconds\n";
+
+ } else {
+ warn "WARNING: asked for schema upgrade of $table,".
+ " but FS::$table has no _upgrade_schema method\n";
+ }
+
+ }
+
+}
+
+=item upgrade_schema_data
+
+=cut
+
+sub upgrade_schema_data {
+ my %opt = @_;
+
+ tie my %hash, 'Tie::IxHash',
+
+ #fix classnum character(1)
+ 'cust_bill_pkg_detail' => [],
+
+ ;
+
+ \%hash;
+
+}
+
sub upgrade_sqlradius {
#my %opt = @_;
More information about the freeside-commits
mailing list