isa => 'DBIx::Class::Schema',
is => 'ro',
required => 1,
+ handles => ['schema_version'],
);
has upgrade_directory => ( # configuration
# which is... probably not how we want it
);
+sub _build_to_version { $_[0]->schema->schema_version }
+
has databases => ( # configuration
coerce => 1,
isa => 'DBIx::Class::DeploymentHandler::Databases',
requires 'next_version_set';
-has schema => (
- isa => 'DBIx::Class::Schema',
- is => 'ro',
- required => 1,
- handles => [qw( schema_version )],
-);
-
-has version_storage => (
- does => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
- is => 'ro',
- required => 1,
- handles => 'DBIx::Class::DeploymentHandler::HandlesVersionStorage',
-);
-
-has to_version => (
- is => 'ro',
- lazy_build => 1,
-);
-
-sub _build_to_version { $_[0]->schema->schema_version }
-
1;
__END__
with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
+has schema_version => (
+ isa => 'Str',
+ is => 'ro',
+ required => 1,
+);
+
+has database_version => (
+ isa => 'Str',
+ is => 'ro',
+ required => 1,
+);
+
+has to_version => ( # configuration
+ is => 'ro',
+ lazy_build => 1, # builder comes from another role...
+ # which is... probably not how we want it
+);
+
+sub _build_to_version { $_[0]->schema_version }
+
has once => (
is => 'rw',
isa => 'Bool',
with 'DBIx::Class::DeploymentHandler::HandlesVersioning';
+has schema_version => (
+ isa => 'Str',
+ is => 'ro',
+ required => 1,
+);
+
+has database_version => (
+ isa => 'Str',
+ is => 'ro',
+ required => 1,
+);
+
+has to_version => ( # configuration
+ is => 'ro',
+ lazy_build => 1, # builder comes from another role...
+ # which is... probably not how we want it
+);
+
+sub _build_to_version { $_[0]->schema_version }
+
has ordered_versions => (
is => 'ro',
isa => 'ArrayRef',
my $self = shift;
my $args = {
- schema => $self->schema,
- version_storage => $self->version_storage,
+ database_version => $self->database_version,
+ schema_version => $self->schema_version,
};
$args->{to_version} = $self->to_version if $self->has_to_version;
use lib 't/lib';
use DBICDHTest;
use DBICTest;
-use DBIx::Class::DeploymentHandler;
-use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
-my $db = 'dbi:SQLite:db.db';
-my @connection = ($db, '', '', { ignore_version => 1 });
-my $sql_dir = 't/sql';
+use aliased
+ 'DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions';
-DBICDHTest::ready;
-
-use DBICVersion_v1;
-my $s = DBICVersion::Schema->connect(@connection);
-
-my $handler = DBIx::Class::DeploymentHandler->new({
- upgrade_directory => $sql_dir,
- schema => $s,
- databases => 'SQLite',
- sqltargs => { add_drop_table => 0 },
-});
-my $v_storage = $handler->version_storage;
-my $version = $s->schema_version();
-$handler->prepare_install();
-
-$handler->install;
{
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
- schema => $s,
- ordered_versions => $versions,
+ my $vh = DatabaseToSchemaVersions->new({
to_version => '5.0',
- version_storage => $v_storage,
+ database_version => '1.0',
+ schema_version => '1.0',
});
ok( $vh, 'VersionHandler gets instantiated' );
- ok( eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ), 'db version and to_version get correctly put into version set');
+ ok(
+ eq_array( $vh->next_version_set, [qw( 1.0 5.0 )] ),
+ 'db version and to_version get correctly put into version set'
+ );
ok( !$vh->next_version_set, 'next_version_set only works once');
ok( !$vh->next_version_set, 'seriously.');
}
{
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
- schema => $s,
- ordered_versions => $versions,
- version_storage => $v_storage,
+ my $vh = DatabaseToSchemaVersions->new({
+ database_version => '1.0',
+ schema_version => '1.0',
});
ok( $vh, 'VersionHandler gets instantiated' );
- ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
+ ok(
+ !$vh->next_version_set,
+ 'VersionHandler is null when schema_version and db_verison are the same'
+ );
}
{
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
- schema => $s,
- ordered_versions => $versions,
- version_storage => $v_storage,
+ my $vh = DatabaseToSchemaVersions->new({
+ database_version => '1.0',
+ schema_version => '1.0',
});
ok( $vh, 'VersionHandler gets instantiated' );
- ok( !$vh->next_version_set, 'VersionHandler is null when schema_version and db_verison are the same' );
+ ok(
+ !$vh->next_version_set,
+ 'VersionHandler is null when schema_version and db_verison are the same'
+ );
}
{
- $DBICVersion::Schema::VERSION = '10.0';
-
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::DatabaseToSchemaVersions->new({
- schema => $s,
- ordered_versions => $versions,
- version_storage => $v_storage,
+ my $vh = DatabaseToSchemaVersions->new({
+ database_version => '1.0',
+ schema_version => '10.0',
});
ok( $vh, 'VersionHandler gets instantiated' );
- ok( eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ), 'db version and schema version get correctly put into version set');
+ ok(
+ eq_array( $vh->next_version_set, [qw( 1.0 10.0 )] ),
+ 'db version and schema version get correctly put into version set'
+ );
ok( !$vh->next_version_set, 'VersionHandler is null on next try' );
}
done_testing;
-__END__
-
-vim: ts=2 sw=2 expandtab
+# vim: ts=2 sw=2 expandtab
use Test::Exception;
use lib 't/lib';
-use DBICDHTest;
-use DBICTest;
-use DBIx::Class::DeploymentHandler;
-use DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions;
-my $db = 'dbi:SQLite:db.db';
-my @connection = ($db, '', '', { ignore_version => 1 });
-my $sql_dir = 't/sql';
-
-DBICDHTest::ready;
-
-use DBICVersion_v1;
-my $s = DBICVersion::Schema->connect(@connection);
-
-my $handler = DBIx::Class::DeploymentHandler->new({
- upgrade_directory => $sql_dir,
- schema => $s,
- databases => 'SQLite',
- sqltargs => { add_drop_table => 0 },
-});
-
-my $v_storage = $handler->version_storage;
-
-my $version = $s->schema_version();
-$handler->prepare_install();
-
-$handler->install;
+use aliased
+ 'DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions';
my $versions = [map "$_.0", 0..100];
{
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
- schema => $s,
+ my $vh = ExplicitVersions->new({
ordered_versions => $versions,
to_version => '1.0',
- version_storage => $v_storage,
+ schema_version => '1.0',
+ database_version => '1.0',
});
ok $vh, 'VersionHandler gets instantiated';
- ok( !$vh->next_version_set, 'next version set returns undef if we are at the version requested' );
+ ok(
+ !$vh->next_version_set,
+ 'next version set returns undef if we are at the version requested'
+ );
}
{
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
- schema => $s,
+ my $vh = ExplicitVersions->new({
ordered_versions => $versions,
to_version => '5.0',
- version_storage => $v_storage,
+ schema_version => '1.0',
+ database_version => '1.0',
});
ok $vh, 'VersionHandler gets instantiated';
- ok( eq_array($vh->next_version_set, [qw( 1.0 2.0 )]), 'first version pair works' );
- ok( eq_array($vh->next_version_set, [qw( 2.0 3.0 )]), 'second version pair works' );
- ok( eq_array($vh->next_version_set, [qw( 3.0 4.0 )]), 'third version pair works' );
- ok( eq_array($vh->next_version_set, [qw( 4.0 5.0 )]), 'fourth version pair works' );
+ ok(
+ eq_array($vh->next_version_set, [qw( 1.0 2.0 )]),
+ 'first version pair works'
+ );
+ ok(
+ eq_array($vh->next_version_set, [qw( 2.0 3.0 )]),
+ 'second version pair works'
+ );
+ ok(
+ eq_array($vh->next_version_set, [qw( 3.0 4.0 )]),
+ 'third version pair works'
+ );
+ ok(
+ eq_array($vh->next_version_set, [qw( 4.0 5.0 )]),
+ 'fourth version pair works'
+ );
ok( !$vh->next_version_set, 'no more versions after final pair' );
ok( !$vh->next_version_set, 'still no more versions after final pair' );
}
dies_ok {
- my $vh = DBIx::Class::DeploymentHandler::VersionHandler::ExplicitVersions->new({
- schema => $s,
+ my $vh = ExplicitVersions->new({
ordered_versions => $versions,
to_version => '0.0',
- version_storage => $v_storage,
+ schema_version => '1.0',
+ database_version => '1.0',
});
} 'cannot request a version before the current version';
done_testing;
-__END__
-
-vim: ts=2 sw=2 expandtab
+#vim: ts=2 sw=2 expandtab