Rails数据库,为什么要使用相同的DBMS进行开发和生产? [英] Rails databases, why use same DBMS for development and production?

查看:73
本文介绍了Rails数据库,为什么要使用相同的DBMS进行开发和生产?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于您为什么要在开发中和生产中使用相同的数据库,我似乎似乎找不到确切的解释。我个人喜欢在开发中使用sqlite3(它轻巧,易于使用,并且具有出色的sqlite浏览器GUI工具),然后在heroku中使用postgres进行生产。但是,我一直从RBates或Michael Hartl或其他人那里听到,您应该在两者中使用同一数据库,这到底是为什么呢?

解决方案

在我的前几个Rails项目中,我已经在开发中使用了SQLite3,在生产中使用了PostgreSQL。就在今天,我将当前项目的开发环境切换到了PostgreSQL。



当我第一次将应用程序部署到Heroku时,我花了两天的时间来纠正由于数据库迁移引起的错误。迁移在SQLite3中运行良好,但在PostgreSQL中中断。如果我使用过一个数据库,则可以避免这次调试。



今天早上,我试图使用一些SQL查询。如果仅使用rails查询,则可以不用切换数据库。当您开始编写SQL时,您开始发现问题。在此处查看我的问题和解决方案: Ruby strftime' %-m'不在查询中工作



如果我曾经使用strftime使原始SQL查询工作,那么它们将在生产中中断。 p>

通过创建匹配的开发和生产环境来避免将来的麻烦。


I really can't seem to find an accurate explanation on why you should use the same database in development as in production. I personally love using sqlite3 in development (it's light, easy to use, and has a sweet sqlite browser GUI tool), then use postgres in production with heroku. But, I keep hearing whether from RBates or Michael Hartl or someone else that you should use the same database in both, why exactly is this?

解决方案

I have used SQLite3 in development and PostgreSQL in production for my first few Rails projects. Just today I switched my current project's development environment over to PostgreSQL.

When I first deployed my app to Heroku, I spent two days correcting errors caused by database migrations. The migrations worked fine in SQLite3 but broke in PostgreSQL. If I had used one DB, I would have avoided this time debugging.

This morning I was trying to use some SQL queries. If you are only using rails queries, you can get away with switching DBs. When you start writing SQL, you begin to see the problems. Check out my question and the solution here: Ruby strftime '%-m' not working in query

If I had ever gotten my original SQL queries to work using strftime, they would have broke in production.

Save yourself the future headache by creating matching development and production environments.

这篇关于Rails数据库,为什么要使用相同的DBMS进行开发和生产?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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