comparison _test/Test/SQL/Diff.pm @ 169:fd92830036c3

corrected IMPL::SQL::Schema::Diff
author sourcer
date Tue, 17 May 2011 00:04:28 +0400
parents 6148f89bb7bf
children d1676be8afcc
comparison
equal deleted inserted replaced
168:6148f89bb7bf 169:fd92830036c3
12 __PACKAGE__->PassThroughArgs; 12 __PACKAGE__->PassThroughArgs;
13 13
14 test diff => sub { 14 test diff => sub {
15 my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 ); 15 my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 );
16 16
17 $schemaSrc->AddTable({ 17 my $tbl = $schemaSrc->AddTable({
18 name => 'User', 18 name => 'User',
19 columns => [ 19 columns => [
20 { name => 'name', type => Varchar(255) } 20 { name => 'name', type => Varchar(255) },
21 { name => 'description', type => Varchar(255) }
21 ] 22 ]
22 }); 23 });
24
25 $tbl->AddConstraint( unique => { name => 'unique_name', columns => ['name'] });
23 26
24 my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 ); 27 my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 );
25 28
26 my $users = $schemaDst->AddTable({ 29 my $users = $schemaDst->AddTable({
27 name => 'User', 30 name => 'User',
31 { name => 'description', type => Text, isNullable => 1 } 34 { name => 'description', type => Text, isNullable => 1 }
32 ] 35 ]
33 }); 36 });
34 37
35 $users->SetPrimaryKey('id'); 38 $users->SetPrimaryKey('id');
36 $users->AddConstraint( unique => { name => 'unique_user_login', columns => ['login'] } ); 39 $users->AddConstraint( unique => { name => 'unique_login', columns => ['login'] } );
37 40
38 warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst)); 41 warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
39 42
40 $schemaSrc->Dispose; 43 $schemaSrc->Dispose;
41 $schemaDst->Dispose; 44 $schemaDst->Dispose;