[Rt-commit] rt branch 5.0/cli-skip-db-config created. rt-5.0.3-23-gbd0cd7765e
BPS Git Server
git at git.bestpractical.com
Mon Jul 25 20:59:26 UTC 2022
This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "rt".
The branch, 5.0/cli-skip-db-config has been created
at bd0cd7765ebd43ce3f2657674552d0faabbbb5a7 (commit)
- Log -----------------------------------------------------------------
commit bd0cd7765ebd43ce3f2657674552d0faabbbb5a7
Author: Jim Brandt <jbrandt at bestpractical.com>
Date: Mon Jul 25 16:42:19 2022 -0400
Add an option to run CLI utilities without DB configuration
The Configurations table was added in RT 5, so running RT 5
scripts against an older database, possibly during an upgrade,
results in errors. Provide a way to skip loading DB config
when running some CLI scripts.
diff --git a/etc/upgrade/reset-sequences.in b/etc/upgrade/reset-sequences.in
index a33596fc3e..28897101d5 100644
--- a/etc/upgrade/reset-sequences.in
+++ b/etc/upgrade/reset-sequences.in
@@ -59,14 +59,10 @@ use Getopt::Long;
$| = 1; # unbuffer all output.
my %args;
-GetOptions(
- \%args,
- 'dba=s', 'dba-password=s', 'prompt-for-dba-password',
-);
no warnings 'once';
use RT::Interface::CLI qw(Init);
-Init();
+Init(\%args, 'dba=s', 'dba-password=s', 'prompt-for-dba-password', 'no-db-config');
my $db_type = RT->Config->Get('DatabaseType') || '';
my $db_host = RT->Config->Get('DatabaseHost') || '';
diff --git a/lib/RT/Interface/CLI.pm b/lib/RT/Interface/CLI.pm
index 57cac5d9c1..0fab110f72 100644
--- a/lib/RT/Interface/CLI.pm
+++ b/lib/RT/Interface/CLI.pm
@@ -175,6 +175,10 @@ It accepts log levels like C<$StatementLog>:
--statement-log=debug
+C<--no-db-config> skips loading configuration from the database.
+The Configurations table was added in RT 5 and this option allows
+you to run some CLI utilities against older RT databases.
+
=cut
sub Init {
@@ -218,6 +222,9 @@ sub Init {
push @args, "statement-log=s" => \($hash->{'statement-log'})
unless $exists{'statement-log'};
+ push @args, "no-db-config" => \($hash->{'no-db-config'})
+ unless $exists{'no-db-config'};
+
my $ok = Getopt::Long::GetOptions( @args );
Pod::Usage::pod2usage(1) if not $ok and not defined wantarray;
@@ -241,7 +248,7 @@ sub Init {
}
RT->Config->Set( 'StatementLog', $hash->{'statement-log'} ) if defined $hash->{'statement-log'};
- RT::Init();
+ RT::Init( SkipConfigurations => $hash->{'no-db-config'} );
$RT::Handle->LogSQLStatements(1) if RT->Config->Get('StatementLog');
$| = 1;
-----------------------------------------------------------------------
hooks/post-receive
--
rt
More information about the rt-commit
mailing list