8 eval "use DBD::SQLite; use SQL::Translator 0.08;";
10 ? ( skip_all => 'needs DBD::SQLite and SQL::Translator 0.08 for testing' )
16 use_ok('DBICVersionOrig');
18 my $db_file = "t/var/versioning.db";
19 unlink($db_file) if -e $db_file;
20 unlink($db_file . "-journal") if -e $db_file . "-journal";
21 mkdir("t/var") unless -d "t/var";
22 unlink('t/var/DBICVersion-Schema-1.0-SQLite.sql');
24 my $schema_orig = DBICVersion::Schema->connect(
25 "dbi:SQLite:$db_file",
30 # $schema->storage->ensure_connected();
32 is($schema_orig->ddl_filename('SQLite', 't/var', '1.0'), File::Spec->catfile('t', 'var', 'DBICVersion-Schema-1.0-SQLite.sql'), 'Filename creation working');
33 $schema_orig->create_ddl_dir('SQLite', undef, 't/var');
35 ok(-f 't/var/DBICVersion-Schema-1.0-SQLite.sql', 'Created DDL file');
36 ## do this here or let Versioned.pm do it?
39 my $tvrs = $schema_orig->resultset('Table');
40 is($schema_orig->_source_exists($tvrs), 1, 'Created schema from DDL file');
42 eval "use DBICVersionNew";
43 my $schema_new = DBICVersion::Schema->connect(
44 "dbi:SQLite:$db_file",
50 unlink('t/var/DBICVersion-Schema-2.0-SQLite.sql');
51 unlink('t/var/DBICVersion-Schema-1.0-2.0-SQLite.sql');
52 $schema_new->create_ddl_dir('SQLite', undef, 't/var', '1.0');
53 ok(-f 't/var/DBICVersion-Schema-1.0-2.0-SQLite.sql', 'Created DDL upgrade file');
55 ## create new to pick up filedata for upgrade files we just made (on_connect)
56 my $schema_upgrade = DBICVersion::Schema->connect(
57 "dbi:SQLite:$db_file",
63 ## do this here or let Versioned.pm do it?
64 $schema_upgrade->upgrade();
65 $tvrs = $schema_upgrade->resultset('Table');
66 is($schema_upgrade->_source_exists($tvrs), 1, 'Upgraded schema from DDL file');
68 unlink($db_file) if -e $db_file;
69 unlink($db_file . "-journal") if -e $db_file . "-journal";
70 unlink('t/var/DBICVersion-Schema-1.0-SQLite.sql');
71 unlink('t/var/DBICVersion-Schema-2.0-SQLite.sql');
72 unlink('t/var/DBICVersion-Schema-1.0-2.0-SQLite.sql');
73 unlink(<t/var/backup/*>);