Dan Friedman > Class-DBI-DataMigration-0.02 > Class::DBI::DataMigration::Synchronizer



Annotate this POD


New  1
Open  0
View/Report Bugs

Name ^


Synopsis ^

 use Class::DBI::DataMigration::Synchronizer;

 my $synch = Class::DBI::DataMigration::Synchronizer->new(
    search_criteria => \%search_criteria);
 my $synched_objects = $synch->synchronize;

Description ^

Class::DBI::DataMigration::Synchronizer - Keep records synchronized between source and target databases.

Methods ^


Class accessor/mutator for the directory in which our config.yaml can be found. This config.yaml will be used to build a Class::DBI::DataMigration::Migrator, which we will then use to synchronize the appropriate data. Defaults to './'.


Accessor/mutator for a hashref of hashes of search criteria to use, per table, to locate objects for migration between the source and target databases.

The hash should be keyed on source db CDBI class names, with hashrefs of key/value pairs to search for in each class as values; these latter key/value hashes will be used to search() each class. Classes whose values are empty hashes will have retrieve_all() called on them -- that is, *all* objects in that class will be migrated. For example:

    SourceClass1 => { 
        key1 => value1, 
        key2 => value2 
    },                                    # migrate objects in SourceClass1 that match
                                          # key1 => value1, key2 => value2

    SourceClass2 => {}                    # migrate all objects in SourceClass2


This constructor uses Getopt::Long to parse command-line arguments, producing a search_criteria hash suitable for use at synchronize() time.

 --table=class1,key1,value1,key2,value2... --table=class2,key3,value3... --table=class3...

The keys and values supplied for each --table argument will be used to search() the given class for objects to be migrated. If no keys/values are given, *all* objects in the class (i.e., all rows in the table) will be migrated. So, in the example above, the search_criteria hashref produced would be:

    class1 => {
        key1 => value1,
        key2 => value2

    class2 => {
        key3 => value3

    class3 => {}

Class/key/value lists must contain no spaces and be separated by commas, as in the example above.


Collect together all objects from the various CDBI classes matching our search_criteria; build a migrator for our class's config.yaml file and migrate the objects we've collected.

NB: our config.yaml file is expected to be found in config_path(), which defaults to ./.

Author ^

Dan Friedman, <lamech@cpan.org>

Copyright & License ^

Copyright 2004 Dan Friedman, All Rights Reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

Please note that these modules are not products of or supported by the employers of the various contributors to the code.

syntax highlighting: