|Perl: the Markov chain saw|
How to verify DBIx::Class::Schema::Versioned upgrade scripts.by chrestomanci (Priest)
|on Feb 10, 2014 at 17:00 UTC||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?