[Dbix-class] DBIC usage smoke/sanity check

Bill Moseley moseley at hank.org
Sat Dec 15 18:05:07 GMT 2012

I've been asked to add something to our build process that does some kind
of sanity check on the database.   For example, make sure all columns
defined in the result class exist in the target database.

I realize this won't catch every potential problem, but should catch
missing columns (or tables) which is our biggest risk.

This seems like a reasonable way to do this?

for my $source_name ( $schema->sources ) {

    my $source =3D $schema->source( $source_name );

    if ( $source->isa( 'DBIx::Class::ResultSource::View' ) ) {
        warn "Skipping view $source_name\n";

    try {
        $source->resultset->search(undef, {
            where =3D> \'TRUE =3D FALSE',
    catch {
        warn "Error in source [$source_name]:\n $_\n";

-- =

Bill Moseley
moseley at hank.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/dbix-class/attachments/20121215/d06=

More information about the DBIx-Class mailing list