Reputation: 1829
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.
Upvotes: 1
Views: 824
Reputation: 1829
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
Upvotes: 1
Reputation: 207
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.
Upvotes: 2