我正在升级Redmine的安装程序,从3.0.3升级到3.3.3。
我一直遵循的过程是在一台新机器上安装一个新红地雷,从当前的机器导入和sqldump,然后复制重要的内容(file/config.yml/database.yml,plugins)并运行所有必要的步骤。在过去,这种做法通常运作良好。
目前,在导入sqldump之后,Redmine还没有启动,而且我得到了一个我无法发现的错误。
mysql导入似乎有效:
mysql -u 'user' -p'mypassword' redmine < /home/redmine20170608.sql然后,我做了通常的步骤,所有的运行没有错误:
bundle exec rake redmine:plugins:migrate RAILS_ENV=production
bundle exec rake db:migrate RAILS_ENV=production
bundle exec rake tmp:sessions:clear
bundle exec rake tmp:cache:clear
sudo service httpd restart当我导航到myredmine.com时,我会得到“内部错误”消息。查看日志,输出如下:
ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 'tokens.updated_on' in 'field list': UPDATE `tokens` SET `tokens`.`updated_on` = '2017-06-09 07:10:56.515511' WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = '5a229e24fe73e8a43768c46af2275a8b4a60c9b3' AND `tokens`.`action` = 'session'):
app/models/user.rb:425:in `verify_session_token'
app/controllers/application_controller.rb:77:in `session_expired?'
app/controllers/application_controller.rb:67:in `session_expiration'
Migrating to CreateRolesManagedRoles (20150528092912)
Started GET "/" for 72.155.92.149 at 2017-06-09 07:16:14 +0000
Processing by WelcomeController#index as HTML
Completed 500 Internal Server Error in 25ms (ActiveRecord: 1.8ms)
ActiveRecord::StatementInvalid (Mysql2::Error: Unknown column 'tokens.updated_on' in 'field list': UPDATE `tokens` SET `tokens`.`updated_on` = '2017-06-09 07:16:14.896744' WHERE `tokens`.`user_id` = 1 AND `tokens`.`value` = '5a229e24fe73e8a43768c46af2275a8b4a60c9b3' AND `tokens`.`action` = 'session'):
app/models/user.rb:425:in `verify_session_token'
app/controllers/application_controller.rb:77:in `session_expired?'
app/controllers/application_controller.rb:67:in `session_expiration'这是该文件第425行的代码:
scope.update_all(:updated_on => Time.now) == 1在本节中:
# Returns true if token is a valid session token for the user whose id is user_id
def self.verify_session_token(user_id, token)
return false if user_id.blank? || token.blank?
scope = Token.where(:user_id => user_id, :value => token.to_s, :action => 'session')
if Setting.session_lifetime?
scope = scope.where("created_on > ?", Setting.session_lifetime.to_i.minutes.ago)
end
if Setting.session_timeout?
scope = scope.where("updated_on > ?", Setting.session_timeout.to_i.minutes.ago)
end
scope.update_all(:updated_on => Time.now) == 1
end我通常会发现这些错误的输出相对来说是不言自明的,但我不知道如何解释这个错误。
我已经删除了所有的插件,以确保它不是一个兼容性问题,并得到相同的问题。
当前的红地雷是3.0.3,运行在Ruby1.9.3-p551、Rails 4.2.1和2010.03上(我建议您不要使用它)。
新的红矿山是3.3.3,运行在Ruby2.2.5-p319、Rails 4.2.7.1和CentOS 7上。
任何帮助都非常感谢。
发布于 2017-06-09 08:10:05
正如注释中所讨论的,错误是
ActiveRecord::StatementIn有效值(Mysql2 2::Error:未知列'tokens.updated_on‘)
在updated_on模型中没有名为Token的列,您正在尝试在第425行更新它
scope.update_all(:updated_on => Time.now) == 1您需要为该列添加迁移。
从app的根文件夹在终端中运行以下命令,
rails g migration AddUpdatedOnToToken updated_on:datetime
rake db:migrate发布于 2017-06-12 11:49:19
答案是手动添加所需的列。第一个答案中所描述的方式是行不通的--正如我所指出的,我一直被拒绝许可。这很奇怪,因为只有两个mysql用户,而且都可以访问该数据库。
因此,解决这个问题的方法是以Redmine用户身份登录mysql并运行以下命令:
USE mydatabase;
ALTER TABLE tokens ADD updated_on VARCHAR(60);这个问题得到了解决--我能够在没有问题的情况下继续访问红矿山。
https://stackoverflow.com/questions/44451934
复制相似问题