NAME
DBICx::Backend::Move - Migrate an existing database to another backend
SYNOPSIS
use DBICx::Backend::Move::Psql;
use Try::Tiny;
my $connect_from = [ 'dbi:mysql:dbname=mydb', 'mysql_user', 'mysql_password' ];
my $connect_to = [ 'dbi::pg::dbname=mydb' , 'psql_user' , 'psql_password' ];
my $schema = 'My::Schema';
my $verbose = 1;
my $migrator = DBICx::Backend::Move::Psql->new()
try {
$migrator->migrate( $connect_from, $connect_to, $schema, $opt)
} catch {
... # handle error
};
DESCRIPTION
When you use DBIx::Class to work with your database, migrating it from one backend to another should be really easy. Turns out it is not. This module offers a turn-key solution to the problem. Create an object of the DBICx::Migration subclass that contains the type of the destination database in the name. For example if you want to migrate from MySQL to PostgreSQL you use new DBICx::Backend::Move::Psql
. Currently, Psql and SQLite are supported. If you want it even more easy, there is an application that uses DBICx::Backend::Move. Have a look at App::DBICx::Backend::Move.
SUBROUTINES
migrate
Execute the migration process.
- connect_from
-
This argument is an array ref containing DSN, username, password and an optional option hash. It will be passed to DBIx::Class::Schema->connect. For more information see "connect_info" in DBIx::Class::Storage::DBI. The array should contain all information to connect to the source database.
- connect_to
-
This argument is an array ref containing DSN, username, password and an optional option hash. It will be passed to DBIx::Class::Schema->connect. For more information see "connect_info" in DBIx::Class::Storage::DBI. The array should contain all information to connect to the destination database. The destination needs to exist and be empty (i.e. contain no tables).
- schema_name
-
Name of the DBIx::Class based schema description of the source database. Therefore, it also will be the schema for the destination database.
- verbose
-
Print the name of the table the tool is currently working on and a dot for every row.
In case of an error the function will throw an exception.
AUTHOR
Maik Hentsche, <Caldrin at cpan dot org>
BUGS
Please report any bugs or feature requests to bug-dbicx-migration at rt.cpan.org
, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=DBICx-Backend-Move. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
SUPPORT
You can find documentation for this module with the perldoc command.
perldoc DBICx::Backend::Move
You can also look for information at:
RT: CPAN's request tracker (report bugs here)
AnnoCPAN: Annotated CPAN documentation
CPAN Ratings
Search CPAN
ACKNOWLEDGEMENTS
Thanks to
renormalist for discussinh design decisions
mst for explaining transaction handling in DBIC and DBI
LICENSE AND COPYRIGHT
Copyright 2012 Maik Hentsche.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.