Rails databases, why use same DBMS for development and production?

扶醉桌前 提交于 2019-12-10 13:57:56

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/29743444/rails-databases-why-use-same-dbms-for-development-and-production

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!