herokuにrailsappをデプロイしたのですが途中までのmigrationファイルしか反映されず、DBのschemeがうまく動きません。こういった時どうやって全部反映させればいいかだれか教えてもらえると助かります。
scheme
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20171007030215) do create_table "comments", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "comment" t.integer "user_id" t.integer "post_id" end create_table "posts", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.text "content" t.integer "user_id" t.text "location" t.integer "gender" t.text "line_id" end create_table "users", force: :cascade do |t| t.datetime "created_at", null: false t.datetime "updated_at", null: false t.integer "icon_id" t.integer "icon_back_id" end end
反映されていないもの
class RenameSexColumnToGender < ActiveRecord::Migration[5.1] def change rename_column :posts, :sex, :gender end end
class CreateComments < ActiveRecord::Migration[5.1] def change create_table :comments do |t| t.timestamps end end end
class Comments < ActiveRecord::Migration[5.1] def change add_column :comments, :comment, :text add_column :comments, :user_id, :integer add_column :comments, :post_id, :integer end end
単純なところから: コミット漏れではありませんか?
返信ありがとうございます!全部コミットしています(泣)
heroku logs など、ログは確認されましたか? なにかエラーメッセージは見当たりませんか?
2017-10-29T08:39:35.455183+00:00 heroku[run.2159]: Awaiting client 2017-10-29T08:39:35.484930+00:00 heroku[run.2159]: Starting process with command `bundle exec rake db:migrate` 2017-10-29T08:39:35.669319+00:00 heroku[run.2159]: State changed from starting to up 2017-10-29T08:39:42.425116+00:00 heroku[run.2159]: State changed from up to complete 2017-10-29T08:39:42.410939+00:00 heroku[run.2159]: Process exited with status 1
こういったlogがでてきたのですがmigrate自体はうまくできていそうかなと。。。
詳しくはわかりませんが: 正常終了であれば プロセスの終了状態は1ではなく 0で終わるハズです、より前後に広範囲のログを確認する必要があるかもしれません
なるほど。ありがとうございます。logにあまりそれらしいのが見当たらない。。。git cloneでコードを取ってきたんですがコード自体はちゃんとあったのでpushでコードが上手く遅れてないわけではなさそう。heroku側で途中からマイグレーションファイルを反映できないってあるんですかねえ?
一番上のmigrationファイルは、クラス定義がないようですがこれは質問を書くときになくなってしまっただけで、実際のファイルにはあるということですよね?
すみません、そうですね、間違えてクラス定義が書かれていないだけです。修正しました。
migrationファイルは途中から書き換えたわけではないですよね?例えばmigrationファイルを一度作成して、rails db:migrateしてその後に再度編集してデプロイしようとしてるとか。。。
途中で書き換えてしまっています!
あなたの回答
tips
プレビュー