简体   繁体   English

Rails 3到Rails 5迁移ActiveRecord问题

[英]Rails 3 to Rails 5 migration ActiveRecord issue

Rails upgrade from 2.3.8 to 5.1.2 with Jruby 使用Jruby将Rails从2.3.8升级到5.1.2

ActiveRecord issue when upgrading gem 'activerecord-jdbc-adapter' 升级gem'activerecord-jdbc-adapter'时的ActiveRecord问题

I started to work as a junior Rails developer and my first task is to update a legacy Rails 2.3.8 app written around 2008 in Jruby 1.5.3 (Ruby 1.8.7) to Rails 5.1.2 in Jruby 9.1.12 (Ruby 2.3.3). 我开始作为初级的Rails开发人员,我的第一个任务是将Jruby 1.5.3(Ruby 1.8.7)于2008年左右编写的旧版Rails 2.3.8应用程序更新为Jruby 9.1.12(Ruby 2.3)中的Rails 5.1.2。 0.3)。 It consists of 222 controllers and 122 models, and only spits XML that is consumed by a Java Swing desktop app. 它由222个控制器和122个模型组成,并且仅吐出Java Swing桌面应用程序使用的XML。 Searching I found that the best way to do it, is step by step from one minor version to another correcting all issues in the inter. 搜索后发现,最好的方法是逐步从一个次要版本到另一个更正版本中的所有问题。 I reached version 3.0.12 in two weeks leaving the aplication without warnings, but I was asked to go directly to Jruby 9.XX and Rails 5.1.X. 我在两周内就达到了3.0.12版本,但没有警告,但是我被要求直接使用Jruby 9.XX和Rails5.1.X。 With a few difficulties I get the server up, but when I try to login in the application I got this error. 遇到一些困难,我启动了服务器,但是当我尝试登录应用程序时,出现了此错误。 I suspect about the jdbc adapter gem, but any gem below 5.0pre1 works with Rails 5. Could this be only a parsing error from the DB? 我怀疑有关jdbc适配器的gem,但是5.0pre1以下的任何gem都可以与Rails 5一起使用。这可能只是数据库的解析错误吗? Should I continue with the cycle I was carrying? 我应该继续我所携带的周期吗?

NOTE: There's no test suite for the app, and there are eight modules that override some Rails core methods. 注意:该应用程序没有测试套件,并且有八个模块可以覆盖某些Rails核心方法。

Started POST "/login/login_xml" for 127.0.0.1 at 2017-08-03 12:21:03 -0500
  ActiveRecord::SchemaMigration Load (0.0ms)  SELECT `schema_migrations`.* 
FROM `schema_migrations`

NoMethodError (undefined method `to_sym' for nil:NilClass
Did you mean?  to_s):

activerecord (5.0.4) lib/active_record/attribute_methods/time_zone_conversion.rb:88:in `create_time_zone_conversion_attribute?'
activerecord (5.0.4) lib/active_record/attribute_methods/time_zone_conversion.rb:78:in `block in inherited'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:62:in `block in matching'
org/jruby/RubyArray.java:2565:in `select'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:61:in `matching'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:57:in `decorators_for'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:48:in `apply'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:30:in `block in load_schema!'
org/jruby/RubyHash.java:1343:in `each'
activerecord (5.0.4) lib/active_record/attribute_decorators.rb:29:in `load_schema!'
activerecord (5.0.4) lib/active_record/model_schema.rb:455:in `block in load_schema'
C:/jruby-9.1.12.0/lib/ruby/stdlib/monitor.rb:214:in `mon_synchronize'
activerecord (5.0.4) lib/active_record/model_schema.rb:452:in `load_schema'
activerecord (5.0.4) lib/active_record/model_schema.rb:343:in `columns_hash'
activerecord (5.0.4) lib/active_record/querying.rb:41:in `find_by_sql'
activerecord (5.0.4) lib/active_record/relation.rb:702:in `exec_queries'
activerecord (5.0.4) lib/active_record/relation.rb:583:in `load'
activerecord (5.0.4) lib/active_record/relation.rb:260:in `records'
activerecord (5.0.4) lib/active_record/relation/delegation.rb:38:in `map'
activerecord (5.0.4) lib/active_record/migration.rb:1031:in `block in get_all_versions'
activesupport (5.0.4) lib/active_support/deprecation/reporting.rb:36:in `silence'
activesupport (5.0.4) lib/active_support/deprecation/instance_delegator.rb:20:in `silence'
activerecord (5.0.4) lib/active_record/migration.rb:1029:in `get_all_versions'
activerecord (5.0.4) lib/active_record/migration.rb:1043:in `needs_migration?'
activerecord (5.0.4) lib/active_record/migration.rb:573:in `check_pending!'
activerecord (5.0.4) lib/active_record/migration.rb:549:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/callbacks.rb:38:in `block in call'
activesupport (5.0.4) lib/active_support/callbacks.rb:97:in `__run_callbacks__'
activesupport (5.0.4) lib/active_support/callbacks.rb:750:in `_run_call_callbacks'
activesupport (5.0.4) lib/active_support/callbacks.rb:90:in `run_callbacks'
actionpack (5.0.4) lib/action_dispatch/middleware/callbacks.rb:36:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/debug_exceptions.rb:49:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.0.4) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.0.4) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.0.4) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.0.4) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.0) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/request_id.rb:24:in `call'
rack (2.0.3) lib/rack/method_override.rb:22:in `call'
rack (2.0.3) lib/rack/runtime.rb:22:in `call'
activesupport (5.0.4) lib/active_support/cache/strategy/local_cache_middleware.rb:28:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.0.4) lib/action_dispatch/middleware/static.rb:136:in `call'
rack (2.0.3) lib/rack/sendfile.rb:111:in `call'
railties (5.0.4) lib/rails/engine.rb:522:in `call'
puma-3.9.1 (java) lib/puma/configuration.rb:224:in `call'
puma-3.9.1 (java) lib/puma/server.rb:602:in `handle_request'
puma-3.9.1 (java) lib/puma/server.rb:435:in `process_client'
puma-3.9.1 (java) lib/puma/server.rb:299:in `block in run'
puma-3.9.1 (java) lib/puma/thread_pool.rb:120:in `block in spawn_thread'
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_source.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_source.html.erb (16.0ms)
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (16.0ms)
  Rendering C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (12.0ms)
  Rendered C:/jruby-9.1.12.0/lib/ruby/gems/shared/gems/actionpack-5.0.4/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb within rescues/layout (142.0ms)

The simplest answer is that you need to immediately push back on the request to skip directly to 5.1 . 最简单的答案是,您需要立即回退请求以直接跳到5.1 You are being set up for failure. 您正准备失败。 It may not even be possible to go from your current version to 5.1 , and without digging into your project and analyzing the gems you're currently reliant on, there's no way to know. 甚至可能无法从当前版本升级到5.1 ,而且如果不深入研究项目并分析当前依赖的gem,就无法知道。

You are trying to take an extremely dated project to a modern version and that is simply going to take a significant amount of time to do properly. 您正在尝试将一个过时的项目升级为现代版本,这只会花费大量时间才能正常工作。 This is why yearly/bi-yearly updates to modern versions are important, so you don't accumulate such high levels of technical debt. 这就是为什么对现代版本进行每年两次/每年一次的更新很重要的原因,因此您不会积累如此高的技术债务。

Please talk with a higher-level dev or your manager about this unreasonable request. 请就此不合理的请求与更高级别的开发人员或您的经理联系。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM