use Carp::Clan '^DBIx::Class::DeploymentHandler';
with 'DBIx::Class::DeploymentHandler::WithSqltDeployMethod';
+with 'DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions';
BEGIN {
use Moose::Util::TypeConstraints;
}
}
-method ordered_schema_versions { undef }
-
method upgrade {
my $db_version = $self->db_version;
my $schema_version = $self->schema_version;
return;
}
- my @version_list = $self->ordered_schema_versions ||
- ( $db_version, $schema_version );
+ my @version_list = $self->ordered_schema_versions;
# remove all versions in list above the required version
while ( @version_list && ( $version_list[-1] ne $schema_version ) ) {
--- /dev/null
+package DBIx::Class::DeploymentHandler::DatabaseToSchemaVersions;
+use Moose;
+use Method::Signatures::Simple;
+
+has schema => (
+ isa => 'DBIx::Class::Schema',
+ is => 'ro',
+ required => 1,
+ handles => [qw( ddl_filename schema_version )],
+);
+
+has version_rs => (
+ isa => 'DBIx::Class::ResultSet',
+ is => 'ro',
+ lazy_build => 1,
+ handles => [qw( is_installed db_version )],
+);
+
+method _build_version_rs {
+ $self->schema->set_us_up_the_bomb;
+ $self->schema->resultset('__VERSION')
+}
+
+method ordered_schema_versions {
+ ( $self->db_version, $self->schema_version)
+}
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::ExplicitVersions;
+use Moose;
+use Method::Signatures::Simple;
+
+method ordered_schema_versions { undef }
+
+__PACKAGE__->meta->make_immutable;
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab
--- /dev/null
+package DBIx::Class::DeploymentHandler::WithDatabaseToSchemaVersions;
+use Moose::Role;
+
+use DBIx::Class::DeploymentHandler::DatabaseToSchemaVersions;
+
+use Carp 'carp';
+
+has version_handler => (
+
+# < mst> isa => 'DBIx::Class::DeploymentHandler::SqltDeployMethod',
+# < mst> should be
+# < mst> does => <some role>
+# < mst> and that role should supply those methods
+# < mst> then you can pass handles => <some role> as well
+
+ isa => 'DBIx::Class::DeploymentHandler::DatabaseToSchemaVersions',
+ is => 'ro',
+ lazy_build => 1,
+ handles => [qw{ ordered_schema_versions }],
+);
+
+sub _build_version_handler {
+ my $self = shift;
+ DBIx::Class::DeploymentHandler::DatabaseToSchemaVersions->new({
+ schema => $self->schema,
+ });
+}
+
+1;
+
+__END__
+
+vim: ts=2 sw=2 expandtab