Rails - How to backup and restore the current status of the database easily
28 January 2012
Leave Comment
While I'm a huge fan of THIS method which I detailed in a prior post, that method is only helpfull for setting up tables with very few records.
I just recently found myself in a situation where I built a rails app that interfaced with a C# program which was designed to migrate a database up the rails website. This C# app takes a long time to compile the database into TCP, and rails takes a while loading up it's own database. Naturally, I wanted to do away with this down time throughout the development process. But there's no chance in hell you will be able to get me to fill in thousands of records by hand. The answer was to run my migration program once so it setup all the tables, and then dump those tables to a datafile.
The gem that allows for this is called db_yaml, and it does what the name implies, converts a database to yaml.
ref: https://github.com/ludicast/yaml_db
ref: http://stackoverflow...xtures-in-rails
(Gemfile)
My usage was
(save the current status of the database.)
(load up the database with the data last saved)
It looks like at the moment there is a bug against doing
...which would be more ideal for me, since I'd only like to save each table to an individual file within a directory... so yeah, bummer, but I don't mind. There was a bug in rails 3.0.7 which prevented it from functioning, but 3.0.8 is fine, and 3.0.9 is ideal but I gotta check that my webhost doesn't freak on me about these changes.
I just recently found myself in a situation where I built a rails app that interfaced with a C# program which was designed to migrate a database up the rails website. This C# app takes a long time to compile the database into TCP, and rails takes a while loading up it's own database. Naturally, I wanted to do away with this down time throughout the development process. But there's no chance in hell you will be able to get me to fill in thousands of records by hand. The answer was to run my migration program once so it setup all the tables, and then dump those tables to a datafile.
The gem that allows for this is called db_yaml, and it does what the name implies, converts a database to yaml.
ref: https://github.com/ludicast/yaml_db
ref: http://stackoverflow...xtures-in-rails
(Gemfile)
gem 'yaml_db'
My usage was
(save the current status of the database.)
$ rake db:data:dump
(load up the database with the data last saved)
$ rake db:data:load
It looks like at the moment there is a bug against doing
rake db:data:dump_dir
...which would be more ideal for me, since I'd only like to save each table to an individual file within a directory... so yeah, bummer, but I don't mind. There was a bug in rails 3.0.7 which prevented it from functioning, but 3.0.8 is fine, and 3.0.9 is ideal but I gotta check that my webhost doesn't freak on me about these changes.
0 Comments On This Entry
Trackbacks for this entry [ Trackback URL ]
← January 2022 →
| S | M | T | W | T | F | S |
|---|---|---|---|---|---|---|
| 1 | ||||||
| 2 | 3 | 4 | 5 | 6 | 7 | 8 |
| 9 | 10 | 11 | 12 | 13 | 14 | 15 |
| 16 | 17 | 18 | 19 | 20 | 21 | 22 |
| 23 | 24 | 25 | 26 | 27 | 28 | 29 |
| 30 | 31 |
Tags
My Blog Links
Recent Entries
-
-
Rails - Sending delete signals to rails with jQuery since it broke PROTOTYPE's delete linkson Feb 25 2012 08:56 AM
-
Rails - How to backup and restore the current status of the database easilyon Jan 28 2012 11:14 AM
-
-
Web Related - Most Potent Librarieson Sep 06 2011 02:32 PM
Recent Comments
-
NotarySojac on Aug 03 2011 02:50 PM
005 Rails: From Views to Models -- The flow of data from the user
Search My Blog
2 user(s) viewing
2 Guests
0 member(s)
0 anonymous member(s)
0 member(s)
0 anonymous member(s)












|