8 use DBIx::Class::DeploymentHandler;
9 my $db = 'dbi:SQLite:db.db';
10 my @connection = ($db, '', '', { ignore_version => 1 });
11 my $sql_dir = 't/sql';
13 unlink 'db.db' if -e 'db.db';
15 unlink $_ for glob('t/sql/*');
21 use_ok 'DBICVersion_v1';
22 my $s = DBICVersion::Schema->connect(@connection);
23 ok($s, 'DBICVersion::Schema 1.0 instantiates correctly');
24 my $handler = DBIx::Class::DeploymentHandler->new({
25 upgrade_directory => $sql_dir,
27 databases => 'SQLite',
28 sqltargs => { add_drop_table => 0 },
31 ok($handler, 'DBIx::Class::DeploymentHandler w/1.0 instantiates correctly');
33 my $version = $s->schema_version();
34 $handler->prepare_install();
35 ok(-e 't/sql/DBICVersion-Schema-schema-1.0-SQLite.sql', 'DDL for 1.0 got created successfully');
38 $s->resultset('Foo')->create({
41 } 'schema not deployed';
44 $s->resultset('Foo')->create({
47 } 'schema is deployed';
51 use_ok 'DBICVersion_v2';
52 my $s = DBICVersion::Schema->connect(@connection);
53 ok($s, 'DBICVersion::Schema 2.0 instantiates correctly');
54 my $handler = DBIx::Class::DeploymentHandler->new({
55 upgrade_directory => $sql_dir,
57 databases => 'SQLite',
60 ok($handler, 'DBIx::Class::DeploymentHandler w/2.0 instantiates correctly');
62 $version = $s->schema_version();
63 $handler->prepare_install();
64 $handler->prepare_update('1.0', $version);
65 ok(-e 't/sql/DBICVersion-Schema-schema-2.0-SQLite.sql', 'DDL for 2.0 got created successfully');
66 ok(-e 't/sql/DBICVersion-Schema-diff-1.0-2.0-SQLite.sql', 'DDL for migration from 1.0 to 2.0 got created successfully');
68 $s->resultset('Foo')->create({
72 } 'schema not deployed';
73 #$handler->install('1.0');
75 $s->resultset('Foo')->create({
79 } 'schema not uppgrayyed';
82 $s->resultset('Foo')->create({
86 } 'schema is deployed';
90 use_ok 'DBICVersion_v3';
91 my $s = DBICVersion::Schema->connect(@connection);
92 ok($s, 'DBICVersion::Schema 3.0 instantiates correctly');
93 my $handler = DBIx::Class::DeploymentHandler->new({
94 upgrade_directory => $sql_dir,
96 databases => 'SQLite',
99 ok($handler, 'DBIx::Class::DeploymentHandler w/3.0 instantiates correctly');
101 $version = $s->schema_version();
102 $handler->prepare_install;
103 $handler->prepare_update( '1.0', $version );
104 $handler->prepare_update( '2.0', $version );
105 ok(-e 't/sql/DBICVersion-Schema-schema-3.0-SQLite.sql', 'DDL for 3.0 got created successfully');
106 ok(-e 't/sql/DBICVersion-Schema-diff-1.0-3.0-SQLite.sql', 'DDL for migration from 1.0 to 3.0 got created successfully');
107 ok(-e 't/sql/DBICVersion-Schema-diff-2.0-3.0-SQLite.sql', 'DDL for migration from 2.0 to 3.0 got created successfully');
109 $s->resultset('Foo')->create({
114 } 'schema not deployed';
117 $s->resultset('Foo')->create({
122 } 'schema is deployed';
128 vim: ts=2 sw=2 expandtab