Best way to export a database table to a YAML file?

后端 未结 11 1308
野的像风
野的像风 2020-12-07 14:54

I have some data in my development database that I would like to utilize as fixtures in my test environment. What is the best way in Rails 2.x to export a database table to

11条回答
  •  广开言路
    2020-12-07 15:24

    I have been using YamlDb to save the state of my database.

    Install it with the following command:

    script/plugin install git://github.com/adamwiggins/yaml_db.git 
    

    Use the rake task to dump the contents of Rails database to db/data.yml

    rake db:data:dump
    

    Use the rake task to load the contents of db/data.yml into the database

    rake db:data:load
    

    This is the creators homepage:

    http://blog.heroku.com/archives/2007/11/23/yamldb_for_databaseindependent_data_dumps/

提交回复
热议问题