4

I have created the test, production and development databases on server manually but not able to figure out, how to transfer data from local myapp_development database to myapp_production database on the server ?

I searched and found this How to move Rails app + pgsql database from localhost to my server?, capistrano is giving me lot of errors and I am sure there must be a standard Rails way or postgres way to do this as exporting data as dump and again importing it though I may have to do it if I can't find anything better.

2 Answers 2

4

You can dump the database using pg_dump then scp the database dump up to the database and run it on the server using psql databse_name < database.dump

Sign up to request clarification or add additional context in comments.

Comments

1

I use yaml_db gem. It can dump your data into a file and then load it back into the database. It's written using activerecord so it works with most databases.

URL: https://github.com/ludicast/yaml_db

rake db:data:dump   ->   Dump contents of Rails database to db/data.yml
rake db:data:load   ->   Load contents of db/data.yml into the database

Prefix the commands with RAILS_ENV=development or RAILS_ENV=production to choose target and destination scheme.

2 Comments

Boris, it looks good but from the yaml_db page - "Users, permissions, schemas, triggers, and other advanced database features are not supported - by design." , well I do need the users data to be exported
You want to export PostgreSQL users? Aren't you use just one PostgreSQL user to access your schema?Also I would recommend to give the production user different password, so that no development script can accidently be run against production database.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.