view _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
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 );
	
	$schemaSrc->AddTable({
		name => 'User',
		columns => [
			{ name => 'name', type => Varchar(255) }
		]
	});
	
	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_user_login', columns => ['login'] } );
	
	warn Dumper(IMPL::SQL::Schema::Traits::Diff->Diff($schemaSrc,$schemaDst));
	
	$schemaSrc->Dispose;
	$schemaDst->Dispose;
	
};


1;