X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=2413960fc46f7bd71535784bb878a0d80a93466c;hb=b97c2c1e790cc4c18370238fd98eddac4e7de2d8;hp=05bad6a71654991e6d4202bf4095d1ba54d4ac02;hpb=e8ad6491c9e520ef034a1f94e702e660d5c5959c;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 05bad6a..2413960 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -308,26 +308,44 @@ Does the actual schema-construction work. sub load { my $self = shift; + $self->_load_tables($self->_tables_list); +} + +=head2 rescan + +Rescan the database for newly added tables. Does +not process drops or changes. + +=cut + +sub rescan { + my $self = shift; + + my @created; + my @current = $self->_tables_list; + foreach my $table ($self->_tables_list) { + if(!exists $self->{_tables}->{$table}) { + push(@created, $table); + } + } + + $self->_load_tables(@created); +} + +sub _load_tables { + my ($self, @tables) = @_; + # First, use _tables_list with constraint and exclude # to get a list of tables to operate on my $constraint = $self->constraint; my $exclude = $self->exclude; - my @tables = sort $self->_tables_list; - if(!@tables) { - warn "No tables found in database, nothing to load"; - } - else { - @tables = grep { /$constraint/ } @tables if $constraint; - @tables = grep { ! /$exclude/ } @tables if $exclude; - - warn "All tables excluded by constraint/exclude, nothing to load" - if !@tables; - } + @tables = grep { /$constraint/ } @tables if $constraint; + @tables = grep { ! /$exclude/ } @tables if $exclude; - # Save the tables list - $self->{_tables} = \@tables; + # Save the new tables to the tables list + push(@{$self->{_tables}}, @tables); # Set up classes/monikers { @@ -592,7 +610,7 @@ names. sub tables { my $self = shift; - return @{$self->_tables}; + return keys %{$self->_tables}; } # Make a moniker from a table