1

I have an existing database on my server containing many tables with content. Now I have created a new database but some columns are added.

Is it possible to migrate all the data from the one database to the other.

Kind regards.

2 Answers 2

2

I've used the yaml_db gem to migrate DBs: https://github.com/ludicast/yaml_db - this gem adds some rake tasks that are helpful

After installing the gem, you can run rake db:data:dump to save your database to a .yml file.

Then, after changing your database configuration, you can run rake db:data:load to load the data into your new database.

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

Comments

1

I like your answer! But a more easy way is to dump the whole database like you said. But just transfer it to another server.

Like this:

To Dump:

pg_dump -U demo02 -h localhost -O demo02 > demo2.sql

To Restore:

psql -U demo3 demo3 < demo2.sql

1 Comment

This was very helpful, although a little confusing using the same text for the username and database name. pg_dump -U ADMINUSER1 -h localhost -O DBASENAME > dump.sql and psql -U ADMINUSER2 DBASENAME < dump.sql

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.