From 42cb05f8b363d8f56ff620256adcaf1a4f15046f Mon Sep 17 00:00:00 2001 From: Ivan Kohler Date: Tue, 10 Sep 2013 15:21:34 -0700 Subject: [PATCH] add queue-no_history config option, RT#20345 --- FS/FS/Conf.pm | 7 +++++++ FS/FS/Schema.pm | 5 ++++- FS/bin/freeside-upgrade | 9 ++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/FS/FS/Conf.pm b/FS/FS/Conf.pm index d8c2317b6..d63c12fa8 100644 --- a/FS/FS/Conf.pm +++ b/FS/FS/Conf.pm @@ -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", diff --git a/FS/FS/Schema.pm b/FS/FS/Schema.pm index 95b2cc56f..45c0b7ae1 100644 --- a/FS/FS/Schema.pm +++ b/FS/FS/Schema.pm @@ -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 diff --git a/FS/bin/freeside-upgrade b/FS/bin/freeside-upgrade index 5bd141538..06ec96205 100755 --- a/FS/bin/freeside-upgrade +++ b/FS/bin/freeside-upgrade @@ -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, }, ); -- 2.11.0