=item *
-Multiple sql files files per upgrade/downgrade/install
+Multiple sql files per upgrade/downgrade/install
=item *
use DBIx::Class::Carp;
use Time::HiRes qw/gettimeofday/;
use Try::Tiny;
+use Scalar::Util 'weaken';
use namespace::clean;
__PACKAGE__->mk_classdata('_filedata');
Takes one argument which should be the version that the database is currently at. Defaults to the return value of L</schema_version>.
-See L</getting_started> for more details.
+See L</GETTING STARTED> for more details.
=cut
=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
{
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');
# 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);
}
}
# 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,
$dt[0],
int($tm[1] / 1000), # convert to millisecs
),
- });
+ })->insert;
}
sub _read_sql_file {
};
}
-1;
+=head1 FURTHER QUESTIONS?
+Check the list of L<additional DBIC resources|DBIx::Class/GETTING HELP/SUPPORT>.
-=head1 AUTHOR AND CONTRIBUTORS
+=head1 COPYRIGHT AND LICENSE
-See L<AUTHOR|DBIx::Class/AUTHOR> and L<CONTRIBUTORS|DBIx::Class/CONTRIBUTORS> in DBIx::Class
+This module is free software L<copyright|DBIx::Class/COPYRIGHT AND LICENSE>
+by the L<DBIx::Class (DBIC) authors|DBIx::Class/AUTHORS>. You can
+redistribute it and/or modify it under the same terms as the
+L<DBIx::Class library|DBIx::Class/COPYRIGHT AND LICENSE>.
-=head1 LICENSE
+=cut
-You may distribute this code under the same terms as Perl itself.
+1;