rails 项目中的 db/development_structure.sql 是什么? [英] What is db/development_structure.sql in a rails project?
问题描述
在我的 rails 应用程序(rails 2.3.4,ruby 1.8.7)的/db 文件夹中有一个 development_structure.sql,我不确定它到底是做什么的.
There is a development_structure.sql inside my /db folder of my rails application (rails 2.3.4, ruby 1.8.7) and I am not sure exactly what it does.
- 某些特定环境是否需要它?(我想我在某处读到它用于测试)
- 我需要将它添加到我的 git 存储库中吗?
推荐答案
您不应将其添加到您的 git 存储库中.
You should not add it to your git repository.
这是一个由 rails 在您运行迁移时自动创建的文件,您的 database.yml 配置为连接到 mysql 数据库.您可以将其视为 schema.rb 的替代方案
It is a file created automatically by rails when you run migrations with your database.yml configured to connect against a mysql database. You can view it as an alternative to schema.rb
我相信你可以通过在你的 environment.rb 中添加来强制 rails 创建它:
I believe you can force rails to create it by adding in your environment.rb:
config.active_record.schema_format = :sql
当存在此文件时,例如:
When present this file is used for example by:
rake db:test:clone_structure
编辑
Ruby On Rails 指南中的相关部分.http://guides.rubyonrails.org/migrations.html#schema-dumping-和你
Relevant section in Ruby On Rails Guides. http://guides.rubyonrails.org/migrations.html#schema-dumping-and-you
他们建议将其签入 wiki 上的源代码管理.
They recommend to check it into source control on the wiki.
我个人喜欢把它排除在外.我喜欢能够非常快速地运行所有迁移.这对我来说是个好兆头.如果迁移变慢,我觉得我不再完全控制我的环境.迁移缓慢通常意味着我的开发数据库中有很多数据,我感觉不对.
I personally like to keep it out of it. I like to be able to run all migrations very quickly. It is for me a good sign. If migrations become slow I feel like I am not in total control of my environment anymore. Slowness in migrations generally means I have a lot of data in my development database which I feel wrong.
然而,如今这似乎是个人品味的问题.跟随你的直觉.
However, It seems to be a matter of personal taste nowadays. Follow your instincts on this one.
这篇关于rails 项目中的 db/development_structure.sql 是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!