handles => [qw( is_installed db_version )],
);
+has databases => (
+ # make this coerce from Str
+ isa => 'ArrayRef[Str]',
+ is => 'ro',
+ default => sub { [qw( MySQL SQLite PostgreSQL )] },
+);
+
method _build_version_rs {
$self->schema->set_us_up_the_bomb;
$self->schema->resultset('__VERSION')
});
}
-method create_ddl_dir($databases, $version, $dir, $preversion, $sqltargs) {
+method create_ddl_dir($version, $preversion, $sqltargs) {
my $schema = $self->schema;
- if(!$dir || !-d $dir) {
- carp "No directory given, using ./\n";
+ my $databases = $self->databases;
+ my $dir = $self->upgrade_directory;
+ unless( -d $dir ) {
+ carp "Upgrade directory $dir does not exist, using ./\n";
$dir = "./";
}
- $databases ||= ['MySQL', 'SQLite', 'PostgreSQL'];
- $databases = [ $databases ] if(ref($databases) ne 'ARRAY');
my $schema_version = $schema->schema_version || '1.x';
$version ||= $schema_version;
my $handler = DBIx::Class::DeploymentHandler->new({
upgrade_directory => $sql_dir,
schema => $s,
+ databases => ['SQLite'],
});
ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly');
my $version = $s->schema_version();
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
+ $handler->create_ddl_dir( $version, 0);
ok(-e 't/sql/DBICVersion-Schema-1.0-SQLite.sql', 'DDL for 1.0 got created successfully');
dies_ok {
my $handler = DBIx::Class::DeploymentHandler->new({
upgrade_directory => $sql_dir,
schema => $s,
+ databases => ['SQLite'],
});
ok($handler, 'DBIx::Class::DeploymentHandler w/2.0 instantiates correctly');
$version = $s->schema_version();
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '1.0');
+ $handler->create_ddl_dir($version, 0);
+ $handler->create_ddl_dir($version, '1.0');
ok(-e 't/sql/DBICVersion-Schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully');
ok(-e 't/sql/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully');
dies_ok {
my $handler = DBIx::Class::DeploymentHandler->new({
upgrade_directory => $sql_dir,
schema => $s,
+ databases => ['SQLite'],
});
ok($handler, 'DBIx::Class::DeploymentHandler w/3.0 instantiates correctly');
$version = $s->schema_version();
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, 0);
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '1.0');
- $handler->create_ddl_dir( 'SQLite', $version, $sql_dir, '2.0');
+ $handler->create_ddl_dir( $version, 0);
+ $handler->create_ddl_dir( $version, '1.0');
+ $handler->create_ddl_dir( $version, '2.0');
ok(-e 't/sql/DBICVersion-Schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully');
ok(-e 't/sql/DBICVersion-Schema-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully');
ok(-e 't/sql/DBICVersion-Schema-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');