Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs: Postgres DB best practices #78

Open
chrisdopuch opened this issue Mar 29, 2017 · 1 comment
Open

Docs: Postgres DB best practices #78

chrisdopuch opened this issue Mar 29, 2017 · 1 comment

Comments

@chrisdopuch
Copy link

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.

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+Developer

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.

@JohnMurray
Copy link
Contributor

Hey @chrisdopuch. Yeah, I know this is a current limitation of the tool. Feel free to open a PR to update the readme.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants