Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Rails-like database migrations

by mp (Deacon)
on Nov 11, 2008 at 20:27 UTC ( #722975=perlquestion: print w/ replies, xml ) Need Help??
mp has asked for the wisdom of the Perl Monks concerning the following question:

Are there any perl-based database migration systems similar to what is built into rails?

From what I understand, rails keeps a schema version number in a table in the database, then has a migration script which will determine which upgrade/downgrade scripts need to be run to bring the database from its current state to the desired state. The upgrade/downgrade scripts can be managed under revision control, thus providing a way to revision control the structure of the database.

I found the following CPAN modules: DBIx::Migration and DBIx::Migration::Directories, and old discussion OT: Ways of managing changes to a database's structure during a project., and some inquiries ActiveRecord migrations-type implementation in perl? and Interface suggestions. Is anyone else doing any active work in this area?

Comment on Rails-like database migrations
Re: Rails-like database migrations
by perrin (Chancellor) on Nov 11, 2008 at 20:33 UTC
    The upgrade infrastructure in the Krang CMS handles this.
Re: Rails-like database migrations
by stonecolddevin (Vicar) on Nov 11, 2008 at 20:49 UTC

    DBIx::Class::Schema::Versioned does something of this sort. Also, you can make all your changes in the database and then use DBIx::Class::Schema::Loader and use the make_schema_at method to upgrade your schema code.

    I do it like this:

    #!/usr/bin/perl ## this works fine for development ## but should probably add some production environment vars too use FindBin; use DBIx::Class::Schema::Loader qw| make_schema_at |; make_schema_at( "MyApp::Schema", { debug => 1, use_namespaces => 0, components => ["InflateColumn::DateTime"], dump_directory => "$FindBin::Bin/../lib" }, [ "dbi:mysql:dbname", "user", "pass" ] );

    Then call perl script/*update*

    meh.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://722975]
Approved by Corion
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2014-08-01 03:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (256 votes), past polls