Class::DBI::DataMigration Getting Your Data From There to Here #15

Step 3: Pass the data structure to Class::DBI::DataMigration::Migrator

Remember the bit about needing very little perl code?

use Class::DBI::DataMigration::Migrator;
use Legacy::DBI::Games;
use New::DBI::Game;

open YAML, 'config.yaml' or die $!;
my $migrator = new Class::DBI::DataMigration::Migrator(join '', <YAML>);

my @source_objects = Legacy::DBI::Games->retrieve_all;
my $target_objects = $migrator->migrate_objects(\@source_objs);

# Now, New::DBI::Game objects have been created in the target class 
# (i.e., a new row has been inserted in the target db for 
# each of the source db rows), and $target_objects is a reference 
# to a list of the newly-created target database objects.
Copyright © 2005 Dan Friedman (Powered by Spork)