Reputation: 46274
In Django, I run the following to dump the entire database to a json file:
django-admin.py dumpdata > data.json
What's the equivalent of the above in Rails 3.2.11? I've tried the following commands but they don't work:
rake db:data:dump_dir dir="my_dir"
rake db:fixtures:dump
The error message for the above is:
user:~/blog$ rake db:fixtures:dump
rake aborted!
Don't know how to build task 'db:fixtures:dump'
/home/user/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `eval'
/home/user/.rvm/gems/ruby-1.9.3-p362/bin/ruby_noexec_wrapper:14:in `<main>'
(See full trace by running task with --trace)
Upvotes: 2
Views: 3718
Reputation: 76976
You can try https://github.com/jetthoughts/yaml_db which is a fork of the original yaml_db https://github.com/adamwiggins/yaml_db
Upvotes: 2
Reputation: 3549
Rails has a schema dumping feature (rake db:schema:dump
), but no built in data dumping feature.
What database are you using? With MySQL, you can just do a mysqldump
.
Edit:
If you wanted to dump JSON data from one model (assuming it wasn't a ton of data), you could do:
MyModel.all.to_json
Upvotes: 1
Reputation: 14402
Based on the comments, this screencast is for you: #342 Migrating to PostgreSQL. It uses the taps gem.
Upvotes: 0