9 use aliased 'DBIx::Class::DeploymentHandler::VersionStorage::Standard';
12 use DBIx::Class::DeploymentHandler;
13 my $db = 'dbi:SQLite:db.db';
14 my @connection = ($db, '', '', { ignore_version => 1 });
15 my $sql_dir = 't/sql';
17 my $s = DBICVersion::Schema->connect(@connection);
20 local $SIG{__WARN__} = sub {$warning = shift};
21 my $t = DBICVersion::Schema->connect('frewfrew', '', '');
22 like( $warning, qr/Your DB is currently unversioned. Please call upgrade on your schema to sync the DB/, 'warning when database is unversioned');
27 my $handler = DBIx::Class::DeploymentHandler->new({
28 upgrade_directory => $sql_dir,
30 databases => 'SQLite',
31 sqltargs => { add_drop_table => 0 },
34 $handler->prepare_install();
36 my $vs = Standard->new({ schema => $s });
38 ok( $vs, 'DBIC::DH::VersionStorage::Standard instantiates correctly' );
40 ok( !$vs->version_storage_is_installed, 'VersionStorage is not yet installed' );
44 ok( $vs->version_storage_is_installed, 'VersionStorage is now installed' );
49 [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all],
52 'initial version works correctly'
55 is( $vs->database_version, '1.0', 'database version is 1.0');
56 $vs->add_database_version({
59 is( $vs->database_version, '2.0', 'database version is 2.0');
63 [ $vs->version_rs->search(undef, {order_by => 'id'})->get_column('version')->all],
66 'adding another version works correctly'
71 local $SIG{__WARN__} = sub {$warning = shift};
72 my $u = DBICVersion::Schema->connect($db, '', '');
73 like( $warning, qr/Versions out of sync. This is 1.0, your database contains version 2.0, please call upgrade on your Schema./, 'warning when database/schema mismatch');
77 $vs->version_rs->delete;
79 ok( $vs->version_storage_is_installed, 'VersionStorage is still installed even if all versions are deleted' );