Error when run migrations on Heroku, PostgreSQL with Rails 5

后端 未结 3 966
北恋
北恋 2021-01-16 11:12

I deploy Rails 5 with PostgreSQL to free app in Heroku. This is my configuration from database.yml:

production:
  adapter: postgresql
  username         


        
相关标签:
3条回答
  • 2021-01-16 12:10

    It seems like database is not provided for your app, you need to add one:

    heroku addons:create heroku-postgresql
    

    You can verify the database was added to your application by running:

    heroku config --app your_app_name
    
    0 讨论(0)
  • 2021-01-16 12:11

    After delete old DB, you should execute this

    heroku pg:promote HEROKU_POSTGRESQL_NEW_DATABASE
    

    You can check your DB nickname by

    heroku pg:info
    
    0 讨论(0)
  • 2021-01-16 12:12

    Follow some steps in serial order,

    1. $ heroku login

    2. In Gemfile, add the pg gem to your Rails project. Change:

      gem sqlite

      to

      gem 'sqlite3', group: :development
      gem 'pg', '0.18.1', group: :production

    3. In Gemfile, add the rails_12factor gem::

      gem 'rails_12factor', group: :production

    4. $ bundle install

    5. Ensure config/database.yml is using the postgresql adapter. Change:

      production:
      <<: *default
      database: db/production.sqlite3
      to

      production:
      <<: *default
      adapter: postgresql
      database: db/production.sqlite3

    6. $ git add .
      $ git commit -m "Heroku config"
    7. $ heroku create
    8. $ git push heroku master
    9. $ heroku run rake db:migrate
      I hope it worked.

    SO FOLLOW STEP 5 correctly.

    0 讨论(0)
提交回复
热议问题