DBICx::Backend::Move - Migrate an existing database to another backend
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 };
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.
new DBICx::Backend::Move::Psql
Execute the migration process.
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.
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).
Name of the DBIx::Class based schema description of the source database. Therefore, it also will be the schema for the destination database.
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.
Maik Hentsche, <Caldrin at cpan dot org>
<Caldrin at cpan dot org>
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.
bug-dbicx-migration at rt.cpan.org
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)
http://rt.cpan.org/NoAuth/Bugs.html?Dist=DBICx-Backend-Move
AnnoCPAN: Annotated CPAN documentation
http://annocpan.org/dist/DBICx-Backend-Move
CPAN Ratings
http://cpanratings.perl.org/d/DBICx-Backend-Move
Search CPAN
http://search.cpan.org/dist/DBICx-Backend-Move/
Thanks to
renormalist for discussinh design decisions
mst for explaining transaction handling in DBIC and DBI
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.
To install DBICx::Backend::Move, copy and paste the appropriate command in to your terminal.
cpanm
cpanm DBICx::Backend::Move
CPAN shell
perl -MCPAN -e shell install DBICx::Backend::Move
For more information on module installation, please visit the detailed CPAN module installation guide.