# Some tips to pull and push a database with Heroku
Some tips to improve test flow dealing with database on local and production environments.
It is really usefull if you want to fill your local database with real data from production environment.
rake db:drop
General Command
heroku pg:pull DATABASE_URL local_database_name --app app_name
For QuincenaMe use the line below:
heroku pg:pull DATABASE_URL quincename_development --app quincename
Setup test database locally
rake db:test:prepare
HINT: If you want to setup some alias in the terminal, you can type the commands below:
$ alias get_production_database="heroku pg:pull DATABASE_URL quincename_development --app quincename; rake db:test:prepare"
Now you can run get_production_database
in the terminal and magic will happen.
I use this specially when I want to fill a temporary app within the pipeline in order to test feature or fixes with real data.
heroku pg:reset DATABASE_URL --app pipeline_app_name
You must to consider if you want to push a database to a heroku application you will need the database locally and reset the database in the production environment:
heroku pg:push database_name DATABASE_URL --app pipeline_app_name
I build the post based on this Heroku documentation