###Herokuを使いアプリをデプロイしようとしています。
ターミナル(Mac)にて
$ git push heroku master
コマンドが成功し、アプリのURLが取得できたのですが、本番環境でのマイグレーションを行おうと思い
$ heroku run rails db:migrate
コマンドを実行したところ、途中まで順調に走っていたのですが、途中でエラーが発生してしまいました。こちらの記事などを参考に、
$ heroku addons:add heroku-postgresql
も実行して、再度 $ heroku run rails db:migrate
をしても同じ結果で、エラーとなってしまいます。
ActiveRecord::StatementInvalid: PG::UndefinedTable: ERROR: relation "notified_bies" does not exist
とあるように、なにやらnotificationsテーブルで存在しないカラムがあるよと怒られています。
でもこのカラムは、自分でも覚えがありません。どうしてつくっていないカラムが「存在しない」と言われているか原因がわからないでいます。上記エラー文内に"relation"とあるので、もしかしたらmodelのリレーションの記述が適切でなく、こうなってしまっているのでしょうか。ですが開発環境ではこのような事は起こりませんでした。
今回のエラーの原因になっているテーブルに関係するマイグレーションファイルは以下のものです
○○○○○○_create_notifications.rb
class CreateNotifications < ActiveRecord::Migration[5.2] def change create_table :notifications do |t| t.references :user, index: true, foreign_key: true t.references :notified_by, index: true, foreign_key: true t.references :event, index: true, foreign_key: true t.string :type t.boolean :check, default: false t.timestamps end add_foreign_key :notifications, :users, column: :notified_by_id end end
○○○○○○_rename_type_column_to_notifications.rb
class RenameTypeColumnToNotifications < ActiveRecord::Migration[5.2] def change rename_column :notifications, :type, :notification_type end end
こちらがgithubのリンクです
githubで見る
ご指摘や、ご覧になりたい箇所のコード等ありましたら対応いたします。よろしくお願いいたします。
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2019/02/17 01:44