view _test/Test/SQL/Diff.pm @ 245:7c517134c42f

Added Unsupported media type Web exception corrected resourceLocation setting in the resource Implemented localizable resources for text messages fixed TT view scopings, INIT block in controls now sets globals correctly.
author sergey
date Mon, 29 Oct 2012 03:15:22 +0400
parents 4d0e1962161c
children 56364d0c4b4f
line wrap: on
line source

package Test::SQL::Diff;
use strict;
use warnings;
use parent qw(IMPL::Test::Unit);

use IMPL::Test qw(test failed assert);
use IMPL::SQL::Schema();
use IMPL::SQL::Types qw(Integer Varchar Text);
use IMPL::SQL::Schema::Traits::Diff();
use Data::Dumper;

__PACKAGE__->PassThroughArgs;

test diff => sub {
    my $schemaSrc = new IMPL::SQL::Schema(name => 'simple', version => 1 );
    
    my $tbl = $schemaSrc->AddTable({
        name => 'User',
        columns => [
            { name => 'name', type => Varchar(255) },
            { name => 'description', type => Varchar(255) }
        ]
    });
    
    $tbl->AddConstraint( unique => { name => 'unique_name', columns => ['name'] });
    
    my $schemaDst = new IMPL::SQL::Schema(name => 'simple', version => 2 );
    
    my $users = $schemaDst->AddTable({
        name => 'User',
        columns => [
            { name => 'id', type => Integer },
            { name => 'login', type => Varchar(255) },
            { name => 'description', type => Text, isNullable => 1 }
        ]
    });
    
    $users->SetPrimaryKey('id');
    $users->AddConstraint( unique => { name => 'unique_login', columns => ['login'] } );
    
    #warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
    
    $schemaSrc->Dispose;
    $schemaDst->Dispose;
    
};


1;