This allows me to deploy the schema to a variety of databases easily, without worrying about inter-database SQL concerns.
In my unit tests, I create quite a lot of test databases.. PostgreSQL in particular is very noisy during this process, printing a LOT of "NOTICE" messages to the console. I wanted to quieten it down, so that actual test failures/warnings were more obvious.
If you'd like that too, try this in your MyApp::Schema class:
# If you use Moose:
before 'deploy' => sub {
my $schema = shift;
$schema->storage->dbh->do('SET client_min_messages = warning');
};
# If you don't use Moose:
sub deploy {
my $schema = shift;
$schema->storage->dbh->do('SET client_min_messages = warning');
$schema->next::method(@_);
}
No comments:
Post a Comment