|
Revision 14975, 1.0 kB
(checked in by tokuhirom, 5 years ago)
|
|
i think, SQL::Translator is too slow.
|
| Line | |
|---|
| 1 | package Archer::Plugin::MySQLDiff::Sledge; |
|---|
| 2 | use strict; |
|---|
| 3 | use warnings; |
|---|
| 4 | use base qw/Archer::Plugin/; |
|---|
| 5 | use MySQL::Diff; |
|---|
| 6 | |
|---|
| 7 | sub 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 | |
|---|
| 22 | sub _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 | |
|---|
| 35 | 1; |
|---|
| 36 | __END__ |
|---|
| 37 | |
|---|
| 38 | =head1 NAME |
|---|
| 39 | |
|---|
| 40 | Archer::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 | |
|---|
| 50 | Tokuhiro Matsuno. |
|---|
| 51 | |
|---|
| 52 | =cut |
|---|
| 53 | |
|---|