Rails 4.0.1 on Heroku, can't create database

后端 未结 5 681
盖世英雄少女心
盖世英雄少女心 2020-12-24 14:40

I can\'t get rake db:migrate to run on my rails 4.0.1 app on Heroku.

I\'m guessing that I don\'t have postgres configured properly... but reading the docs on heroku

相关标签:
5条回答
  • 2020-12-24 15:03

    Run

    heroku pg:reset DATABASE_URL
    

    and you are done.

    0 讨论(0)
  • 2020-12-24 15:08

    I should've read the stack trace more closely. My factories.rb was creating user objects as attributes for other factories. Wrapping them in a block fixed it:

    FactoryGirl screws up rake db:migrate process

    0 讨论(0)
  • 2020-12-24 15:16

    I would first try

    heroku restart
    
    heroku rake db:migrate
    

    If that doesn't work, then try.

    heroku pg:reset DATABASE_URL   #Literally type in heroku pg:reset DATABASE_URL
    
    heroku rake db:migrate
    
    0 讨论(0)
  • 2020-12-24 15:17

    To drop and recreate database

    1. Login to heroku in terminal
    2. cd into your app
    3. Run

    heroku pg:reset DATABASE

    0 讨论(0)
  • 2020-12-24 15:18

    Jason's answer might fix your problem, but I wanted to expand on why you got the error and how to fix it.

    1. You can't run "rake db:setup" on Heroku, because it will try to create a database, and your database already exists on Heroku

    2. In your database.yml, you should read the database url from the environment variable like: production: url: <%= ENV["DATABASE_URL"] %>

    3. I think you are getting the 2nd error because you have some version error in your migrations, runing them from the begining should fix it : rake db:migrate VERSION=0

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