2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

heroku でdatabase mysql2 sequel proを使いたい

2
Posted at

herokuでgit push heroku masterするときに、dbと繋ぎたい。
初期ではherokuはPostgreSQLをしようする流れになっていたかと思いますが、今回はsequel proでdbを作りたいと思います。

ruby 2.5.1
rails 5.2.1
mac high sierra 10.13
production do
gem 'rails_12factor'
end

gemを入れますrails_12factor  ##これはもしかしたらいらなかったかも??

必要であればmysqlのgem versionを指定してあげるといいかも。(~> '0.0.1')みたいに。

config/environments/production.rb
config.assets.compile = true
追記。自分はfalseになってました。

heroku createとか実行

heroku addons:add cleardb
heroku config | grep CLEARDB_DATABASE_URL

実行すると、
mysql://b00000008:0000000e@us-00000000.cleardb.net/heroku_8000000003?reconnect=true
みたいなのが出てくると思います。

mysql://ユーザー名:パスワード@ホスト名/データベース?reconnect=true
の順番になっているので、メモ。

`heroku config:add DATABASE_URL='ここにメモしたものをmysql2にして貼り付け'
実行!!!

できなかったらごめんなさい。
一度、addons:detachを試してみてもいいかも。

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?