PG:错误:关系“admin_users”不存在

时间:2014-03-27 21:28:45

标签: postgresql heroku ruby-on-rails-4 activeadmin

我在尝试登录生产URL的admin / login部分后运行heroku logs时出现以下错误:

ActiveRecord::StatementInvalid (PG::UndefinedTable: ERROR:  relation “admin_users"  does not exist

我已经尝试过这个帖子:https://github.com/gregbell/active_admin/issues/753,特别是以下建议步骤(建议在“新安装”上执行,我不清楚这意味着什么!)

  1. rails g active_admin:devise

  2. rails g active_admin:install

  3. (如果由于#2414导致安装失败,请从路径文件中删除重复的ActiveAdmin.routes(self),然后运行rails g active_admin:assets) 删除add_devise_to_admin_users迁移文件

  4. rake db:migrate

    我已经完成了上述步骤,没有遵守“新安装”部分,但仍然遇到同样的错误。

  5. 以下是我的database.yml文件的副本:

    # SQLite version 3.x
    #   gem install sqlite3
    #
    #   Ensure the SQLite 3 gem is defined in your Gemfile  
    #   gem 'sqlite3'
    development:
      adapter: postgresql
      database: myapp_development
      pool: 5
      timeout: 5000
      password:
    
    # Warning: The database defined as "test" will be erased and
    # re-generated from your development database when you run "rake".
    # Do not set this db to the same as development or production.
    test:
      adapter: postgresql
      encoding: unicode
      database: myapp_test
      pool: 5
      timeout: 5000
      password:
    
    production:
      adapter: postgresql
      database: myapp_production
      username: 
      password: 
      pool: 5
      timeout: 5000
    

    这是我的Gemfile的副本

    source 'https://rubygems.org'
    ruby "2.1.1"
    
    gem 'rails', '4.0.4'
    
    
    
    gem 'sass-rails', '~> 4.0.2'
    
    
    gem 'uglifier', '>= 1.3.0'
    
    gem 'coffee-rails', '~> 4.0.0'
    
    gem 'jquery-rails'
    
    
    gem 'turbolinks'
    
    # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
    gem 'jbuilder', '~> 1.2'
    
    group :doc do
      # bundle exec rake doc:rails generates the API under doc/api.
      gem 'sdoc', require: false
    end
    
    
    gem 'activeadmin', github: 'gregbell/active_admin'
    
    group :production do
      gem 'pg'
      gem 'rails_12factor'
    end
    

1 个答案:

答案 0 :(得分:3)

通过git将代码推送到Heroku后,切换到项目根目录并运行:

$ heroku run rake db:migrate

这将在您的生产服务器上运行rake db:migrate