FlatFile::DataStore::Utils - a collection of utility routines for FlatFile::DataStore datastores.
VERSION: 1.03
Nothing is exported by default. The following may be exported individually; all of them may be exported using the :all tag:
:all
- migrate - migrate_nohist - validate - compare
Examples:
use FlatFile::DataStore::Utils qw( migrate migrate_nohist validate compare ); use FlatFile::DataStore::Utils qw( :all );
use FlatFile::DataStore::Utils qw( migrate migrate_nohist validate compare ); my $from_dir = '/from/dir'; my $from_name = 'ds1'; my $to_dir = '/to/dir'; my $to_name = 'ds2'; validate( $from_dir, $from_name ); migrate ( $from_dir, $from_name, $to_dir, $to_name ); validate( $to_dir, $to_name ); compare ( $from_dir, $from_name, $to_dir, $to_name ); # optionally, migrate_nohist() will not copy any history # or deleted records: validate( $from_dir, $from_name ); migrate_nohist ( $from_dir, $from_name, $to_dir, $to_name ); validate( $to_dir, $to_name ); # can't compare anything (yet) after a nohist migrate
This module provides
- validate(), to validate a datastore, checking that it can be traversed and that its past record data has not changed, and creating history and transaction files for comparison purposes.
- migrate(), to migrate a datastore to a new datastore. Use cases:
- The data has outgrown the datastore as originally configured - You want a better configuration than originally conceived
- migrate_nohist(), to migrate a datastore to a new datastore without any update history and without any deleted records. This is normally discouraged (since the spirit of the module is to retain all history of activity), but it has its uses.
- compare(), to compare the files that validate() creates for one datastore to the files that validate() creates for a second datastore (following a migrate(), most likely). If these files (history, transaction, md5) are exactly equal, then the two data stores are equivalent, i.e., they both contain exactly the same records, even though their data files, etc., may be very differently configured.
Descriptions and parameters for the exportable subroutines are detailed below.
The directory of the datastore.
The name of the datastore.
The directory of the datastore we're migrating from.
The name of the datastore we're migrating from.
The directory of the datastore we're migrating to.
The name of the datastore we're migrating to.
The uri of the datastore we're migrating to. If given, a new data store will be initialized. If this parameter is not given, it is assumed that the new datastore has already been initialized.
This routine will not keep any record history and will not migrate deleted records.
Intended for post-migration comparisons, this routine writes a "$dir/$name.nohist" data file where each line contains two integers. The first integer is the record sequence number from the from_ds, and the second is from the to_ds. Using these, it should be possible to compare the user data and record data md5 signature from both datastores to verify that the data was migrated completely.
from_ds
to_ds
This routine compares the files written by validate() for each of the datastores to verify that after migration, the second datastore contains exactly the same information as the first.
The directory of the datastore we migrated from.
The name of the datastore we migrated from.
The directory of the datastore we migrated to.
The name of the datastore we migrated to.
To install FlatFile::DataStore, copy and paste the appropriate command in to your terminal.
cpanm
cpanm FlatFile::DataStore
CPAN shell
perl -MCPAN -e shell install FlatFile::DataStore
For more information on module installation, please visit the detailed CPAN module installation guide.