+ #remove bad pending records
+ 'cust_pay_pending' => [],
+
+ #replace invnum and pkgnum with billpkgnum
+ 'cust_bill_pkg_detail' => [],
+
+ #usage_classes if we have none
+ 'usage_class' => [],
+
+ #phone_type if we have none
+ 'phone_type' => [],
+
+ #fixup access rights
+ 'access_right' => [],
+
+ #change recur_flat and enable_prorate
+ 'part_pkg_option' => [],
+
+ #add weights to pkg_category
+ 'pkg_category' => [],
+
+ #cdrbatch fixes
+ 'cdr' => [],
+
+ #otaker->usernum
+ 'cust_attachment' => [],
+ #'cust_credit' => [],
+ #'cust_main' => [],
+ 'cust_main_note' => [],
+ #'cust_pay' => [],
+ 'cust_pay_void' => [],
+ 'cust_pkg' => [],
+ #'cust_pkg_reason' => [],
+ 'cust_pkg_discount' => [],
+ 'cust_refund' => [],
+ 'banned_pay' => [],
+
+ #default namespace
+ 'payment_gateway' => [],
+
+ #migrate to templates
+ 'msg_template' => [],
+
+ #return unprovisioned numbers to availability
+ 'phone_avail' => [],
+
+ #insert scripcondition
+ 'TicketSystem' => [],
+
+ #insert LATA data if not already present
+ 'lata' => [],
+
+ #insert MSA data if not already present
+ 'msa' => [],
+
+ # migrate to radius_group and groupnum instead of groupname
+ 'radius_usergroup' => [],
+ 'part_svc' => [],
+ 'part_export' => [],
+
+ #insert default tower_sector if not present
+ 'tower' => [],
+
+ #routernum/blocknum
+ 'svc_broadband' => [],
+
+ #set up payment gateways if needed
+ 'pay_batch' => [],
+
+ #flag monthly tax exemptions
+ 'cust_tax_exempt_pkg' => [],
+
+ #kick off tax location history upgrade
+ 'cust_bill_pkg' => [],
+ ;
+
+ \%hash;
+
+}
+
+=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' => [],
+ #add necessary columns to RT schema
+ 'TicketSystem' => [],
+