gpt4 book ai didi

mysql - rails : From local MySQL to Heroku

转载 作者:可可西里 更新时间:2023-11-01 07:02:54 25 4
gpt4 key购买 nike

我正在开发一个由 MySQL 数据库支持的本地主机应用程序。但是我想部署到 Heroku,我读过它是 PostGreSQL 的 bacekd。

这样做的最佳方式是什么?我想过在 Gemfile 中这样做:

group :development do
gem 'mysql2'
end

group :test do
gem 'pg'
end

但是,我该如何配置 database.yml?这是正确的做法吗?

最佳答案

此页面有一个示例配置:

Tutorial: Rails 3.2 with Ruby 1.9.3 on Heroku · RailsApps

该教程假定您在本地安装了 SQLite。如果你想要 MySQL,只需在你的 Gemfile 中使用

group :development, :test do
gem 'mysql2'
end
group :production do
gem 'pg'
end

But, how would I configure the database.yml

您无需进行任何特殊设置;一旦你推送,Heroku 就会为你生成它。

注意(from Heroku):

We highly recommend using PostgreSQL during development. Maintaining parity between your development and deployment environments prevents subtle bugs from being introduced because of differences between your environments.

本地 gem 注释(来自 the tutorial ):

Run bundle install --without production to update your gems. The flag --without production allows you to skip local installation of the pg gem; otherwise, you will have to install PostgreSQL locally (the pg gem won’t install if PostgreSQL is not installed).

关于mysql - rails : From local MySQL to Heroku,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9936884/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com