my $base_dir = $self->script_directory;
my $main = catfile( $base_dir, $type );
- my $generic = catfile( $base_dir, '_generic' );
my $common =
catfile( $base_dir, '_common', $prefix, join q(-), @{$versions} );
my $dir;
if (-d $main) {
$dir = catfile($main, $prefix, join q(-), @{$versions})
- } elsif (-d $generic) {
- $dir = catfile($generic, $prefix, join q(-), @{$versions});
} else {
- croak "neither $main or $generic exist; please write/generate some SQL";
+ croak "$main does not exist; please write/generate some SQL";
}
my %files;
| `- up
| `- 1-2
| `- 002-generate-customers.pl
- |- _generic
- | |- down
- | | `- 2-1
- | | `- 001-auto.sql
- | |- schema
- | | `- 1
- | | `- 001-auto.sql
- | `- up
- | `- 1-2
- | |- 001-auto.sql
- | `- 002-create-stored-procedures.sql
`- MySQL
|- down
| `- 2-1
C<.pl> files don't have to be in the C<_common> directory, but most of the time
they should be, because perl scripts are generally be database independent.
-C<_generic> exists for when you for some reason are sure that your SQL is
-generic enough to run on all databases. Good luck with that one.
-
Note that unlike most steps in the process, C<preinstall> will not run SQL, as
there may not even be an database at preinstall time. It will run perl scripts
just like the other steps in the process, but nothing is passed to them.
=back
-=item C<$storage_type> This is a set of scripts that gets run depending on
-what your storage type is. If you are not sure what your storage type is,
-take a look at the producers listed for L<SQL::Translator>. Also note,
-C<_generic> and C<_common> are special cases. C<_generic> will get run if
-there is no directory for your given storage, and C<_common> will get merged
-into whatever other files (C<_generic> or your storage type) you already have.
-This directory can containt the following directories itself:
+=item C<$storage_type> This is a set of scripts that gets run depending on what
+your storage type is. If you are not sure what your storage type is, take a
+look at the producers listed for L<SQL::Translator>. Also note, C<_common>
+is a special case. C<_common> will get merged into whatever other files you
+already have. This directory can containt the following directories itself:
=over 2
-f catfile(qw( t sql SQLite up 1.0-2.0 001-auto.sql )),
'2.0-3.0 diff gets generated properly'
);
- mkpath catfile(qw( t sql _generic up 2.0-3.0 ));
- rename catfile(qw( t sql SQLite up 2.0-3.0 001-auto.sql )), catfile(qw( t sql _generic up 2.0-3.0 001-auto.sql ));
- rmtree(catfile(qw( t sql SQLite )));
- warn 'how can this be' if -d catfile(qw( t sql SQLite ));
dies_ok {
$s->resultset('Foo')->create({
bar => 'frew',
baz => 'frew',
biff => 'frew',
})
- } 'schema is deployed using _generic';
- rmtree(catfile(qw( t sql SQLite )));
- rmtree(catfile(qw( t sql _generic )));
+ } 'schema is deployed';
dies_ok {
$dm->upgrade_single_step({ version_set => [qw( 2.0 3.0 )] });
} 'dies when sql dir does not exist';