【问题标题】:Deploy Rails Application on Heroku : ERROR在 Heroku 上部署 Rails 应用程序:错误
【发布时间】:2020-05-15 14:38:28
【问题描述】:

我正在尝试执行 heroku run rake db:migrate,但结果如下: 耙中止! PG::Error: 错误:参数“client_encoding”的值无效:“utf8mb4”

我想在开发中使用 mysql 数据库,在生产中使用 postgres,这就是我配置 database.yml 的方式:

postgres: &postgres
  adapter: postgresql
  encoding: unicode
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
mysql: &mysql
  adapter: mysql2
  encoding: utf8mb4
  pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
  username: root
  password:
  socket: /var/run/mysqld/mysqld.sock
development:
  <<: *mysql
  database: event_development
test:
  <<: *mysql
  database: event_test
production:
  <<: *postgres
  database: event_production
  username: event
  password: <%= ENV['EVENT_DATABASE_PASSWORD'] %>

我该如何解决这个问题?

【问题讨论】:

    标签: mysql ruby-on-rails postgresql heroku


    【解决方案1】:

    只需使用 url 即可。如果你已经安装了“Heroku Postgres”插件。配置变量中应该有 DATABASE_URL。

    数据库.yml:

    ...
    production:
       url: <%= ENV['DATABASE_URL'] %>
    

    【讨论】:

      猜你喜欢
      • 2019-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-08-08
      • 2017-08-22
      相关资源
      最近更新 更多