[Jifty-commit] jifty branch, setupwizard-refactor, updated. 2f82163e784e9d3171d33499d1b52ac5c4b307ea
Jifty commits
jifty-commit at lists.jifty.org
Thu Jul 8 11:18:20 EDT 2010
The branch, setupwizard-refactor has been updated
via 2f82163e784e9d3171d33499d1b52ac5c4b307ea (commit)
via 0a25ab89af2a10563ebc6fddbc08cb7f86f92ec0 (commit)
from ae6b0474bb9d6b05d96d508d733820523d90785b (commit)
Summary of changes:
lib/Jifty/Handle.pm | 4 +++
lib/Jifty/Schema.pm | 47 ++++++++++++++++++++++++++++++++++++++++++-
lib/Jifty/Script/Schema.pm | 7 +----
3 files changed, 51 insertions(+), 7 deletions(-)
- Log -----------------------------------------------------------------
commit 0a25ab89af2a10563ebc6fddbc08cb7f86f92ec0
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Jul 8 10:26:33 2010 -0400
Return success when printing in create_database
diff --git a/lib/Jifty/Handle.pm b/lib/Jifty/Handle.pm
index c22ce09..011f889 100644
--- a/lib/Jifty/Handle.pm
+++ b/lib/Jifty/Handle.pm
@@ -250,6 +250,7 @@ sub create_database {
$query .= " TEMPLATE template0" if $driver =~ /Pg/;
if ( $mode eq 'print' ) {
print "$query;\n";
+ return 1;
} elsif ( $driver =~ /SQLite/ ) {
return 1; # Kinda an optimistic hack
} else {
commit 2f82163e784e9d3171d33499d1b52ac5c4b307ea
Author: Thomas Sibley <trs at bestpractical.com>
Date: Thu Jul 8 11:19:24 2010 -0400
Ensure we always have a minimal Jifty environment during DB setup
diff --git a/lib/Jifty/Handle.pm b/lib/Jifty/Handle.pm
index 011f889..9bb8e8c 100644
--- a/lib/Jifty/Handle.pm
+++ b/lib/Jifty/Handle.pm
@@ -303,6 +303,7 @@ sub drop_database {
sub _create_original_database {
my $self = shift;
+ require Jifty::Schema;
Jifty::Schema->new->create_all_tables;
# reconnect for consistency
@@ -313,6 +314,8 @@ sub _create_original_database {
sub _upgrade_schema {
my $self = shift;
+
+ require Jifty::Schema;
Jifty::Schema->new->run_upgrades;
}
diff --git a/lib/Jifty/Schema.pm b/lib/Jifty/Schema.pm
index bfff733..3ba3ee3 100644
--- a/lib/Jifty/Schema.pm
+++ b/lib/Jifty/Schema.pm
@@ -39,8 +39,27 @@ delete $_SQL_RESERVED{ lc($_) } for (@_SQL_RESERVED_OVERRIDE);
=head2 flags
Takes and returns a hashref which holds schema management flags. You
-shouldn't need to set these yourself unless you're doing something funky with
-the database.
+shouldn't need to set these yourself unless you're doing some advanced
+database foo.
+
+The following flags are respected, although the first four may be modified by
+L</probe_database_existence>, which is called by L</setup_database>.
+
+=head3 create_database
+
+=head3 drop_database
+
+=head3 create_all_tables
+
+=head3 setup_tables
+
+=head3 print
+
+=head3 no_bootstrap
+
+=head3 ignore_reserved
+
+See L<Jifty::Script::Schema> for an explanation of their usage.
=cut
@@ -109,9 +128,19 @@ sub serialize_current_schema {
}
+=head2 setup_database
+
+Sets up or upgrades a new or existing Jifty database. It is used primarily by L<Jifty::Script::Schema>. Respects a number of flags set with L</flags>.
+
+The methods it calls will die on error, so be sure to wrap any call to this
+method in an C<eval>.
+
+=cut
+
sub setup_database {
my $self = shift;
+ $self->setup_minimal_environment();
$self->probe_database_existence();
$self->manage_database_existence();
@@ -122,6 +151,20 @@ sub setup_database {
}
}
+=head2 setup_minimal_environment
+
+Sets up a minimal Jifty environment.
+
+=cut
+
+sub setup_minimal_environment {
+ # Import Jifty
+ Jifty::Util->require("Jifty");
+ Jifty::Util->require("Jifty::Model::Metadata");
+ Jifty->new( no_handle => 1, logger_component => 'SchemaTool', )
+ unless Jifty->class_loader;
+}
+
=head2 probe_database_existence [NO_HANDLE]
Probes our database to see if it exists and is up to date. This sets various
diff --git a/lib/Jifty/Script/Schema.pm b/lib/Jifty/Script/Schema.pm
index 15ad4a5..aadb319 100644
--- a/lib/Jifty/Script/Schema.pm
+++ b/lib/Jifty/Script/Schema.pm
@@ -172,11 +172,8 @@ Sets up a minimal Jifty environment.
sub setup_environment {
my $self = shift;
- # Import Jifty
- Jifty::Util->require("Jifty");
- Jifty::Util->require("Jifty::Model::Metadata");
- Jifty->new( no_handle => 1, logger_component => 'SchemaTool', )
- unless Jifty->class_loader;
+ # Ensure we have Jifty setup
+ $self->schema->setup_minimal_environment();
# Set the flags for Jifty::Schema
$self->schema->flags({ map { $_ => $self->{$_} }
-----------------------------------------------------------------------
More information about the Jifty-commit
mailing list