rake db:migrate到底是做什么的? [英] exactly what does rake db:migrate do?

查看:110
本文介绍了rake db:migrate到底是做什么的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

rake db:migrate是仅添加新的迁移,还是删除所有迁移/更改并构建所有新内容?

Does rake db:migrate only add new migrations, or does it drop all migrations/changes and build everything new?

我认为rake引发了错误,因为它试图访问迁移040中已删除在迁移042中的表属性.不知何故,我的数据库和rake不同步,我想修复它们.

I think rake is throwing an error because it is trying to access a table attribute in migration 040 that was deleted in migration 042. somehow my DB and rake are out of synch and I want to fix them.

对于您在那里的专家-rake与迁移不同步是常见的吗?如何避免这种情况(不,我不手动编辑架构或rake文件).

for you experts out there - is it common for rake to get out of synch with migrations? how can I avoid this (no, I do not hand-edit my schema or rake files).

推荐答案

每次使用脚本(例如脚本/生成模型...)创建迁移时,都会将新迁移添加到正确的目录中,以便与真实目录同步数据库.

Everytime you create a migration using scripts (like script/generate model ...) a new migration is added to the correct directory ready to be synched with the real database.

实际上rake db:migrate只是检查哪些丢失的迁移仍需要应用到数据库,而无需关心先前的迁移.

Actually rake db:migrate just checks which missing migrations still need to be applied to the database without caring about the previouse ones.

当然,如果使用其他方式修改数据库通常会导致数据不同步,因为正如您所说的,您会发现自己将迁移应用到了下面发生更改的内容上.

Of course if you modify the database using other ways is common to obtain out-of-synch things because as you said you can find yourself applying a migration to something that is changed underneath.

这篇关于rake db:migrate到底是做什么的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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