Redmine 数据迁移中断安装(错误 500)

Redmine 数据迁移中断安装(错误 500)

我正在尝试迁移一个较旧的安装:

Environment:
  Redmine version                          2.2.3.stable
  Ruby version                             1.9.3 (x86_64-linux)
  Rails version                            3.2.12
  Environment                              production
  Database adapter                         Mysql2
Redmine plugins:
  no plugin installed

更换为新机器:

Environment:
  Redmine version                2.6.1.stable
  Ruby version                   1.9.3-p194 (2012-04-20) [x86_64-linux]
  Rails version                  3.2.21
  Environment                    production
  Database adapter               Mysql2
SCM:
  Subversion                     1.6.17
  Mercurial                      2.2.2
  Bazaar                         2.6.0
  Git                            1.7.10.4
  Filesystem                     
Redmine plugins:
  redmine_dmsf                   1.4.9 stable

我在旧服务器上做了一个简单的备份:

root@redmine www/redmine# /usr/bin/mysqldump -u root -p"...redmine" redmine_production | gzip > redmine_`date +%y_%m_%d`.gz
root@redmine www/redmine# tar cjf files.tar.bz2 files

并尝试在新的(在职的,但为空)机器:

root@redmine ~# cd /var/www/redmine/
root@redmine www/redmine# scp mcon@syno0:files.tar.bz2 .
files.tar.bz2                                         100% 4229     4.1KB/s   00:00
root@redmine www/redmine# scp mcon@syno0:redmine_15_02_12.gz .
redmine_15_02_12.gz                                   100%   11KB  11.2KB/s   00:00

*** here Redmine server is STILL working ***

root@redmine www/redmine# service apache2 stop
[ ok ] Stopping web server: apache2 ... waiting .
root@redmine www/redmine# tar xjf files.tar.bz2
root@redmine www/redmine# zcat redmine_15_02_12.gz | mysql --user=root --password=...redmine     redmine_production
root@redmine www/redmine# rake db:migrate
==  Setup: migrating ==========================================================
-- create_table("attachments", {:force=>true})
   -> 0.0082s
-- create_table("auth_sources", {:force=>true})
   -> 0.0043s
-- create_table("custom_fields", {:force=>true})
   -> 0.0041s
-- create_table("custom_fields_projects", {:id=>false, :force=>true})
   -> 0.0043s
-- create_table("custom_fields_trackers", {:id=>false, :force=>true})
   -> 0.0037s
-- create_table("custom_values", {:force=>true})
   -> 0.0049s
-- create_table("documents", {:force=>true})
   -> 0.0041s
-- add_index("documents", ["project_id"], {:name=>"documents_project_id"})
   -> 0.0127s
-- create_table("enumerations", {:force=>true})
   -> 0.0052s
-- create_table("issue_categories", {:force=>true})
   -> 0.0036s
-- add_index("issue_categories", ["project_id"], {:name=>"issue_categories_project_id"})
   -> 0.0158s
-- create_table("issue_histories", {:force=>true})
   -> 0.0191s
-- add_index("issue_histories", ["issue_id"], {:name=>"issue_histories_issue_id"})
   -> 0.0143s
-- create_table("issue_statuses", {:force=>true})
   -> 0.0046s
-- create_table("issues", {:force=>true})
   -> 0.0045s
-- add_index("issues", ["project_id"], {:name=>"issues_project_id"})
   -> 0.0149s
-- create_table("members", {:force=>true})
   -> 0.0062s
-- create_table("news", {:force=>true})
   -> 0.0052s
-- add_index("news", ["project_id"], {:name=>"news_project_id"})
   -> 0.0139s
-- create_table("permissions", {:force=>true})
   -> 0.0044s
-- create_table("permissions_roles", {:id=>false, :force=>true})
   -> 0.0059s
-- add_index("permissions_roles", ["role_id"], {:name=>"permissions_roles_role_id"})
   -> 0.0168s
-- create_table("projects", {:force=>true})
   -> 0.0582s
-- create_table("roles", {:force=>true})
   -> 0.0045s
-- create_table("tokens", {:force=>true})
   -> 0.0044s
-- create_table("trackers", {:force=>true})
   -> 0.0037s
-- create_table("users", {:force=>true})
   -> 0.0048s
-- create_table("versions", {:force=>true})
   -> 0.0112s
-- add_index("versions", ["project_id"], {:name=>"versions_project_id"})
   -> 0.0428s
-- create_table("workflows", {:force=>true})
   -> 0.0059s
==  Setup: migrated (0.4712s) =================================================

**** MANY LINES, APPARENTLY WITHOUT ERROR ****

==  ChangeChangesetsCommentsLimit: migrating ==================================
-- change_column(:changesets, :comments, :text, {:limit=>16777216})
   -> 0.0081s
==  ChangeChangesetsCommentsLimit: migrated (0.0085s) =========================

==  AddPasswordChangedAtToUser: migrating =====================================
-- add_column(:users, :passwd_changed_on, :datetime)
   -> 0.0104s
==  AddPasswordChangedAtToUser: migrated (0.0108s) ============================

==  InsertBuiltinGroups: migrating ============================================
==  InsertBuiltinGroups: migrated (0.1441s) ===================================

root@redmine www/redmine# service apache2 start
[ ok ] Starting web server: apache2.
root@redmine www/redmine#

此后,Redmine 不再工作。尝试连接导致:

Internal error

An error occurred on the page you were trying to access.
If you continue to experience problems please contact your Redmine administrator for assistance.

If you are the Redmine administrator, check your log files for details about the error.

Back

我收到以下日志:

...
Connecting to database specified by database.yml
Creating scope :system. Overwriting existing method Enumeration.system.
Creating scope :sorted. Overwriting existing method User.sorted.
Creating scope :sorted. Overwriting existing method Group.sorted.
Started GET "/" for 192.168.7.114 at 2015-02-12 14:41:57 +0000
Processing by WelcomeController#index as HTML
  Current user: admin (id=1)
Completed 500 Internal Server Error in 75.0ms

NoMethodError (undefined method `passwd_changed_on' for #<User:0x00000006696f80>):
  app/controllers/application_controller.rb:150:in `force_logout_if_password_changed'

我究竟做错了什么?

答案1

我真丢脸:

事实证明我错误地期望rake db:migrate采取行动production ENV,即不是案子。

正确的命令是:rake db:migrate RAILS_ENV="production"

这就是当你盲目地复制粘贴时发生的情况。

抱歉造成了噪音(如果版主认为此问答有用,可以删除它)。

记录:您还需要在执行恢复之前删除 redmine_production 中的所有表,否则rake ...命令将失败并出现错误:

Mysql2::Error: Table 'queries_roles' already exists: CREATE TABLE `queries_roles` (`query_id` int(11) NOT NULL, `role_id` int(11) NOT NULL) ENGINE=InnoDB/var/lib/gems/1.9.1/gems/activerecord-3.2.21/lib/active_record/connection_adapters/abstract_mysql_adapter.rb:245:in `query'

相关内容