You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using the schema tool to manage our Postgres DB schema at AppNexus for the AppNexus Exchange API. We ran into a slight issue because the way we set up our initial alters would CREATE DATABASE on the new DB we were creating (sadly Postrgres has no concept of IF NOT EXISTS for DB creation). For Postgres, schema init tries to connect to the DB you have listed in your config.json, and it fails if it can't connect. In the end we decided to remove the CREATE and DROP DB commands from the up/down files to make working with schema tool easier. This means that the DBAs must be informed to create your DB before running your initial alter in prod.
If this idea sounds alright, I would like to contribute a small update to the Readme for schema tool to advise users not to create / drop their DB in their initial alter for Postgres. Basically just some simple best practices to prevent users from shooting themselves in the foot like we did.
Long term, it might make sense to either have schema tool not error out on init if it can't connect to the DB, or else maybe have it create that DB if it doesn't exist. I'm not sure what implications that would have for the code though.
The text was updated successfully, but these errors were encountered:
We are using the schema tool to manage our Postgres DB schema at AppNexus for the AppNexus Exchange API. We ran into a slight issue because the way we set up our initial alters would
CREATE DATABASE
on the new DB we were creating (sadly Postrgres has no concept ofIF NOT EXISTS
for DB creation). For Postgres,schema init
tries to connect to the DB you have listed in yourconfig.json
, and it fails if it can't connect. In the end we decided to remove the CREATE and DROP DB commands from the up/down files to make working with schema tool easier. This means that the DBAs must be informed to create your DB before running your initial alter in prod.If this idea sounds alright, I would like to contribute a small update to the Readme for schema tool to advise users not to create / drop their DB in their initial alter for Postgres. Basically just some simple best practices to prevent users from shooting themselves in the foot like we did.
You can see the accompanying change I made to the DBA documentation here under
NOTE: if using PostgreSQL
: https://corpwiki.appnexus.com/display/engineering/How+to+Make+Database+Changes+as+a+DeveloperLong term, it might make sense to either have schema tool not error out on
init
if it can't connect to the DB, or else maybe have it create that DB if it doesn't exist. I'm not sure what implications that would have for the code though.The text was updated successfully, but these errors were encountered: