Database dump and import

35 views
Skip to first unread message

braini...@gmail.com

unread,
Mar 9, 2019, 2:10:15 PM3/9/19
to Ruby on Rails: Talk
Hey Everyone,

I need to dump the data from a postgress database in Heroku to a mysql database in Heroku for the Ruby on Rails app that has been upgraded. Can anyone walk me through the process. Ideally I want to dump the data to my machine so there is an offline retention of the change as well. Please advise. 


Thanks,

Hasan Diwan

unread,
Mar 9, 2019, 2:16:57 PM3/9/19
to rubyonra...@googlegroups.com
Define 2 stanzas in database.yml. One for your postgres database, the second for your mysql. "bundle exec rails db:schema:dump RAILS_ENV=$POSTGRES_STANZA" will save the data and "bundle exec rails db:schema:load RAILS_ENV=$MYSQL_STANZA" will restore it to mysql. Let me know if you should require further assistance. -- H

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/9dcc62aa-fc44-486f-ac4d-10911cc4848a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
If you wish to request my time, please do so using bit.ly/hd1AppointmentRequest.
Si vous voudrais faire connnaisance, allez a bit.ly/hd1AppointmentRequest.

Sent from my mobile device
Envoye de mon portable

braini...@gmail.com

unread,
Mar 9, 2019, 2:31:00 PM3/9/19
to Ruby on Rails: Talk
Thank you Hassan brilliant. I may not have explained this well. What i want to do is dump it from the CLI locally and then import the data once it is validated for compliance purposes.

Hasan Diwan

unread,
Mar 9, 2019, 2:37:03 PM3/9/19
to rubyonra...@googlegroups.com
The first command will dump the data, then you can do your validations, and finally, the second will restore them. -- H


For more options, visit https://groups.google.com/d/optout.

braini...@gmail.com

unread,
Mar 9, 2019, 2:44:54 PM3/9/19
to Ruby on Rails: Talk
Thank you Hassan. 

Rob Jonson

unread,
Mar 10, 2019, 5:58:21 AM3/10/19
to Ruby on Rails: Talk
bundle exec rails db:schema:dump

does this dump the data, or just the schema?

I would assume just the schema - and that to transfer the data you'll need to use something like the solutions here:

Walter Lee Davis

unread,
Mar 10, 2019, 1:26:32 PM3/10/19
to rubyonra...@googlegroups.com
Just the schema. For the data, you'd need to run a backup utility of some sort. On MySQL, there's mysqldump, I'm pretty sure there's similar on the Postgres side, so no matter which direction you want to go, you'd be set. Be sure to only dump the data, not the structure, if you're using the schema:dump technique. Rails' database adapters are smart, and they can do the exact same structure with all the local weirdnesses that are required by the respective engines.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/5fcb6342-219a-41d8-882b-1ada28ffff8d%40googlegroups.com.

braini...@gmail.com

unread,
Mar 10, 2019, 1:37:05 PM3/10/19
to Ruby on Rails: Talk
Correct Walter. I have the data. I have to do a conversion and then it is all set.
Reply all
Reply to author
Forward
0 new messages