将 db 转储到 Rails 中的 yml 固定装置的标准方法是什么? [英] What is the standard way to dump db to yml fixtures in rails?

查看:23
本文介绍了将 db 转储到 Rails 中的 yml 固定装置的标准方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经看到一些插件和自定义 rake 任务将活动数据库转储到装置,但我不确定流行的技术是什么.

I've seen some plugins and custom rake tasks to dump the active db to fixtures, but I'm not sure what the prevailing technique is.

基本上,我想要 rake:db:fixtures:load 的反面,这样我就可以在部署时将基本的 db 信息(管理员用户帐户)放入 svn.我不想为需要很长时间的样本数据之类的东西手动创建夹具.

Basically, I want the opposite of rake:db:fixtures:load so that I can put basic db information (the admin user account, for one) into svn for when we deploy. I don't want to have to create fixtures manually for things like sample data that would take a long time.

当我们部署时,我希望能够运行

When we deploy I want to be able to just run

rake db:migrate
rake db:fixtures:load

然后去参加比赛.

在 Rails 中执行此操作的最佳/首选方法是什么?

What is the best/preferred method for doing this in rails?

因此似乎没有标准的方法来执行 db:fixtures:load 的相反 rake 任务.

So it seems there is no standard way to do an opposite rake task of db:fixtures:load.

我不想使用迁移,因为我想要为我的所有项目采用一种标准的方式来执行此操作,而且我不喜欢在迁移中放置比管理员帐户更多的内容的想法.其次,我一直在重新考虑使用灯具的想法.我决定使用 yaml_db 因为它使用 rake 任务:

I don't want to use migrations, because I want a standard way of doing this for all my projects, and I don't like the idea of putting any more than maybe the admin account in a migration. Second, I've been rethinking the idea of using the fixtures. I've decided on using yaml_db because it uses rake tasks:

rake db:data:dump
rake db:data:load

数据将在 YAML 文件中结束,而不会破坏测试装置(这可能会有所不同,现在我更仔细地考虑了这一点).此外,如果像 Heroku 这样的主要分发工具正在使用它,我不必担心支持/寿命问题.

The data will wind up in a YAML file without distrupting test fixtures (which could be different, now that I think about this more carefully). Also, if a major distribution tool like Heroku is using it, I don't have to worry about support/longevity issues.

我想这最接近我能找到的标准".

I suppose this is closest to "standard" that I will find.

感谢所有精彩的回复.

推荐答案

Heroku 使用 YamlDB Gem

Heroku uses the YamlDB Gem

http://www.github.com/ludicast/yaml_db/tree/master

这篇关于将 db 转储到 Rails 中的 yml 固定装置的标准方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆