X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FVersioned.pm;h=e92f356b92ca5de18d4406e32bcb35be379a0ab2;hb=d095c62d491afe010e870f31b4e0d1419273cba9;hp=a04b23e3c16f5d6f4445488b87af4cf9d29fd705;hpb=701c96934b3da7a8560d5c53bc84fa7e6ccf0415;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index a04b23e..e92f356 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -109,7 +109,7 @@ Downgrades in addition to upgrades =item * -Multiple sql files files per upgrade/downgrade/install +Multiple sql files per upgrade/downgrade/install =item * @@ -204,6 +204,7 @@ use base 'DBIx::Class::Schema'; use DBIx::Class::Carp; use Time::HiRes qw/gettimeofday/; use Try::Tiny; +use Scalar::Util 'weaken'; use namespace::clean; __PACKAGE__->mk_classdata('_filedata'); @@ -298,7 +299,7 @@ sub create_upgrade_path { =over 4 -=item Returns: a list of version numbers, ordered from lowest to highest +=item Return Value: a list of version numbers, ordered from lowest to highest =back @@ -589,9 +590,10 @@ sub _on_connect { my ($self) = @_; - my $conn_info = $self->storage->connect_info; - $self->{vschema} = DBIx::Class::Version->connect(@$conn_info); - my $conn_attrs = $self->{vschema}->storage->_dbic_connect_attributes || {}; + weaken (my $w_self = $self ); + + $self->{vschema} = DBIx::Class::Version->connect(sub { $w_self->storage->dbh }); + my $conn_attrs = $self->storage->_dbic_connect_attributes || {}; my $vtable = $self->{vschema}->resultset('Table'); @@ -600,10 +602,10 @@ sub _on_connect # check for legacy versions table and move to new if exists unless ($self->_source_exists($vtable)) { - my $vtable_compat = DBIx::Class::VersionCompat->connect(@$conn_info)->resultset('TableCompat'); + my $vtable_compat = DBIx::Class::VersionCompat->connect(sub { $w_self->storage->dbh })->resultset('TableCompat'); if ($self->_source_exists($vtable_compat)) { $self->{vschema}->deploy; - map { $vtable->create({ installed => $_->Installed, version => $_->Version }) } $vtable_compat->all; + map { $vtable->new_result({ installed => $_->Installed, version => $_->Version })->insert } $vtable_compat->all; $self->storage->_get_dbh->do("DROP TABLE " . $vtable_compat->result_source->from); } } @@ -710,7 +712,7 @@ sub _set_db_version { # formatted by this new function will sort _after_ any existing 200... strings. my @tm = gettimeofday(); my @dt = gmtime ($tm[0]); - my $o = $vtable->create({ + my $o = $vtable->new_result({ version => $version, installed => sprintf("v%04d%02d%02d_%02d%02d%02d.%03.0f", $dt[5] + 1900, @@ -721,7 +723,7 @@ sub _set_db_version { $dt[0], int($tm[1] / 1000), # convert to millisecs ), - }); + })->insert; } sub _read_sql_file { @@ -757,10 +759,9 @@ sub _source_exists 1; -=head1 AUTHORS +=head1 AUTHOR AND CONTRIBUTORS -Jess Robinson -Luke Saunders +See L and L in DBIx::Class =head1 LICENSE