Project

General

Profile

Redmine database migration 0.8 => 2.0 failing

Added by Nicolas Vandermeirsch almost 12 years ago

environment:windows server 2003, mysql 5.1, redmine 2.0 with ruby 1.9.3 & rails 3.2.3

We are trying to migrate our old Redmine 0.8 server to Redmine 2.0, following the instructions from:
http://www.redmine.org/projects/redmine/wiki/RedmineUpgrade

Unfortunately the database migration does not work, see log below.
Is there something else we can do or our database is just too old?

Thanks
----------------------------------------------------------------------------------------
C:\redmine-2.0>rake db:migrate RAILS_ENV=production
AddCustomFieldsEditable: migrating ======================================
-- add_column(:custom_fields, :editable, :boolean, {:default=>true})
-> 0.0781s
AddCustomFieldsEditable: migrated (0.0781s) =============================

SetCustomFieldsEditable: migrating ======================================
SetCustomFieldsEditable: migrated (0.0469s) ============================= AddProjectsLftAndRgt: migrating =========================================
-- add_column(:projects, :lft, :integer)
> 0.0156s
-
add_column(:projects, :rgt, :integer)
-> 0.0156s
AddProjectsLftAndRgt: migrated (0.0469s) ================================ BuildProjectsTree: migrating ============================================
rake aborted!
An error has occurred, all later migrations canceled:

undefined method `multiple?' for #<ProjectCustomField:0x2dc8178>

Tasks: TOP => db:migrate
(See full trace by running task with --trace)

C:\redmine-2.0>
---------------------------------------------------------------------------------------------------


Replies (5)

RE: Redmine database migration 0.8 => 2.0 failing - Added by Knight Samar over 11 years ago

Did you get a solution for this ?

I am facing the same problem.

RE: Redmine database migration 0.8 => 2.0 failing - Added by Nicolas Vandermeirsch over 11 years ago

nope, so we have installed a new Redmine 2.0 server on Linux and will try to keep it up to date to avoid database migration issues in the future.

RE: Redmine database migration 0.8 => 2.0 failing - Added by William Roush over 11 years ago

I'd try pulling older versions of Redmine from the source code repo (starting with 0.9, then 1.0, etc.) and doing upgrades that way due to major changes in the objects that seem to be causing this problem.

RE: Redmine database migration 0.8 => 2.0 failing - Added by Assem Bayahi about 11 years ago

Hello,

I'm facing the same problem, and like William, I thought it will be easier to migrate step by step than trying to solve the above problem. Well, this is not the case : because each time I try to migrate from a version to another I was having a lot of hard time : problem with rails, gems, i18m, compatibility issues... so after 2 days I gave up and took the decision to check why we get the multiple? problem.

The problem came from this code (line 90) in the lib/plugins/acts_as_customizable/lib/acts_as_customizable.rb file :

if field.multiple?
              values = custom_values.select { |v| v.custom_field == field }
              if values.empty?
                values << custom_values.build(:customized => self, :custom_field => field, :value => nil)
              end
              x.value = values.map(&:value)
            else
              cv = custom_values.detect { |v| v.custom_field == field }
              cv ||= custom_values.build(:customized => self, :custom_field => field, :value => nil)
              x.value = cv.value
            end

When checking the ProjectCustomField model, in fact there is no multiple function. But when comparing a database created by a new version of redmine and my old database, I see that a new column multiple was added to the Custom_fields table. So I checked in the new redmine administration sections to know when this column is used : it's used to indicate that a list custom filed can have multiple selected value which is something new : in old versions, a list custom field can have only one value. So I got the idea to remove the multiple? test and keep only the code treating a single value, So the code above is now :
cv = custom_values.detect { |v| v.custom_field == field }
              cv ||= custom_values.build(:customized => self, :custom_field => field, :value => nil)
              x.value = cv.value

Then I tried again and it Works :)

RE: Redmine database migration 0.8 => 2.0 failing - Added by Luis Carlos Sanchez Gonzalez about 9 years ago

I have faced same problem migrating from 0.8 to 2.6.1 and the solution was executing the following commands on the terminal:

cd /usr/share/redmine/
RAILS_ENV=production rails console
ActiveRecord::Base.connection.initialize_schema_migrations_table
require "/usr/share/redmine/db/migrate/20120115143100_add_repositories_is_default"
AddRepositoriesIsDefault.new.up
ActiveRecord::Migrator.new(nil,nil).send(:record_version_state_after_migrating, 20120115143100)
require "/usr/share/redmine/db/migrate/20120127174243_add_custom_fields_multiple"
AddCustomFieldsMultiple.new.up
ActiveRecord::Migrator.new(nil,nil).send(:record_version_state_after_migrating, 20120127174243)
require "/usr/share/redmine/db/migrate/20130202090625_add_projects_inherit_members"
AddProjectsInheritMembers.new.up
ActiveRecord::Migrator.new(nil,nil).send(:record_version_state_after_migrating, 20130202090625)
exit
RAILS_ENV=production rake db:migrate

    (1-5/5)