root/lang/perl/Archer/trunk/lib/Archer/Plugin/MySQLDiff/Sledge.pm @ 14975

Revision 14975, 1.0 kB (checked in by tokuhirom, 5 years ago)

i think, SQL::Translator is too slow.

Line 
1package Archer::Plugin::MySQLDiff::Sledge;
2use strict;
3use warnings;
4use base qw/Archer::Plugin/;
5use MySQL::Diff;
6
7sub run {
8    my $self = shift;
9
10    my $config = "$self->{project}::Config";
11    $config->use or die;
12
13    return unless $config->can('_new_instance');
14
15    my $dev = $self->_db($config->_new_instance->datasource);
16    local $ENV{SLEDGE_CONFIG_NAME} = '_product';
17    my $product = $self->_db($config->_new_instance->datasource);
18
19    print MySQL::Diff::diff_dbs({}, $product, $dev);
20}
21
22sub _db {
23    my ($self, $drv, $user, $pass) = @_;
24
25    my $db = ($drv =~ /^dbi:[^:]+:([^:;=]+)/) ? $1 : '';
26    my $host = ($drv =~ /hostname=([a-zA-Z_0-9.]+)/) ? $1 : '';
27
28    return MySQL::Database->new(
29        auth =>
30          { user => $user, password => $pass, host => $host },
31        db => $db,
32    );
33}
34
351;
36__END__
37
38=head1 NAME
39
40Archer::Plugin::MySQLDiff::Sledge - show the mysqldiff, with sledge's configuration class.
41
42=head1 SYNOPSIS
43
44  - module: MySQLDiff::Sledge
45
46=head1 DESCRIPTION
47
48=head1 AUTHORS
49
50Tokuhiro Matsuno.
51
52=cut
53
Note: See TracBrowser for help on using the browser.