slight update for batch-enable description & add ach-spiritone format to batch-defaul...
[freeside.git] / FS / bin / freeside-upgrade
index 3a4e4f8..04e5da9 100755 (executable)
@@ -8,6 +8,7 @@ use DBIx::DBSchema 0.31;
 use FS::UID qw(adminsuidsetup checkeuid datasrc );  #getsecrets);
 use FS::CurrentUser;
 use FS::Schema qw( dbdef dbdef_dist reload_dbdef );
+use FS::Misc::prune qw(prune_applications);
 
 die "Not running uid freeside!" unless checkeuid();
 
@@ -20,7 +21,9 @@ $DRY_RUN = $opt_d;
 
 my $user = shift or die &usage;
 $FS::CurrentUser::upgrade_hack = 1;
+$FS::UID::callback_hack = 1;
 my $dbh = adminsuidsetup($user);
+$FS::UID::callback_hack = 0;
 
 #needs to match FS::Schema...
 my $dbdef_file = "%%%FREESIDE_CONF%%%/dbdef.". datasrc;
@@ -40,12 +43,25 @@ if ( $DRY_RUN ) {
   dbdef->update_schema( dbdef_dist, $dbh );
 }
 
+my $hashref = {};
+$hashref->{dry_run} = 1 if $DRY_RUN;
+$hashref->{debug} = 1 if $DEBUG;
+print join "\n", prune_applications($hashref);
+print "\n" if $DRY_RUN;
+
+
 $dbh->commit or die $dbh->errstr;
 
 dbdef_create($dbh, $dbdef_file);
 
 $dbh->disconnect or die $dbh->errstr;
 
+unless ( $DRY_RUN ) {
+  my $init_config = "freeside-init-config -u $user ";
+  $init_config .= "%%%FREESIDE_CONF%%%/conf.". datasrc;
+  system "$init_config" ;
+}
+
 ###
 
 sub dbdef_create { # reverse engineer the schema from the DB and save to file
@@ -64,7 +80,7 @@ freeside-upgrade - Upgrades database schema for new freeside verisons.
 
 =head1 SYNOPSIS
 
-  freeside-adduser [ -d ] [ -q | -v ]
+  freeside-upgrade [ -d ] [ -q | -v ]
 
 =head1 DESCRIPTION