一种“扁平化"的方法. Rails迁移? [英] Way to "flatten" Rails migrations?

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

问题描述

我现在正在部署我的第一个Rails应用程序,在此过程中的某个地方,我破坏了迁移.当我尝试将应用程序推送到生产服务器并运行rake db:migrate时,它在某处失败并出现错误.

I'm working on deploying my first Rails application right now, and somewhere along the way, I botched a migration. When I try to push my application to the production server and run rake db:migrate, it fails somewhere with an error.

现在,我方法太懒了,无法单独完成迁移工作以找出问题所在,因此,我尝试避免这样做.鉴于我当前的开发数据库运行良好,是否有办法将当前模式扁平化"为单个,全面的迁移?

Now, I am way too lazy to work through my migrations individually to find out what went wrong, so I'm trying to avoid doing that. Given that my current development database works just fine, is there a way to "flatten" the current schema into a single, comprehensive migration?

我知道这很草率,而且我知道我很可能一开始就愚蠢地打破了迁移链. (我可能直接在某个地方编辑了数据库架构,我现在理解这是一个不可以.)尽管这是一个很小的项目,并且我实际上是唯一参与其中的开发人员,所以我很乐意扫一扫这个问题.如果可能的话.

I understand that this is sloppy, and I understand that I likely did a dumb thing to break the migration chain in the first place. (I probably edited the database schema directly somewhere, which I now understand is a no-no.) This is a pretty small project though, and I'm essentially the only developer involved, so I'm comfortable sweeping this issue under the rug if possible.

有办法吗?

感谢您的专业知识.

推荐答案

这是db/schema.rb文件的作用.如果您在迁移中仅进行了结构更改,则可以运行rake db:schema:load而不是运行rake db:migrate来获取表的绝对结构.

This is what the db/schema.rb file is for. If you've only got structural changes in your migrations you will be able to run rake db:schema:load rather than running rake db:migrate to get the absolute structure for your tables.

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

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