[Jifty-commit] r4629 - in jifty/trunk: lib/Jifty lib/Jifty/Script
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Thu Dec 6 14:06:51 EST 2007
Author: alexmv
Date: Thu Dec 6 14:06:50 2007
New Revision: 4629
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Handle.pm
jifty/trunk/lib/Jifty/Script/Schema.pm
Log:
r25492 at zoq-fot-pik: chmrr | 2007-12-06 13:43:07 -0500
* Perltidy
Modified: jifty/trunk/lib/Jifty/Handle.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Handle.pm (original)
+++ jifty/trunk/lib/Jifty/Handle.pm Thu Dec 6 14:06:50 2007
@@ -32,20 +32,20 @@
my $class = shift;
my $driver = Jifty->config->framework('Database')->{'Driver'};
- if ($driver eq 'Oracle') {
- $ENV{'NLS_LANG'} = "AMERICAN_AMERICA.AL32UTF8";
+ if ( $driver eq 'Oracle' ) {
+ $ENV{'NLS_LANG'} = "AMERICAN_AMERICA.AL32UTF8";
$ENV{'NLS_NCHAR'} = "AL32UTF8";
}
-
+
# We do this to avoid Jifty::DBI::Handle's magic reblessing, because
# it breaks subclass methods.
- my $driver_class = "Jifty::DBI::Handle::". $driver;
+ my $driver_class = "Jifty::DBI::Handle::" . $driver;
Jifty::Util->require($driver_class);
die "No such handle class as $driver_class. ",
"Check your spelling and check that your Jifty installation and ",
- "related modules (especially Jifty::DBI) are up to date."
- unless $driver_class->can('isa');
+ "related modules (especially Jifty::DBI) are up to date."
+ unless $driver_class->can('isa');
unshift @ISA, $driver_class;
return $class->SUPER::new();
@@ -64,18 +64,18 @@
sub canonical_database_name {
my $self_or_class = shift;
- my $db_config = Jifty->config->framework('Database');
+ my $db_config = Jifty->config->framework('Database');
# XXX TODO consider canonicalizing to all-lowercase, once there are no
# legacy databases
my $db = $db_config->{'Database'};
- if ($db_config->{'Driver'} =~ /SQLite/) {
+ if ( $db_config->{'Driver'} =~ /SQLite/ ) {
$db = Jifty::Util->absolute_path($db);
- }
+ }
return $db;
-}
+}
=head2 connect ARGS
@@ -85,27 +85,36 @@
=cut
sub connect {
- my $self = shift;
- my %args = (@_);
- my %db_config = (%{Jifty->config->framework('Database')}, Database => $self->canonical_database_name);
+ my $self = shift;
+ my %args = (@_);
+ my %db_config = (
+ %{ Jifty->config->framework('Database') },
+ Database => $self->canonical_database_name
+ );
my %lc_db_config;
+
# Skip the non-dsn keys, but not anything else
- for (grep {!/^autoupgrade|checkschema|version|forwardcompatible|recordbaseclass|attributes$/i} keys %db_config) {
- $lc_db_config{lc($_)} = $db_config{$_};
+ for (
+ grep {
+ !/^autoupgrade|checkschema|version|forwardcompatible|recordbaseclass|attributes$/i
+ } keys %db_config
+ )
+ {
+ $lc_db_config{ lc($_) } = $db_config{$_};
}
- $self->SUPER::connect( %lc_db_config , %args);
- $self->{db_config} = { %lc_db_config , %args };
- $self->dbh->{LongReadLen} = Jifty->config->framework('MaxAttachmentSize') || '10000000';
+ $self->SUPER::connect( %lc_db_config, %args );
+ $self->{db_config} = { %lc_db_config, %args };
+ $self->dbh->{LongReadLen} = Jifty->config->framework('MaxAttachmentSize')
+ || '10000000';
# setup attributes
my $attributes = Jifty->config->framework('Database')->{Attributes} || {};
- for (keys %$attributes) {
- $self->dbh->{lc($_)} = $attributes->{$_};
+ for ( keys %$attributes ) {
+ $self->dbh->{ lc($_) } = $attributes->{$_};
}
}
-
=head2 check_schema_version
Make sure that we have a recent enough database schema. If we don't,
@@ -116,7 +125,7 @@
sub check_schema_version {
my $self = shift;
require Jifty::Model::Metadata;
- my $autoup = delete Jifty->config->framework('Database')->{'AutoUpgrade'};
+ my $autoup = delete Jifty->config->framework('Database')->{'AutoUpgrade'};
# Application db version check
{
@@ -124,7 +133,8 @@
my $appv = Jifty->config->framework('Database')->{'Version'};
if ( not defined $dbv ) {
- # First layer of backwards compatibility -- it used to be in _db_version
+
+ # First layer of backwards compatibility -- it used to be in _db_version
my @v;
eval {
local $SIG{__WARN__} = sub { };
@@ -134,11 +144,14 @@
$dbv = join( ".", @v ) if @v == 3;
}
if ( not defined $dbv ) {
+
# It was also called the 'key' column, not the data_key column
eval {
local $SIG{__WARN__} = sub { };
- $dbv = Jifty->handle->fetch_result(
- "SELECT value FROM _jifty_metadata WHERE key = 'application_db_version'");
+ $dbv
+ = Jifty->handle->fetch_result(
+ "SELECT value FROM _jifty_metadata WHERE key = 'application_db_version'"
+ );
} or undef($dbv);
}
@@ -147,18 +160,24 @@
. "\t bin/jifty schema --setup\n"
unless defined $dbv;
- unless (version->new($appv) == version->new($dbv)) {
- # if app version is older than db version, but we are still compatible
- my $compat = delete Jifty->config->framework('Database')->{'ForwardCompatible'} || $appv;
- if (version->new($appv) > version->new($dbv) || version->new($compat) < version->new($dbv)) {
- warn "Application schema version in database ($dbv) doesn't match application schema version ($appv)\n";
- if( $autoup
- ) {
- warn "Automatically upgrading your database to match the current application schema";
- $self->_upgrade_schema();
- } else {
- die "Please run `bin/jifty schema --setup` to upgrade the database.\n";
- }
+ unless ( version->new($appv) == version->new($dbv) ) {
+
+ # if app version is older than db version, but we are still compatible
+ my $compat = delete Jifty->config->framework('Database')
+ ->{'ForwardCompatible'} || $appv;
+ if ( version->new($appv) > version->new($dbv)
+ || version->new($compat) < version->new($dbv) )
+ {
+ warn
+ "Application schema version in database ($dbv) doesn't match application schema version ($appv)\n";
+ if ( $autoup ) {
+ warn
+ "Automatically upgrading your database to match the current application schema";
+ $self->_upgrade_schema();
+ } else {
+ die
+ "Please run `bin/jifty schema --setup` to upgrade the database.\n";
+ }
}
}
}
@@ -173,20 +192,22 @@
= version->new( Jifty::Model::Metadata->load("jifty_db_version")
|| '0.60426' );
my $appv = version->new($Jifty::VERSION);
- unless ( $appv == $dbv ) {
- warn "Internal jifty schema version in database ($dbv) doesn't match running jifty version ($appv)\n";
- if( $autoup) {
- warn "Automatically upgrading your database to match the current Jifty schema\n";
+ unless ( $appv == $dbv ) {
+ warn
+ "Internal jifty schema version in database ($dbv) doesn't match running jifty version ($appv)\n";
+ if ($autoup) {
+ warn
+ "Automatically upgrading your database to match the current Jifty schema\n";
$self->_upgrade_schema;
} else {
- die "Please run `bin/jifty schema --setup` to upgrade the database.\n"
+ die
+ "Please run `bin/jifty schema --setup` to upgrade the database.\n";
}
- };
+ }
}
}
-
=head2 create_database MODE
C<MODE> is either "print" or "execute".
@@ -197,13 +218,13 @@
=cut
sub create_database {
- my $self = shift;
- my $mode = shift || 'execute';
+ my $self = shift;
+ my $mode = shift || 'execute';
my $database = $self->canonical_database_name;
my $driver = Jifty->config->framework('Database')->{'Driver'};
- my $query = "CREATE DATABASE $database";
+ my $query = "CREATE DATABASE $database";
$query .= " TEMPLATE template0" if $driver =~ /Pg/;
- if ( $mode eq 'print') {
+ if ( $mode eq 'print' ) {
print "$query;\n";
} elsif ( $driver !~ /SQLite/ ) {
$self->simple_query($query);
@@ -220,8 +241,8 @@
=cut
sub drop_database {
- my $self = shift;
- my $mode = shift || 'execute';
+ my $self = shift;
+ my $mode = shift || 'execute';
my $database = $self->canonical_database_name;
my $driver = Jifty->config->framework('Database')->{'Driver'};
if ( $mode eq 'print' ) {
@@ -232,8 +253,8 @@
$self->disconnect if $^O eq 'MSWin32';
unlink($database);
} else {
- local $SIG{__WARN__} =
- sub { warn $_[0] unless $_[0] =~ /exist|couldn't execute/i };
+ local $SIG{__WARN__}
+ = sub { warn $_[0] unless $_[0] =~ /exist|couldn't execute/i };
$self->simple_query("DROP DATABASE $database");
}
}
Modified: jifty/trunk/lib/Jifty/Script/Schema.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Script/Schema.pm (original)
+++ jifty/trunk/lib/Jifty/Script/Schema.pm Thu Dec 6 14:06:50 2007
@@ -54,7 +54,6 @@
}
}
-
=head2 run_upgrades
Take the actions we need in order to bring an existing database up to current.
@@ -63,13 +62,12 @@
sub run_upgrades {
my $self = shift;
- $self->upgrade_jifty_tables();
- $self->upgrade_application_tables();
- $self->upgrade_plugin_tables();
+ $self->upgrade_jifty_tables();
+ $self->upgrade_application_tables();
+ $self->upgrade_plugin_tables();
}
-
=head2 setup_environment
Sets up a minimal Jifty environment.
@@ -82,7 +80,8 @@
# Import Jifty
Jifty::Util->require("Jifty");
Jifty::Util->require("Jifty::Model::Metadata");
- Jifty->new( no_handle => 1, logger_component => 'SchemaTool',) unless Jifty->class_loader;
+ Jifty->new( no_handle => 1, logger_component => 'SchemaTool', )
+ unless Jifty->class_loader;
}
=head2 schema
@@ -98,7 +97,6 @@
return $self->{'SCHEMA'};
}
-
=head2 print_help
Prints out help for the package using pod2usage.
@@ -126,7 +124,7 @@
=cut
sub probe_database_existence {
- my $self = shift;
+ my $self = shift;
my $no_handle = 0;
if ( $self->{'create_database'} or $self->{'drop_database'} ) {
$no_handle = 1;
@@ -134,7 +132,10 @@
# Now try to connect. We trap expected errors and deal with them.
eval {
- Jifty->setup_database_connection( no_handle => $no_handle, logger_component => 'SchemaTool',);
+ Jifty->setup_database_connection(
+ no_handle => $no_handle,
+ logger_component => 'SchemaTool',
+ );
};
if ( $@ =~ /doesn't match (application schema|running jifty) version/i ) {
@@ -146,7 +147,8 @@
# No version table. Assume the DB is empty.
$self->{create_all_tables} = 1;
} elsif ( $@ =~ /database .*? does not exist/i
- or $@ =~ /unknown database/i ) {
+ or $@ =~ /unknown database/i )
+ {
# No database exists; we'll need to make one and fill it up
$self->{create_database} = 1;
@@ -182,22 +184,25 @@
my $log = Log::Log4perl->get_logger("SchemaTool");
$log->info("Generating SQL for application @{[Jifty->app_class]}...");
- my $appv = version->new( Jifty->config->framework('Database')->{'Version'} );
- my $jiftyv = version->new( $Jifty::VERSION );
+ my $appv
+ = version->new( Jifty->config->framework('Database')->{'Version'} );
+ my $jiftyv = version->new($Jifty::VERSION);
# Start a transaction
Jifty->handle->begin_transaction;
- $self->create_tables_for_models (grep {$_->isa('Jifty::DBI::Record')} $self->schema->models );
+ $self->create_tables_for_models( grep { $_->isa('Jifty::DBI::Record') }
+ $self->schema->models );
# Update the versions in the database
Jifty::Model::Metadata->store( application_db_version => $appv );
Jifty::Model::Metadata->store( jifty_db_version => $jiftyv );
# For each plugin, update the plugin version
- for my $plugin (Jifty->plugins) {
+ for my $plugin ( Jifty->plugins ) {
my $pluginv = version->new( $plugin->version );
- Jifty::Model::Metadata->store( (ref $plugin).'_db_version' => $pluginv );
+ Jifty::Model::Metadata->store(
+ ( ref $plugin ) . '_db_version' => $pluginv );
}
# Load initial data
@@ -206,7 +211,7 @@
Jifty::Util->require($bootstrapper);
$bootstrapper->run() if $bootstrapper->can('run');
- for my $plugin (Jifty->plugins) {
+ for my $plugin ( Jifty->plugins ) {
my $plugin_bootstrapper = $plugin->bootstrapper;
Jifty::Util->require($plugin_bootstrapper);
$plugin_bootstrapper->run() if $plugin_bootstrapper->can('run');
@@ -236,44 +241,46 @@
=cut
sub create_tables_for_models {
- my $self = shift;
+ my $self = shift;
my @models = (@_);
my $log = Log::Log4perl->get_logger("SchemaTool");
- my $appv = version->new( Jifty->config->framework('Database')->{'Version'} );
- my $jiftyv = version->new( $Jifty::VERSION );
+ my $appv
+ = version->new( Jifty->config->framework('Database')->{'Version'} );
+ my $jiftyv = version->new($Jifty::VERSION);
my %pluginvs;
- for my $plugin (Jifty->plugins) {
+ for my $plugin ( Jifty->plugins ) {
my $plugin_class = ref $plugin;
- $pluginvs{ $plugin_class } = version->new( $plugin->version );
+ $pluginvs{$plugin_class} = version->new( $plugin->version );
}
- MODEL:
- for my $model ( @models) {
- # Skip autogenerated models; that is, those that are overridden by plugins.
+MODEL:
+ for my $model (@models) {
+
+ # Skip autogenerated models; that is, those that are overridden by plugins.
next MODEL if Jifty::ClassLoader->autogenerated($model);
- my $plugin_root = Jifty->app_class('Plugin').'::';
+ my $plugin_root = Jifty->app_class('Plugin') . '::';
- # TODO XXX FIXME:
- # This *will* try to generate SQL for abstract base classes you might
- # stick in $AC::Model::.
- if ($model->can('since')) {
- my $app_class = Jifty->app_class;
+ # TODO XXX FIXME:
+ # This *will* try to generate SQL for abstract base classes you might
+ # stick in $AC::Model::.
+ if ( $model->can('since') ) {
+ my $app_class = Jifty->app_class;
my $installed_version = 0;
# Is it a Jifty core model?
- if ($model =~ /^Jifty::Model::/) {
+ if ( $model =~ /^Jifty::Model::/ ) {
$installed_version = $jiftyv;
}
# Is it a Jifty or application plugin model?
- elsif ($model =~ /^(?:Jifty::Plugin::|$plugin_root)/) {
+ elsif ( $model =~ /^(?:Jifty::Plugin::|$plugin_root)/ ) {
my $plugin_class = $model;
$plugin_class =~ s/::Model::(.*)$//;
- $installed_version = $pluginvs{ $plugin_class };
+ $installed_version = $pluginvs{$plugin_class};
}
# Otherwise, an application model
@@ -281,21 +288,25 @@
$installed_version = $appv;
}
- if ($installed_version < $model->since) {
- # XXX Is this message correct?
- $log->info("Skipping $model, as it should already be in the database");
+ if ( $installed_version < $model->since ) {
+
+ # XXX Is this message correct?
+ $log->info(
+ "Skipping $model, as it should already be in the database"
+ );
next MODEL;
}
}
- if ($model =~ /^(?:Jifty::Plugin::|$plugin_root)/
- and $model =~ /::Model::(.*)$/) {
+ if ( $model =~ /^(?:Jifty::Plugin::|$plugin_root)/
+ and $model =~ /::Model::(.*)$/ )
+ {
my $model_name = $1;
# Check to make sure this model is not overridden in the app,
# in such cases we don't want to try to create the same table
# twice, so let the app model do it rather than the plugin
- my $app_model = Jifty->app_class("Model",$model_name);
+ my $app_model = Jifty->app_class( "Model", $model_name );
$app_model->require;
next MODEL unless Jifty::ClassLoader->autogenerated($app_model);
}
@@ -303,8 +314,8 @@
$log->info("Using $model, as it appears to be new.");
$self->schema->_check_reserved($model)
- unless ( $self->{'ignore_reserved'}
- or !Jifty->config->framework('Database')->{'CheckSchema'} );
+ unless ( $self->{'ignore_reserved'}
+ or !Jifty->config->framework('Database')->{'CheckSchema'} );
if ( $self->{'print'} ) {
print $model->printable_table_schema;
@@ -324,17 +335,25 @@
my $self = shift;
my $dbv = Jifty::Model::Metadata->load('jifty_db_version');
unless ($dbv) {
+
# Backwards combatibility -- it usd to be 'key' not 'data_key';
eval {
local $SIG{__WARN__} = sub { };
- $dbv = Jifty->handle->fetch_result( "SELECT value FROM _jifty_metadata WHERE key = 'jifty_db_version'");
+ $dbv
+ = Jifty->handle->fetch_result(
+ "SELECT value FROM _jifty_metadata WHERE key = 'jifty_db_version'"
+ );
};
}
- $dbv = version->new($dbv || '0.60426');
+ $dbv = version->new( $dbv || '0.60426' );
my $appv = version->new($Jifty::VERSION);
- return unless $self->upgrade_tables( "Jifty" => $dbv, $appv, "Jifty::Upgrade::Internal");
+ return
+ unless $self->upgrade_tables(
+ "Jifty" => $dbv,
+ $appv, "Jifty::Upgrade::Internal"
+ );
if ( $self->{print} ) {
warn "Need to upgrade jifty_db_version to $appv here!";
} else {
@@ -350,8 +369,10 @@
sub upgrade_application_tables {
my $self = shift;
- my $dbv = version->new( Jifty::Model::Metadata->load('application_db_version') );
- my $appv = version->new( Jifty->config->framework('Database')->{'Version'} );
+ my $dbv = version->new(
+ Jifty::Model::Metadata->load('application_db_version') );
+ my $appv
+ = version->new( Jifty->config->framework('Database')->{'Version'} );
return unless $self->upgrade_tables( Jifty->app_class, $dbv, $appv );
if ( $self->{print} ) {
@@ -368,23 +389,28 @@
=cut
sub upgrade_plugin_tables {
- my $self = shift;
+ my $self = shift;
- for my $plugin (Jifty->plugins) {
+ for my $plugin ( Jifty->plugins ) {
my $plugin_class = ref $plugin;
- my $dbv = Jifty::Model::Metadata->load($plugin_class . '_db_version');
+ my $dbv
+ = Jifty::Model::Metadata->load( $plugin_class . '_db_version' );
my $appv = version->new( $plugin->version );
# Upgrade this plugin from dbv -> appv
- if (defined $dbv) {
- $dbv = version->new( $dbv );
+ if ( defined $dbv ) {
+ $dbv = version->new($dbv);
- next unless $self->upgrade_tables( $plugin_class, $dbv, $appv, $plugin->upgrade_class );
+ next
+ unless $self->upgrade_tables( $plugin_class, $dbv, $appv,
+ $plugin->upgrade_class );
if ( $self->{print} ) {
- warn "Need to upgrade ${plugin_class}_db_version to $appv here!";
+ warn
+ "Need to upgrade ${plugin_class}_db_version to $appv here!";
} else {
- Jifty::Model::Metadata->store( $plugin_class . '_db_version' => $appv );
+ Jifty::Model::Metadata->store(
+ $plugin_class . '_db_version' => $appv );
}
}
@@ -396,15 +422,19 @@
# Create the tables
$self->create_tables_for_models(
- grep { $_->isa('Jifty::DBI::Record') and /^\Q$plugin_class\E::Model::/ }
- $self->schema->models);
-
+ grep {
+ $_->isa('Jifty::DBI::Record')
+ and /^\Q$plugin_class\E::Model::/
+ } $self->schema->models
+ );
+
# Save the plugin version to the database
- Jifty::Model::Metadata->store( $plugin_class . '_db_version' => $appv )
+ Jifty::Model::Metadata->store(
+ $plugin_class . '_db_version' => $appv )
unless $self->{print};
# Run the bootstrapper for initial data
- unless ($self->{print}) {
+ unless ( $self->{print} ) {
eval {
my $bootstrapper = $plugin->bootstrapper;
Jifty::Util->require($bootstrapper);
@@ -412,7 +442,7 @@
};
die $@ if $@;
}
-
+
# Save them records
Jifty->handle->commit;
$log->info("Set up $plugin_class version $appv");
@@ -438,14 +468,16 @@
# Find current versions
if ( $appv < $dbv ) {
- print "$baseclass version $appv from module older than $dbv in database!\n";
+ print
+ "$baseclass version $appv from module older than $dbv in database!\n";
return;
} elsif ( $appv == $dbv ) {
+
# Shouldn't happen
print "$baseclass version $appv up to date.\n";
return;
}
- $log->info( "Generating SQL to upgrade $baseclass $dbv database to $appv" );
+ $log->info("Generating SQL to upgrade $baseclass $dbv database to $appv");
# Figure out what versions the upgrade knows about.
Jifty::Util->require($upgradeclass) or return;
@@ -453,10 +485,12 @@
eval {
$UPGRADES{$_} = [ $upgradeclass->upgrade_to($_) ]
for grep { $appv >= version->new($_) and $dbv < version->new($_) }
- $upgradeclass->versions();
+ $upgradeclass->versions();
};
- for my $model_class ( grep {/^\Q$baseclass\E::Model::/} $self->schema->models ) {
+ for my $model_class ( grep {/^\Q$baseclass\E::Model::/}
+ $self->schema->models )
+ {
# We don't want to get the Collections, for example.
next unless $model_class->isa('Jifty::DBI::Record');
@@ -465,19 +499,32 @@
my $model = $model_class->new;
# If this whole table is new Create it
- if ($model->can( 'since' ) and defined $model->since and $appv >= $model->since and $model->since >$dbv ) {
- unshift @{ $UPGRADES{ $model->since } }, $model->printable_table_schema();
+ if ( $model->can('since')
+ and defined $model->since
+ and $appv >= $model->since
+ and $model->since > $dbv )
+ {
+ unshift @{ $UPGRADES{ $model->since } },
+ $model->printable_table_schema();
} else {
+
# Go through the currently-active columns
- for my $col (grep {not $_->virtual} $model->columns ) {
+ for my $col ( grep { not $_->virtual } $model->columns ) {
+
# If they're new, add them
- if ($col->can( 'since' ) and defined $col->since and $appv >= $col->since and $col->since >$dbv ) {
+ if ( $col->can('since')
+ and defined $col->since
+ and $appv >= $col->since
+ and $col->since > $dbv )
+ {
unshift @{ $UPGRADES{ $col->since } }, sub {
my $renamed = $upgradeclass->just_renamed || {};
# skip it if this was added by a rename
- $model->add_column_in_db($col->name)
- unless defined $renamed->{ $model->table }->{'add'}->{ $col->name };
+ $model->add_column_in_db( $col->name )
+ unless
+ defined $renamed->{ $model->table }->{'add'}
+ ->{ $col->name };
};
}
}
@@ -488,23 +535,23 @@
$self->_print_upgrades(%UPGRADES);
} else {
- eval {
+ eval {
$self->_execute_upgrades(%UPGRADES);
$log->info("Upgraded to version $appv");
- };
+ };
die $@ if $@;
}
return 1;
}
-
-
sub _execute_upgrades {
my $self = shift;
my %UPGRADES = (@_);
Jifty->handle->begin_transaction;
my $log = Log::Log4perl->get_logger("SchemaTool");
- for my $version ( sort { version->new($a) <=> version->new($b) } keys %UPGRADES) {
+ for my $version ( sort { version->new($a) <=> version->new($b) }
+ keys %UPGRADES )
+ {
$log->info("Upgrading through $version");
for my $thing ( @{ $UPGRADES{$version} } ) {
if ( ref $thing ) {
@@ -525,7 +572,8 @@
map { @{ $UPGRADES{$_} } }
sort { version->new($a) <=> version->new($b) }
keys %UPGRADES
- ) {
+ )
+ {
if ( ref $_ ) {
print "-- Upgrade subroutine:\n";
require Data::Dumper;
@@ -553,13 +601,13 @@
my $handle = Jifty::Schema->connect_to_db_for_management();
if ( $self->{print} ) {
- $handle->drop_database('print') if ( $self->{'drop_database'} ) ;
- $handle->create_database('print') if ( $self->{'create_database'} ) ;
+ $handle->drop_database('print') if ( $self->{'drop_database'} );
+ $handle->create_database('print') if ( $self->{'create_database'} );
} else {
- $handle->drop_database('execute') if ( $self->{'drop_database'} ) ;
- $handle->create_database('execute') if ( $self->{'create_database'} ) ;
+ $handle->drop_database('execute') if ( $self->{'drop_database'} );
+ $handle->create_database('execute') if ( $self->{'create_database'} );
$handle->disconnect;
- $self->_reinit_handle() if ($self->{'create_database'} ) ;
+ $self->_reinit_handle() if ( $self->{'create_database'} );
}
}
@@ -568,14 +616,12 @@
Jifty->handle->connect();
}
-
sub _exec_sql {
my $sql = shift;
my $ret = Jifty->handle->simple_query($sql);
$ret or die "error updating a table: " . $ret->error_message;
}
-
1;
__DATA__
More information about the Jifty-commit
mailing list