After connection you can do simple commands thanks to the on_connect_do
connection setting. One thing I sometimes do is turn down the whining. Postgres can be quite noisy when you’re creating tables,
NOTICE: CREATE TABLE / PRIMARY KEY will create implicit index "blah_pkey" for table "blah" NOTICE: CREATE TABLE will create implicit sequence "blah_id_seq" for serial column "blah.id" ...
So I sometimes SET client_min_messages=WARNING
at connection. That makes deploying a schema a lot less verbal.
If you want to deploy to a different schema within a database you can also do a ‘SET search_path TO
’ statement at that point too. That can be quite handy if you want to deploy the same tables again to an alternative schema within a database.
perl -I lib -MMyModule::Schema::DB -e "MyModule::Schema::DB->connect('dbi:Pg:dbname=database;host=postgres', 'username', 'password', { on_connect_do => 'SET search_path TO temp' })->deploy"
If you’re setting up a Catalyst config for DBIC you can set the connection options like this,
<Model::MyDB> connect_info dbi:Pg:dbname=database connect_info username connect_info password <connect_info> on_connect_do [ SET client_min_messages=WARNING ] quote_names 1 ...