ruby-on-rails – Heroku上的Rails 4.0.1无法创建数据库

前端之家收集整理的这篇文章主要介绍了ruby-on-rails – Heroku上的Rails 4.0.1无法创建数据库前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我不能得到rake db:迁移到我的rails 4.0.1应用程序在Heroku上运行.

我猜,我没有正确配置postgres …但阅读英文的文档没有真正的帮助,我不知道该怎么做.我不太了解heroku或postgres.

任何帮助或资源将不胜感激.让我知道,如果还有什么我可以发布.

(另外,我正在使用设计,如果重要)

当我运行heroku运行rake db:migrate我得到这个:

Running `rake db:migrate` attached to terminal... up,run.5077
PG::UndefinedTable: ERROR:  relation "users" does not exist
LINE 5:                WHERE a.attrelid = '"users"'::regclass
                                      ^
:               SELECT a.attname,format_type(a.atttypid,a.atttypmod),pg_get_expr(d.adbin,d.adrelid),a.attnotnull,a.atttypid,a.atttypmod
            FROM pg_attribute a LEFT JOIN pg_attrdef d
              ON a.attrelid = d.adrelid AND a.attnum = d.adnum
           WHERE a.attrelid = '"users"'::regclass
             AND a.attnum > 0 AND NOT a.attisdropped
           ORDER BY a.attnum

rake aborted!
PG::UndefinedTable: ERROR:  relation "users" does not exist
LINE 5:                WHERE a.attrelid = '"users"'::regclass
                                      ^
:               SELECT a.attname,a.atttypmod
            FROM pg_attribute a LEFT JOIN pg_attrdef d
              ON a.attrelid = d.adrelid AND a.attnum = d.adnum
           WHERE a.attrelid = '"users"'::regclass
             AND a.attnum > 0 AND NOT a.attisdropped
           ORDER BY a.attnum

当我运行heroku运行rake db:设置我得到这个:

FATAL:  permission denied for database "postgres"
DETAIL:  User does not have CONNECT privilege.

... stack trace ...

Couldn't create database for {"adapter"=>"postgresql","username"=>"aqofwrwjifcqkx","password"=>"7yqDAx1L_4HFhw7WV3PH7ZrKyM","port"=>5432,"database"=>"d5dvi0pjk7dgr7","host"=>"ec2-23-21-94-137.compute-1.amazonaws.com"}

其后跟相同的PG :: UndefinedTable ERROR关系’users’不存在

database.yml:

development:
  adapter: sqlite3
  encoding: unicode
  database: chore_app_development
  pool: 5

test:
  adapter: sqlite3
  encoding: unicode
  database: chore_app_test
  pool: 5

production:
  adapter: postgresql
  database: chore_app_production
  pool: 5
  timeout: 5000

的Gemfile:

source 'https://rubygems.org'
ruby '2.0.0'

gem 'rails','4.0.1'

# Database
group :production do
  gem 'pg'
end

group :development,:test do
  gem 'sqlite3'
end

# Assets
gem 'sass-rails','~> 4.0.0'
gem 'uglifier','>= 1.3.0'
gem 'turbolinks'
gem 'haml-rails'
gem 'jquery-rails'

# Heroku
gem 'rails_12factor',group: :production

# Application
gem 'devise'
gem 'formtastic'

# Testing
gem 'factory_girl_rails'

解决方法

我会先试试
heroku restart

heroku rake db:migrate

如果不行,那就试试.

heroku pg:reset DATABASE_URL   #Literally type in heroku pg:reset DATABASE_URL

heroku rake db:migrate
原文链接:https://www.f2er.com/ruby/272110.html

猜你在找的Ruby相关文章