Commit | Line | Data |
f9c6ab50 |
1 | #!perl |
2 | |
3 | use Test::More; |
4 | use Test::Exception; |
5 | |
6 | use lib 't/lib'; |
7 | use DBICDHTest; |
8 | use aliased 'DBIx::Class::DeploymentHandler::DeployMethod::SQL::Translator'; |
9 | use File::Spec::Functions; |
10 | use File::Path qw(rmtree mkpath); |
11 | |
12 | my $db = 'dbi:SQLite:db.db'; |
13 | my @connection = ($db, '', '', { ignore_version => 1 }); |
14 | my $sql_dir = 't/sql'; |
15 | |
16 | DBICDHTest::ready; |
17 | |
18 | VERSION1: { |
19 | use_ok 'DBICVersion_v1'; |
20 | my $s = DBICVersion::Schema->connect(@connection); |
21 | my $dm = Translator->new({ |
22 | schema => $s, |
23 | script_directory => $sql_dir, |
24 | databases => ['SQLite'], |
25 | sql_translator_args => { add_drop_table => 0 }, |
26 | }); |
27 | |
28 | $dm->prepare_deploy; |
29 | $dm->deploy; |
30 | } |
31 | |
32 | VERSION2: { |
33 | use_ok 'DBICVersion_v2'; |
34 | my $s = DBICVersion::Schema->connect(@connection); |
35 | my $dm = Translator->new({ |
36 | schema => $s, |
37 | script_directory => $sql_dir, |
38 | databases => ['SQLite'], |
39 | sql_translator_args => { add_drop_table => 0 }, |
40 | txn_wrap => 1, |
41 | }); |
42 | |
43 | $version = $s->schema_version(); |
44 | $dm->prepare_deploy; |
58eb99c3 |
45 | mkpath(catfile(qw( t sql _preprocess_schema upgrade 1.0-2.0 ))); |
f9c6ab50 |
46 | open my $prerun, '>', |
58eb99c3 |
47 | catfile(qw( t sql _preprocess_schema upgrade 1.0-2.0 003-semiautomatic.pl )); |
f9c6ab50 |
48 | print {$prerun} |
49 | 'sub { |
50 | use File::Touch; |
51 | touch(q(robotparty)) |
52 | if $_[0]->isa("SQL::Translator::Schema") |
53 | && $_[1]->isa("SQL::Translator::Schema"); |
54 | }'; |
55 | close $prerun; |
56 | $dm->prepare_upgrade({ |
57 | from_version => '1.0', |
58 | to_version => '2.0', |
59 | version_set => [qw(1.0 2.0)] |
60 | }); |
61 | ok -e 'robotparty', 'intermediate script ran with the right args'; |
62 | $dm->upgrade_single_step({ version_set => [qw( 1.0 2.0 )] }); |
63 | } |
64 | done_testing; |
65 | #vim: ts=2 sw=2 expandtab |