comparison Lib/IMPL/SQL/Schema/Traits/Diff.pm @ 165:76515373dac0

Added Class::Template, Rewritten SQL::Schema 'use parent' directive instead of 'use base'
author wizard
date Sat, 23 Apr 2011 23:06:48 +0400
parents
children 1f7a6d762394
comparison
equal deleted inserted replaced
164:eb3e9861a761 165:76515373dac0
1 package IMPL::SQL::Schema::Traits::Diff;
2 use strict;
3 use warnings;
4 use IMPL::lang;
5
6 use IMPL::SQL::Schema();
7 use IMPL::SQL::Schema::Traits();
8
9 use constant {
10 schema_t => typeof IMPL::SQL::Schema # defining a constant is a good style to enable compile checks
11 };
12
13 sub Diff {
14 my ($self,$src,$dst) = @_;
15
16 die new IMPL::InvalidArgumentException( src => "A valid source schema is required") unless is($src,schema_t);
17 die new IMPL::InvalidArgumentException( dst => "A valid desctination schema is requried" ) unless is($src,schema_t);
18
19 my %dstTables = map { $_->name, $_ } $dst->GetTables;
20
21 my @operations;
22
23 foreach my $srcTable ( $src->GetTables) {
24 my $dstTable = delete $dstTables{$srcTable->name};
25
26 if (not $dstTable) {
27 push @operations, new IMPL::SQL::Schema::Traits::DropTable()
28 } else {
29
30 }
31
32 }
33 }
34
35 1;