症状
gitからアプリを新しいPCにpullして、Railsサーバーを起動してフロント側から動かそうとしたところ下記のエラーメッセージが表示されました。 翻訳すると、「移行は保留中です。この問題を解決するには、次のコマンドを実行します。rails db:migrate RAILS_ENV = development」になりました。error
ActiveRecord::PendingMigrationError (
Migrations are pending. To resolve this issue, run:
rails db:migrate RAILS_ENV=development
):
activerecord (6.0.4.1) lib/active_record/migration.rb:586:in `check_pending!'
activerecord (6.0.4.1) lib/active_record/migration.rb:564:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.4.1) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.4.1) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/actionable_exceptions.rb:18:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.4.1) lib/rails/rack/logger.rb:37:in `call_app'
railties (6.0.4.1) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.4.1) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.4.1) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.4.1) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.4.1) lib/rails/rack/logger.rb:26:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.3) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.4.1) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.3) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.4.1) lib/action_dispatch/middleware/host_authorization.rb:82:in `call'
rack-cors (1.1.1) lib/rack/cors.rb:100:in `call'
railties (6.0.4.1) lib/rails/engine.rb:527:in `call'
puma (4.3.8) lib/puma/configuration.rb:228:in `call'
puma (4.3.8) lib/puma/server.rb:718:in `handle_request'
puma (4.3.8) lib/puma/server.rb:472:in `process_client'
puma (4.3.8) lib/puma/server.rb:328:in `block in run'
puma (4.3.8) lib/puma/thread_pool.rb:134:in `block in spawn_thread'
解決策
メッセージ通りに「rails db:migrate RAILS_ENV=development」を実行したら、railsサーバーが正常に動作するようになりました。 なお、rails db:migrateだけだと、エラーが発生してしまいました。環境をしていしないと、railsさんも困ってしまうようです。fix
rails db:migrate RAILS_ENV=development