6 eval "use DBD::SQLite; use SQL::Translator";
8 ? ( skip_all => 'needs DBD::SQLite and SQL::Translator for testing' )
15 # connect to db and deploy only the original db schema, not journal schema
16 my $schema = DBICTest->init_schema(no_populate => 1, no_deploy => 1);
18 ok($schema, 'Created a Schema');
21 # check we have no journal
23 $schema->_journal_schema->resultset('ChangeLog')->count;
27 is( $count, undef, 'no count' );
28 like( $e, qr/table.*changelog/, 'missing table error' );
30 # insert two rows -not- in txn
31 $schema->storage->dbh_do(sub {
34 "INSERT INTO artist ( name ) VALUES ('Fred Bloggs A' )",
35 "INSERT INTO artist ( name ) VALUES ('Fred Bloggs B' )"
40 $schema->journal_schema_deploy();
43 $count = eval { $schema->_journal_schema->resultset('ChangeLog')->count };
45 is( $@, '', "no error" );
46 is( $count, 0, "count is 0 (changelog)" );
49 $schema->prepopulate_journal();
51 # check there is only one changeset
52 $count = eval { $schema->_journal_schema->resultset('ChangeSet')->count };
54 is( $@, '', "no error" );
55 is( $count, 1, "count is 1 (changeset)" );
57 # check it contains two inserts
58 $count = eval { $schema->_journal_schema->resultset('ChangeLog')->count };
60 is( $@, '', "no error" );
61 is( $count, 2, "count is 2 (changelog)" );
63 # check audit log has two rows for two inserts
64 $count = eval { $schema->_journal_schema->resultset('ArtistAuditLog')->count };
66 is( $@, '', "no error" );
67 is( $count, 2, "count is 2 (auditlog)" );