将数据库表导出到 YAML 文件的最佳方法? [英] Best way to export a database table to a YAML file?

查看:37
本文介绍了将数据库表导出到 YAML 文件的最佳方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的开发数据库中有一些数据,我想将它们用作测试环境中的固定装置.Rails 2.x 中将数据库表导出到 YAML 设备的最佳方式是什么?

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 a YAML fixture?

推荐答案

为此有一个 rake 任务.如果需要,您可以指定 RAILS_ENV;默认为开发环境:

There is a rake task for this. You can specify RAILS_ENV if needed; the default is the development environment:

rake db:fixtures:dump
    # Create YAML test fixtures from data in an existing database.

这篇关于将数据库表导出到 YAML 文件的最佳方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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