);
}
-method _ddl_schema_diff_in_filenames($type, $versions, $dir) {
- $self->__ddl_in_with_prefix($type, $versions, 'diff')
+method _ddl_schema_up_in_filenames($type, $versions, $dir) {
+ $self->__ddl_in_with_prefix($type, $versions, 'up')
}
-method _ddl_schema_diff_out_filename($type, $versions, $dir) {
+method _ddl_schema_down_in_filenames($type, $versions, $dir) {
+ $self->__ddl_in_with_prefix($type, $versions, 'down')
+}
+
+method _ddl_schema_up_out_filename($type, $versions, $dir) {
+ my $dirname = File::Spec->catfile(
+ $dir, $type, 'up', join( q(-), @{$versions} )
+ );
+ File::Path::mkpath($dirname) unless -d $dirname;
+
+ return File::Spec->catfile(
+ $dirname, '001-auto.sql'
+ );
+}
+
+method _ddl_schema_down_out_filename($type, $versions, $dir) {
my $dirname = File::Spec->catfile(
- $dir, $type, 'diff', join( q(-), @{$versions} )
+ $dir, $type, 'down', join( q(-), @{$versions} )
);
File::Path::mkpath($dirname) unless -d $dirname;
}
}
-sub prepare_update {
+sub prepare_upgrade {
my ($self, $from_version, $to_version, $version_set) = @_;
$from_version ||= $self->db_version;
next;
}
- my $diff_file = $self->_ddl_schema_diff_out_filename($db, $version_set, $dir );
+ my $diff_file = $self->_ddl_schema_up_out_filename($db, $version_set, $dir );
if(-e $diff_file) {
- carp("Overwriting existing diff file - $diff_file");
+ carp("Overwriting existing up-diff file - $diff_file");
unlink $diff_file;
}
sub _upgrade_single_step {
my $self = shift;
my @version_set = @{ shift @_ };
- my @upgrade_files = @{$self->_ddl_schema_diff_in_filenames(
+ my @upgrade_files = @{$self->_ddl_schema_up_in_filenames(
$self->storage->sqlt_type,
\@version_set,
)};
$version = $s->schema_version();
$handler->prepare_install();
- $handler->prepare_update('1.0', $version);
+ $handler->prepare_upgrade('1.0', $version);
#ok(-e 't/sql/DBICVersion-Schema-schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully');
#ok(-e 't/sql/DBICVersion-Schema-diff-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully');
dies_ok {
$version = $s->schema_version();
$handler->prepare_install;
- $handler->prepare_update( '1.0', $version );
- $handler->prepare_update( '2.0', $version );
+ $handler->prepare_upgrade( '1.0', $version );
+ $handler->prepare_upgrade( '2.0', $version );
#ok(-e 't/sql/DBICVersion-Schema-schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully');
#ok(-e 't/sql/DBICVersion-Schema-diff-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully');
#ok(-e 't/sql/DBICVersion-Schema-diff-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');