Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/60.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails Ruby on Rails-PendingMigrationError?_Ruby On Rails_Ruby_Puma - Fatal编程技术网

Ruby on rails Ruby on Rails-PendingMigrationError?

Ruby on rails Ruby on Rails-PendingMigrationError?,ruby-on-rails,ruby,puma,Ruby On Rails,Ruby,Puma,我刚刚开始一个使用RoR构建的现有项目,这对我来说是全新的 为了稍微领先一点,我尝试使用rails s启动项目,但在浏览器中出现以下错误: ActiveRecord::PendingMigrationError Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development 当我运行这个命令时,我在控制台中得到以下信息,但是浏览器只是刷新回相同的错误 ansi: '

我刚刚开始一个使用RoR构建的现有项目,这对我来说是全新的

为了稍微领先一点,我尝试使用rails s启动项目,但在浏览器中出现以下错误:

ActiveRecord::PendingMigrationError 

Migrations are pending. To resolve this issue, run: bin/rails db:migrate RAILS_ENV=development
当我运行这个命令时,我在控制台中得到以下信息,但是浏览器只是刷新回相同的错误

ansi: 'gem install win32console' to use color on Windows
=> Booting Puma
=> Rails 5.0.0.1 application starting in development on http://localhost:3000
=> Run `rails server -h` for more startup options
  Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?
  Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?
*** SIGUSR2 not implemented, signal based restart unavailable!
*** SIGUSR1 not implemented, signal based restart unavailable!
*** SIGHUP not implemented, signal based logs reopening unavailable!
Puma starting in single mode...
* Version 3.6.0 (ruby 2.3.3-p222), codename: Sleepy Sunday Serenity
* Min threads: 0, max threads: 16
* Environment: development
* Listening on tcp://localhost:3000
Use Ctrl-C to stop

ActiveRecord::PendingMigrationError (

Migrations are pending. To resolve this issue, run:

        bin/rails db:migrate RAILS_ENV=development

):

activerecord (5.0.0.1) lib/active_record/migration.rb:572:in `check_pending!'
activerecord (5.0.0.1) lib/active_record/migration.rb:548:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.0.1) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.0.1) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
bugsnag (5.1.0) lib/bugsnag/rack.rb:34:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
web-console (3.3.1) lib/web_console/middleware.rb:131:in `call_app'
web-console (3.3.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.3.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.0.1) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `block in tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.0.1) lib/active_support/tagged_logging.rb:70:in `tagged'
railties (5.0.0.1) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
request_store (1.4.0) lib/request_store/middleware.rb:19:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.1) lib/rack/method_override.rb:22:in `call'
rack (2.0.1) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.0.1) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.0.1) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.1) lib/rack/sendfile.rb:111:in `call'
rack-cors (0.4.0) lib/rack/cors.rb:80:in `call'
railties (5.0.0.1) lib/rails/engine.rb:522:in `call'
puma (3.6.0) lib/puma/configuration.rb:225:in `call'
puma (3.6.0) lib/puma/server.rb:578:in `handle_request'
puma (3.6.0) lib/puma/server.rb:415:in `process_client'
puma (3.6.0) lib/puma/server.rb:275:in `block in run'
puma (3.6.0) lib/puma/thread_pool.rb:116:in `block in spawn_thread'
如果我运行rails db:migrate rails\u ENV=development命令,我会得到以下结果,但我无法识别:

ansi: 'gem install win32console' to use color on Windows
  Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?
  Please add the following to your Gemfile to avoid polling for changes:
    gem 'wdm', '>= 0.1.0' if Gem.win_platform?
== 20161205141923 AddLastSeenAtToUsers: migrating =============================
-- add_column(:users, :last_seen_at, :datetime)
   -> 0.0020s
rake aborted!
StandardError: An error has occurred, this and all later migrations canceled:

PG::UndefinedColumn: ERROR:  column users.deleted_at does not exist
LINE 1: SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS ...
                                            ^
: SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL
C:/projectName/db/migrate/20161205141923_add_last_seen_at_to_users.rb:5:in `change'
ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column users.deleted_at does not exist
LINE 1: SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS ...
                                            ^
: SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS NULL
C:/projectName/db/migrate/20161205141923_add_last_seen_at_to_users.rb:5:in `change'
PG::UndefinedColumn: ERROR:  column users.deleted_at does not exist
LINE 1: SELECT "users".* FROM "users" WHERE "users"."deleted_at" IS ...
                                            ^
C:/projectName/db/migrate/20161205141923_add_last_seen_at_to_users.rb:5:in `change'
Tasks: TOP => db:migrate
(See full trace by running task with --trace)
正如我所说,我对RoR是新手,所以我不确定到底出了什么问题,发生了什么,或者——很明显——如何修复它

我试过用谷歌搜索它,但我能找到的只是rake db:drop/create/migrate,这没有任何帮助

有人想知道发生了什么事吗


谢谢,

您需要运行迁移,以便schema.rb中的时间戳等于上次迁移的时间戳

如果数据库已设置,请运行命令rake db:migrate

否则,

rakedb:创建数据库 rake db:migrate运行所有迁移 rake db:seeds.rb文件中的种子加载数据


在设置数据库和执行迁移之前运行bundle install,以安装运行项目所需的所有gem。

根据您的迁移错误,在db/migrations中找到的20161205141923_add_last_seen___at_to_users.rb迁移中,您需要添加添加列:users,:deleted_at,:datetime位于def change或def up下方,具体取决于您的Rails版本


此列可能也是在以后的迁移中创建的,因此您需要查看添加此行后它在何处/是否中断

rake db:migrate:status返回什么?@JoshBrody我不愿意粘贴结果,因为这不是我的项目,但它是一个包含大约60个up/down status、migration ID和migration name的表。如果您不介意我问的话,这是什么?正如控制台输出中给出的,迁移是挂起的。要解决这个问题,请运行:bin/rails db:migrate rails_ENV=development:@marmeladze正如我在问题中所说的,我已经尝试过这个,但没有进一步的尝试happened@RichardKeMiKaLGeNeRaLDenton这只是迁移及其状态的列表。发布它们真的没什么害处。我们正在寻找一个说向下而不是向上的;尝试rake db:migrate:status | grep upI以前尝试过db:drop/create/migrate,但没有遇到seed,尝试过它,但它提供的输出与运行rails db:migrate rails_ENV=development相同,如我的问题所示。我认为您需要设置gems。我有一种感觉,ParanoiaGem被用来在用户模型的字段中设置删除的_。在通过bundle安装安装gems并遵循gem的说明(通过gem添加已删除的_at)之后,请再次尝试运行迁移。啊,好的,现在我可能有进展了!我尝试按照您指定的方式添加该行,现在它似乎很喜欢它,并且出现了另一个错误,并且告诉我该行在其他地方已经存在。在我开始逐一研究所有这些问题之前,我将与该公司的一位开发人员交谈,看看他们以前是否遇到过这种情况。谢谢你迄今为止的帮助,乔希,非常感谢,我明天可能会回来!我唯一不明白的是他们让这个工作?!哦,鬼把戏!!!通过执行rakedb:schema:load;rake db:seed-它将从schema.rb加载所有内容,并且不会运行迁移,但听起来好像缺少一些东西。JOSH。。。它起作用了!诚然,有错误,但运行你的负载和种子使它爆发出生命!非常感谢:@RichardKeMiKaLGeNeRaLDenton这里可能发生的事情是,开发人员在某个点上从零开始破坏了运行迁移。这并不罕见。例如,如果旧迁移引用了一些不再存在的数据/方法/数据库扩展,则经常会发生这种情况。