我应该扁平化 Rails 迁移吗? [英] Should I flatten Rails migrations?

查看:29
本文介绍了我应该扁平化 Rails 迁移吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

可以将 db/migrate/* 替换为 db/schema.rb 的内容,这样您就只有一个迁移步骤.

It's possible to replace db/migrate/* with the contents of db/schema.rb, so that you only have one migration step.

你们中有人这样做过吗?为什么?

Do any of you ever do this? Why?

推荐答案

你为什么要这样做?如果您不想运行所有迁移,则可以运行 rake db:schema:load.迁移不仅(仅)用于初始化新数据库,还用于将其迁移到另一个版本.

Why would you want to do this? You could just run rake db:schema:load if you don't want to run all migrations. Migrations are used not (only) to initialize a new database, but to migrate it to another version.

这篇关于我应该扁平化 Rails 迁移吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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