X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FVersioned.pm;h=4e7b944de29ded6ef694eb85633d580dc4b19622;hb=4c633384a2afd15b77f6c5d46b9c7831feaa1272;hp=036d4521fa71b1541fb8ecb5a2e6cfb4274340af;hpb=fb50ae66893dadd76a192a53e65d5d9ba171d1f3;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Schema/Versioned.pm b/lib/DBIx/Class/Schema/Versioned.pm index 036d452..4e7b944 100644 --- a/lib/DBIx/Class/Schema/Versioned.pm +++ b/lib/DBIx/Class/Schema/Versioned.pm @@ -96,11 +96,6 @@ this will attempt to upgrade the database from its current version to the curren schema version using a diff from your I. If a suitable diff is not found then no upgrade is possible. -NB: At the moment, only SQLite and MySQL are supported. This is due to -spotty behaviour in the SQL::Translator producers, please help us by -enhancing them. Ask on the mailing list or IRC channel for details (community details -in L). - =head1 GETTING STARTED Firstly you need to setup your schema class as per the L, make sure @@ -568,23 +563,22 @@ sub _on_connect { my ($self) = @_; - my $info = $self->storage->connect_info; - my $args = $info->[-1]; + my $conn_info = $self->storage->connect_info; + $self->{vschema} = DBIx::Class::Version->connect(@$conn_info); + my $conn_attrs = $self->{vschema}->storage->_dbic_connect_attributes || {}; - $self->{vschema} = DBIx::Class::Version->connect(@$info); my $vtable = $self->{vschema}->resultset('Table'); # useful when connecting from scripts etc - return if ($args->{ignore_version} || ($ENV{DBIC_NO_VERSION_CHECK} && !exists $args->{ignore_version})); + return if ($conn_attrs->{ignore_version} || ($ENV{DBIC_NO_VERSION_CHECK} && !exists $conn_attrs->{ignore_version})); # check for legacy versions table and move to new if exists - my $vschema_compat = DBIx::Class::VersionCompat->connect(@$info); unless ($self->_source_exists($vtable)) { - my $vtable_compat = $vschema_compat->resultset('TableCompat'); + my $vtable_compat = DBIx::Class::VersionCompat->connect(@$conn_info)->resultset('TableCompat'); if ($self->_source_exists($vtable_compat)) { $self->{vschema}->deploy; map { $vtable->create({ installed => $_->Installed, version => $_->Version }) } $vtable_compat->all; - $self->storage->dbh->do("DROP TABLE " . $vtable_compat->result_source->from); + $self->storage->_get_dbh->do("DROP TABLE " . $vtable_compat->result_source->from); } } @@ -726,9 +720,12 @@ sub _source_exists { my ($self, $rs) = @_; - my $c = try { $rs->search({ 1, 0 })->count }; - - return (defined $c) ? 1 : 0; + return try { + $rs->search(\'1=0')->cursor->next; + 1; + } catch { + 0; + }; } 1;