brendanebers / wheresbrendan

0 stars 1 forks source link

Create tool for copying main database to local db #13

Open brendanebers opened 9 years ago

brendanebers commented 9 years ago

Instead of directly playing with the production db, we should probably develop off of a local one.

organicveggie commented 9 years ago

Brendan, does the production DB exist? Have you already applied migrations to it?

organicveggie commented 9 years ago

I will probably clean things up so we can have either multiple db manage scripts or at least more configurable manage scripts. That way we can easily support running migrations both locally and remotely. For example, I have both a local PostgreSQL instance for development and a Pgsql instance running on Heroku for testing. Plus you have your copies as well...

organicveggie commented 9 years ago

Also, it would make life easier going forward to have some consistency in database conventions. What are you currently calling your database? And what is the name of the primary database username?

organicveggie commented 9 years ago

So, I'm not sure if it's worth writing a script for this. You can use the pg_dump tool to extract the schema and data from one database and load it into another database:

pg_dump -h mydb.com -p 5432 -d wheres -U wheres_admin -T migrate_version \
| psql -h localhost -d wheres_local -U wheres_local
organicveggie commented 9 years ago

I could still create something if you really want it. But I can't test Windows batch files...

brendanebers commented 9 years ago

Because I'm lazy and prefer doing-it-live against a real database, I'm going to unassign this one