comparison _test/Test/SQL/Diff.pm @ 168:6148f89bb7bf

IMPL::SQL::Schema::Traits::Diff alfa version IMPL::lang added hash traits
author sourcer
date Mon, 16 May 2011 04:30:38 +0400
parents
children fd92830036c3
comparison
equal deleted inserted replaced
167:1f7a6d762394 168:6148f89bb7bf
1 package Test::SQL::Diff;
2 use strict;
3 use warnings;
4 use parent qw(IMPL::Test::Unit);
5
6 use IMPL::Test qw(test failed assert);
7 use IMPL::SQL::Schema();
8 use IMPL::SQL::Types qw(Integer Varchar Text);
9 use IMPL::SQL::Schema::Traits::Diff();
10 use Data::Dumper;
11
12 __PACKAGE__->PassThroughArgs;
13
14 test diff => sub {
15 my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 );
16
17 $schemaSrc->AddTable({
18 name => 'User',
19 columns => [
20 { name => 'name', type => Varchar(255) }
21 ]
22 });
23
24 my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 );
25
26 my $users = $schemaDst->AddTable({
27 name => 'User',
28 columns => [
29 { name => 'id', type => Integer },
30 { name => 'login', type => Varchar(255) },
31 { name => 'description', type => Text, isNullable => 1 }
32 ]
33 });
34
35 $users->SetPrimaryKey('id');
36 $users->AddConstraint( unique => { name => 'unique_user_login', columns => ['login'] } );
37
38 warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
39
40 $schemaSrc->Dispose;
41 $schemaDst->Dispose;
42
43 };
44
45
46 1;