App-LedgerSMB-Admin
view release on metacpan or search on metacpan
lib/App/LedgerSMB/Admin/Database.pm view on Meta::CPAN
package App::LedgerSMB::Admin::Database;
use Moo;
extends 'PGObject::Util::DBAdmin';
use File::Temp;
use Cwd;
use PGObject::Util::DBChange;
use App::LedgerSMB::Admin;
use App::LedgerSMB::Admin::Database::Setting;
=head1 NAME
App::LedgerSMB::Admin::Database - Administer LedgerSMB Databases
=head1 SYNOPSIS
Upgrading to 1.4 from 1.3, after updating 1.3 instance to latest:
use App::LedgerSMB::Admin;
use App::LedgerSMB::Admin::Database;
App::LedgerSMB::Admin->add_paths(
'1.3' => '/usr/local/ledgersmb_1.3',
'1.4' => '/usr/local/ledgersmb_1.4',
); # setting the version paths
my $db = App::LedgerSMB::Admin::Database->new(
username => 'postgres',
password => 'secretpassword',
host => 'localhost',
port => '5432',
dbname => 'mycompany',
);
if ($db->major_version eq '1.3') {
$db->reload;
$db->upgrade_to('1.4');
}
=head1 VERSION
0.04
=cut
our $VERSION=0.04;
=head1 PROPERTIES INHERITED FROM PGObject::Util::DBAdmin
Please see the docs for PGObject::Util::DBAdmin.
=head2 username
=head2 password
=head2 host
=head2 port
=head2 dbname
=head1 ADDITIONAL PROPERTIES
=head2 version
Returns the version number of the database.
=cut
has version => (is => 'lazy');
sub _build_version {
my $self = shift;
return App::LedgerSMB::Admin::Database::Setting->new(
database => $self,
setting_key => 'version')->value;
}
=head2 major_version
Major versions are generally understood to be not backwards compatible. In
LedgerSMB, as with PostgreSQL, major versions are based on the second numbers
in the version, so 1.2, 1.3, and 1.4 are major versions.
=cut
has major_version => (is => 'lazy');
sub _build_major_version {
my $self = shift;
my $version = $self->version;
$version =~ s/\.\d*(?:-dev)?$//;
return $version;
}
=head1 METHODS INHERITED
Please see the docs for PGObject::Util::DBAdmin
=head2 create
=head2 connect
=head2 drop
=head2 run_file
=head2 backup
=head2 restore_backup
=head1 NEW METHODS
=head2 stats
( run in 0.813 second using v1.01-cache-2.11-cpan-75ffa21a3d4 )