import torrus 1.0.9
[freeside.git] / FS / FS / part_pkg_option.pm
index c2f609e..142622b 100644 (file)
@@ -2,7 +2,7 @@ package FS::part_pkg_option;
 
 use strict;
 use vars qw( @ISA );
-use FS::Record qw( qsearch qsearchs );
+use FS::Record qw( qsearch qsearchs dbh );
 use FS::part_pkg;
 
 @ISA = qw(FS::Record);
@@ -117,6 +117,34 @@ sub check {
 
 =back
 
+=cut
+
+#
+# Used by FS::Upgrade to migrate to a new database.
+#
+#
+
+sub _upgrade_data {  # class method
+  my ($class, %opts) = @_;
+
+  my $sql = "UPDATE part_pkg_option SET optionname = 'recur_fee'".
+            " WHERE optionname = 'recur_flat'";
+  my $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+
+  $sql = "UPDATE part_pkg_option SET optionname = 'recur_method',".
+            "optionvalue = 'prorate'  WHERE optionname = 'enable_prorate'";
+  $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+
+  $sql = "UPDATE part_pkg_option SET optionvalue = NULL WHERE ".
+            "optionname = 'contract_end_months' AND optionvalue = '(none)'";
+  $sth = dbh->prepare($sql) or die dbh->errstr;
+  $sth->execute or die $sth->errstr;
+  '';
+
+}
+
 =head1 BUGS
 
 Possibly.