[freeside-commits] freeside/FS/FS Upgrade.pm,1.43,1.44
Ivan,,,
ivan at wavetail.420.am
Mon Aug 16 13:11:32 PDT 2010
Update of /home/cvs/cvsroot/freeside/FS/FS
In directory wavetail.420.am:/tmp/cvs-serv19604/FS/FS
Modified Files:
Upgrade.pm
Log Message:
fix upgrade with ancient cust_bill_pkg_detail.classnum but new DBIx::DBSchema, RT#9640
Index: Upgrade.pm
===================================================================
RCS file: /home/cvs/cvsroot/freeside/FS/FS/Upgrade.pm,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -w -d -r1.43 -r1.44
--- Upgrade.pm 28 Jul 2010 23:16:29 -0000 1.43
+++ Upgrade.pm 16 Aug 2010 20:11:30 -0000 1.44
@@ -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 = @_;
@@ -166,6 +169,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