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

查看:25
本文介绍了“扁平化"的方法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.

有没有办法做到这一点?

Is there a way to do that?

感谢您提供专业知识.

推荐答案

这就是 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天全站免登陆