Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

How to verify DBIx::Class::Schema::Versioned upgrade scripts.

by chrestomanci (Priest)
on Feb 10, 2014 at 17:00 UTC ( #1074276=perlquestion: print w/ replies, xml ) Need Help??
chrestomanci has asked for the wisdom of the Perl Monks concerning the following question:

Greetings wise brothers.

The project I am working on uses DBIx::Class::Schema::Versioned to version the MySQL schema of the database used by the application. Whenever a developer needs to change the schema, he increments the schema version, then runs a script that calls create_ddl_dir() on the schema object to write an SQL file containing the deployment statements. (See DBIx::Class::Storage::DBI

This part is reliable. The problem is the upgrade and downgrade scripts. These are written by hand by the developer, and we have been caught out several times with upgrade scripts that are buggy, don't work or are missing. I would like an automated test to trap mistakes in this area, so that humans don't have to.

I am aware that create_ddl_dir() can be called with both the old and new schema version in order to create an upgrade script, but I have found that to be unreliable, and in any case it does not help with downgrade scripts.

Is there a test script out there that solves this problem?

I had considered writing a test script that creates two databases at consecutive version numbers using Test::mysqld, and then upgrade one, and comparing that the overall outcome is the same. Has that wheel already been invented and published on CPAN?

Comment on How to verify DBIx::Class::Schema::Versioned upgrade scripts.
Download Code
Re: How to verify DBIx::Class::Schema::Versioned upgrade scripts.
by stonecolddevin (Vicar) on Feb 10, 2014 at 19:02 UTC

    I apologize for engaging in the far too often "use this instead" train of though, but jnap wrote DBIx::Class::Migration to mitigate a lot of the issues you run into with Versioned. If at all possible, maybe check Migration on out. It's newer and has better support, and should plug right into your existing schema.

    Three thousand years of beautiful tradition, from Moses to Sandy Koufax, you're god damn right I'm living in the fucking past

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (7)
As of 2014-12-28 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (181 votes), past polls