I have a small application written in Go that connects to a PostgreSQL database on another server, utilizing database/sql
and lib/pq
. When I start the application, it goes through and establishes that all the database tables and indexes exist. As part of this process, it issues a SET search_path TO preferredschema,public
command. Then, for the remainder of the database access, I do not have to specify the schema.
From what I've determined from debugging it, when database/sql
reconnects (no network is perfect), the application begins failing because the search path isn't set. Is there a way to specify commands that should be executed when it reconnects? I've searched for an event that might be able to be leveraged, but have come up empty so far.
Thanks!