X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FAdmin.pm;h=366c2b443d3d731eb5296a4cbee50b750252e1dc;hb=6875b150ef4ed534bcef51352be8224eeabd0d51;hp=284f72db93cb50401429580f4b5980658ac55956;hpb=a77f5ab1c0f242d27d3f77018574c56172bdd95c;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Admin.pm b/lib/DBIx/Class/Admin.pm index 284f72d..366c2b4 100644 --- a/lib/DBIx/Class/Admin.pm +++ b/lib/DBIx/Class/Admin.pm @@ -88,12 +88,26 @@ has 'schema' => ( sub _build_schema { my ($self) = @_; require Class::MOP; - Class::MOP::load_class($self->schema_class); - + { + my @include_dirs = @{$self->include_dirs}; + local @INC = (@include_dirs, @INC); + Class::MOP::load_class($self->schema_class); + } $self->connect_info->[3]->{ignore_version} =1; return $self->schema_class->connect(@{$self->connect_info()} ); # , $self->connect_info->[3], { ignore_version => 1} ); } +=head2 include_dirs + +Extra include directories to look when loading C + +=cut + +has 'include_dirs' => ( + is => 'rw', + isa => 'ArrayRef', + default => sub {[]} +); =head2 resultset @@ -195,7 +209,7 @@ has 'config_stanza' => ( =head2 config -Instead of loading from a file the configuration can be provided directly as a hash ref. Please note +Instead of loading from a file the configuration can be provided directly as a hash ref. Please note config_stanza will still be required. =cut @@ -209,8 +223,8 @@ has config => ( sub _build_config { my ($self) = @_; - eval { require Config::Any } - or die ("Config::Any is required to parse the config file.\n"); + try { require Config::Any } + catch { die ("Config::Any is required to parse the config file.\n") }; my $cfg = Config::Any->load_files ( {files => [$self->config_file], use_ext =>1, flatten_to_hash=>1}); @@ -296,8 +310,8 @@ has '_confirm' => ( =back -L will generate sql for the supplied schema_class in sql_dir. The flavour of sql to -generate can be controlled by suppling a sqlt_type which should be a L name. +L will generate sql for the supplied schema_class in sql_dir. The flavour of sql to +generate can be controlled by suppling a sqlt_type which should be a L name. Arguments for L can be supplied in the sqlt_args hashref. @@ -352,9 +366,9 @@ sub upgrade { =back -install is here to help when you want to move to L and have an existing -database. install will take a version and add the version tracking tables and 'install' the version. No -further ddl modification takes place. Setting the force attribute to a true value will allow overriding of +install is here to help when you want to move to L and have an existing +database. install will take a version and add the version tracking tables and 'install' the version. No +further ddl modification takes place. Setting the force attribute to a true value will allow overriding of already versioned databases. =cut @@ -391,7 +405,7 @@ sub install { =back -deploy will create the schema at the connected database. C<$args> are passed straight to +deploy will create the schema at the connected database. C<$args> are passed straight to L. =cut @@ -399,13 +413,7 @@ L. sub deploy { my ($self, $args) = @_; my $schema = $self->schema(); - if (!$schema->get_db_version() ) { - # schema is unversioned - $schema->deploy( $args, $self->sql_dir) - or $schema->throw_exception ("Could not deploy schema.\n"); # FIXME deploy() does not return 1/0 on success/fail - } else { - $schema->throw_exception("A versioned schema has already been deployed, try upgrade instead.\n"); - } + $schema->deploy( $args, $self->sql_dir ); } =head2 insert @@ -502,7 +510,7 @@ sub delete { =back -select takes the name of a resultset from the schema_class, a where hashref and a attrs to pass to ->search. +select takes the name of a resultset from the schema_class, a where hashref and a attrs to pass to ->search. The found data is returned in a array ref where the first row will be the columns list. =cut @@ -518,7 +526,7 @@ sub select { my @data; my @columns = $resultset->result_source->columns(); - push @data, [@columns];# + push @data, [@columns];# while (my $row = $resultset->next()) { my @fields;