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?

Replies are listed 'Best First'.
Re: How to verify DBIx::Class::Schema::Versioned upgrade scripts.
by stonecolddevin (Parson) 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