More information about the Underscore mailing list

[_] Advice on migrating from Mysql to Pgsql

amias something at amias.org.uk
Thu Jan 10 16:00:02 GMT 2008

On Thu, 2008-01-10 at 14:58 +0000, Derek Almond wrote:
> >> 
> >> An now in true underscore style , the sanctimonious "of course that
> >> doesn't effect me" bit ....
> >> 
> >> For what its worth i use Perl Catalyst with Class::DBIx which is
> >> database neutral because it abstracts all the SQL and gives you yummy
> >> objects to do all the queries and all the smugness you can eat.
> 
> But surely that does affect you if you want to port your DB from one format
> to another - its not about where your code can reach, its about where your
> data is right now.

Its not completely automated , you do have to edit a few things but its
minimal stuff and more importantly the code implementing the business
logic doesn't change. You could also run your unit tests just to be
sure.

> I suppose you could use two db objects, one for each db type and copy the
> data across that's way - might work for simple cases... you'd still need to
> sort out the schemas though, so its not really a win since apart from the
> quoting differences you can import a SQL dump  from mysql to postgres if its
> only simple data.

Thats what SQL::Translator does .
http://search.cpan.org/~jrobinson/SQL-Translator-0.08001/lib/SQL/Translator.pm

Once the definition is ported you just change the login details in the
schema module to point to the new copy. the rest just works because the
other objects take care of translating your SQL::Abstract structures to
valid SQL for the given backend.

Toodle-perl
Amias

-- 
 Freelance programming , consultancy and hardware builds
blog.amias.org.uk * www.amias.org.uk * www.ecotalk.org.uk