2017-01-07 20 views
0

私は生産のための私のアプリケーションが準備されている、と私は私のデータベースを掻き集めるに苦しんでいます。それは私に、このエラーを与えている。ここでPG ::レール上UndefinedTable ERRORルビーHerokuの

PG::UndefinedTable: ERROR: relation "events" does not exist 
: ALTER TABLE "events" ADD "code" character varying 

は私のdatabase.ymlのファイルです:

class CreateEvents < ActiveRecord::Migration[5.0] 
    def change 
    create_table :events do |t| 
     t.string :name 
     t.string :partycode 
     t.references :user, foreign_key: true 

     t.timestamps 
    end 
    end 
end 

EDIT: Iここで

# SQLite version 3.x 
# gem install sqlite3 
# 
# Ensure the SQLite 3 gem is defined in your Gemfile 
# gem 'sqlite3' 
# 
default: &default 
    adapter: postgresql 
    pool: 5 
    timeout: 5000 

development: 
    <<: *default 
    database: db/development.sqlite3 

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

私のイベントの移行ファイルであります enter image description here :実行rake db:migrate:status私は、次のような結果を得ます最後に、ここに私のgemfileがあります:

source 'http://rubygems.org' 

    gem 'bootstrap-sass', '3.2.0.2' 

    gem 'bcrypt',   '3.1.11' 

    gem 'will_paginate' 

    gem 'responders' 

    gem 'rails', '~> 5.0.0', '>= 5.0.0.1' 

    gem 'puma', '~> 3.0' 

    gem 'sass-rails', '~> 5.0' 

    gem 'uglifier', '>= 1.3.0' 

    gem 'coffee-rails', '~> 4.2' 

    gem "heroku" 

    gem 'coffee-script-source', '1.8.0' 

    gem 'jquery-rails' 

    gem 'turbolinks', '~> 5' 

    gem 'jbuilder', '~> 2.5' 


    group :development, :test do 
     # Call 'byebug' anywhere in the code to stop execution and get a debugger console 
     gem 'sqlite3' 
     gem 'byebug', platform: :mri 
    end 

    group :production do 
     gem 'web-console' 
     gem 'pg' 
    end 

    gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 
    ruby "2.2.4" 

私が持っているこの問題を解決するために必要なものが他にもあります。ありがとう:D

答えて

1

見て、あなたのrake db:migrate:statusあなたはeventで変更を行っているが、そのためのテーブルが後で作成されているので、Create events移行後である必要があり、移行Add code to eventsある一つの問題があります。だから、これを修正し、あなたが何ができるか一時的な修正のためである必要があります。

rake db:migrate:up VERSION=20161219214142 

20161219214142はあなたのバージョンCreate Events移行であるので、これはあなたのための具体的な移行を実行すると、あなたがするならば、eventsテーブルを作成します。 rake db:migrateを実行すると正常に動作します。

+0

それでは、どのように私は、これら2の順序を変更するに行きますか?この@Aaron – Aaron

+0

は、移行シーケンスを変更するためにあなたhttp://stackoverflow.com/questions/10456761/rails-migration-change-sequence-or-orderを助けるかもしれません。一方、一時的な修正を試すことができます。 – Deep

+0

が魅力のように働いた、私は今、私の生産applicaitonを見ることができます – Aaron

関連する問題