add queue-no_history config option, RT#20345
authorIvan Kohler <ivan@freeside.biz>
Tue, 10 Sep 2013 22:21:34 +0000 (15:21 -0700)
committerIvan Kohler <ivan@freeside.biz>
Tue, 10 Sep 2013 22:21:34 +0000 (15:21 -0700)
FS/FS/Conf.pm
FS/FS/Schema.pm
FS/bin/freeside-upgrade

index d8c2317..d63c12f 100644 (file)
@@ -4896,6 +4896,13 @@ and customer address. Include units.',
   },
 
   {
+    'key'         => 'queue-no_history',
+    'section'     => '',
+    'description' => "Don't recreate the h_queue and h_queue_arg tables on upgrades.  This can save disk space for large installs, especially when using prepaid or multi-process billing.  After turning this option on, drop the h_queue and h_queue_arg tables, run freeside-dbdef-create and restart Apache and Freeside.",
+    'type'        => 'checkbox',
+  },
+
+  {
     'key'         => 'cancelled_cust-noevents',
     'section'     => 'billing',
     'description' => "Don't run events for cancelled customers",
index 95b2cc5..45c0b7a 100644 (file)
@@ -7,6 +7,7 @@ use DBIx::DBSchema 0.40; #0.40 for mysql upgrade fixes
 use DBIx::DBSchema::Table;
 use DBIx::DBSchema::Column;
 use DBIx::DBSchema::Index;
+#can't use this yet, dependency bs #use FS::Conf;
 
 @ISA = qw(Exporter);
 @EXPORT_OK = qw( dbdef dbdef_dist reload_dbdef );
@@ -75,7 +76,8 @@ Currently, this enables "ENGINE=InnoDB" for MySQL databases.
 =cut
 
 sub dbdef_dist {
-  my $datasrc = @_ ? shift : '';
+  my $datasrc = @_ && !ref($_[0]) ? shift : '';
+  my $opt = @_ ? shift : {};
   
   my $local_options = '';
   if ( $datasrc =~ /^dbi:mysql/i ) {
@@ -192,6 +194,7 @@ sub dbdef_dist {
     grep {    ! /^(clientapi|access_user)_session/
            && ! /^h_/
            && ! /^log(_context)?$/
+           && ( ! /^queue(_arg)?$/ || ! $opt->{'queue-no_history'} )
            && ! $tables_hashref_torrus->{$_}
          }
       $dbdef->tables
index 5bd1415..06ec962 100755 (executable)
@@ -107,7 +107,14 @@ if ( $DRY_RUN ) {
 #from 1.3 to 1.4... if not, it needs to be hooked into -upgrade here or
 #you'll lose all the part_svc settings it migrates to part_svc_column
 
-my @statements = dbdef->sql_update_schema( dbdef_dist(datasrc),
+my $conf = new FS::Conf;
+
+my $dbdef_dist = dbdef_dist(
+  datasrc,
+  { 'queue-no_history' => $conf->exists('queue-no_history') },
+);
+
+my @statements = dbdef->sql_update_schema( $dbdef_dist,
                                            $dbh,
                                            { 'nullify_default' => 1, },
                                          );