从schema.rb生成迁移文件 [英] Generate a migration file from schema.rb
问题描述
我正在寻找从schema.rb生成一个迁移文件.是否有可能?
I'm looking to generate a migration file from the schema.rb. is it possible?
目前我有许多迁移文件,并希望将所有内容合并到一个主迁移文件中.
I have many migration files at the moment and would like to combine everything into one master migration file.
我还认为我有时可能不小心删除了迁移文件.
I also think i may have accidentally deleted a migration file at some point.
感谢您的帮助
推荐答案
不需要这样做.对于新安装,您应该运行rake db:schema:load
而不是rake db:migrate
,这会将架构加载到数据库中,比运行所有迁移要快.
There's no need to do this. For new installations you should be running rake db:schema:load
, not rake db:migrate
, this will load the schema into the database, which is faster than running all the migrations.
您永远不应删除迁移,并且绝对不能将它们合并在一起.对于意外删除的情况,您应该使用版本控制系统,例如 Git .
You should never delete migrations, and certainly not combine them. As for accidentally deleting one, you should be using a version control system, such as Git.
这篇关于从schema.rb生成迁移文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!