誰か助けてもらえますか?heroku run db:migrate
?私はdev envの移行と一緒にherokuでdb:migrationを実行するのを忘れてしまった。私はそれらのcoulpleを作り、今私は以下のエラーを受信しています:PG :: UndefinedColumn:ERROR:relation "articles"の "image_file_name"列が存在しません
wozane:~/workspace (master) $ heroku run rake db:migrate
Running rake db:migrate on ⬢ wozane... up, run.7786
(0.8ms) SELECT pg_try_advisory_lock(96974639112725850);
ActiveRecord::SchemaMigration Load (1.1ms) SELECT "schema_migrations".* FROM "schema_migrations"
Migrating to RemoveColumnImage (20160917131520)
(0.7ms) BEGIN
== 20160917131520 RemoveColumnImage: migrating ================================
-- remove_column(:articles, :image_file_name, :string)
(1.5ms) ALTER TABLE "articles" DROP "image_file_name"
(0.7ms) ROLLBACK
(0.8ms) SELECT pg_advisory_unlock(96974639112725850)
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:
PG::UndefinedColumn: ERROR: column "image_file_name" of relation "articles" does not exist
: ALTER TABLE "articles" DROP "image_file_name"
場合は、この列は削除されており、それが存在しないことです。
class RemoveColumnImage < ActiveRecord::Migration[5.0]
def change
remove_column :articles, :image_file_name , :string
remove_column :articles, :image_content_type, :string
remove_column :articles, :image_file_size, :integer
remove_column :articles, :image_updated_at, :datetime
end
end
Schema.rbはそのようになります:
ActiveRecord::Schema.define(version: 20160921115118) do
create_table "articles", force: :cascade do |t|
t.string "title"
t.text "text"
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "img_url"
end
create_table "photos", force: :cascade do |t|
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
t.string "title"
t.string "img_url"
t.text "text"
end
end
私は#
への移行でコード全体を試み、それがなかった
移行は、エラーメッセージに(数20160917131520)を挙げます
rails db:environment:set RAILS_ENV=production
heroku run rake db:reset
heroku run rake db:migrate -app wozane
heroku pg:reset DATABASE --confirm wozane
Doと一緒に役立ちます私の場合、ヒロクの移行をどのように実行するか考えている人はいますか?
ありがとうございます。
あなたの記事のテーブルを実行しようとするには、削除しようとしている列のいずれかを持っていないようです。 –
マイグレーションを早めに削除しました。問題は、私がその時間に 'heroku run rake db:migrate 'をやっていないこと、そしてあまりにも多くの他の変更がその間に起こったということです。 – Wozane