Defect #6868
openmigrate_from_trac and trac 0.12
0%
Description
When I migrate from my Trac 0.12 database using sqlite3. I encounter this error :
Not knowing much about ruby I have some problems finding where it comes from
www-data@myserver:~/public/ruby/redmine-1.0.3$ rake redmine:migrate_from_trac RAILS_ENV="production" --trace(in /home/www-data/public/ruby/redmine-1.0.3)
- Invoke redmine:migrate_from_trac (first_time)
- Invoke environment (first_time)
- Execute environment
- Execute redmine:migrate_from_trac
WARNING: a new project will be added to Redmine during this process.
Are you sure you want to continue ? [y/N] y
Trac directory []: /home/www-data/public/python/trac/myproject/
Trac database adapter (sqlite, sqlite3, mysql, postgresql) [sqlite3]: 
Trac database encoding [UTF-8]: 
Target project identifier []: myproject
Migrating components..
Migrating milestones....
Migrating custom fields
Migrating tickets................
Migrating wiki...........................................................................................................rake aborted!
no implicit conversion to float from nil /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:277:in `minus_without_duration' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:277:in `minus_without_coercion' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activesupport/lib/active_support/core_ext/time/calculations.rb:286:in `-' /home/www-data/public/ruby/redmine-1.0.3/lib/tasks/migrate_from_trac.rake:79:in `fake' /home/www-data/public/ruby/redmine-1.0.3/lib/tasks/migrate_from_trac.rake:547:in `migrate' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:369:in `method_missing' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `each' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `send' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_proxy.rb:215:in `method_missing' /home/www-data/public/ruby/redmine-1.0.3/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb:369:in `method_missing' /home/www-data/public/ruby/redmine-1.0.3/lib/tasks/migrate_from_trac.rake:545:in `migrate' /home/www-data/public/ruby/redmine-1.0.3/lib/tasks/migrate_from_trac.rake:758 /usr/lib/ruby/1.8/rake.rb:636:in `call' /usr/lib/ruby/1.8/rake.rb:636:in `execute' /usr/lib/ruby/1.8/rake.rb:631:in `each' /usr/lib/ruby/1.8/rake.rb:631:in `execute' /usr/lib/ruby/1.8/rake.rb:597:in `invoke_with_call_chain' /usr/lib/ruby/1.8/monitor.rb:242:in `synchronize' /usr/lib/ruby/1.8/rake.rb:590:in `invoke_with_call_chain' /usr/lib/ruby/1.8/rake.rb:583:in `invoke' /usr/lib/ruby/1.8/rake.rb:2051:in `invoke_task' /usr/lib/ruby/1.8/rake.rb:2029:in `top_level' /usr/lib/ruby/1.8/rake.rb:2029:in `each' /usr/lib/ruby/1.8/rake.rb:2029:in `top_level' /usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling' /usr/lib/ruby/1.8/rake.rb:2023:in `top_level' /usr/lib/ruby/1.8/rake.rb:2001:in `run' /usr/lib/ruby/1.8/rake.rb:2068:in `standard_exception_handling' /usr/lib/ruby/1.8/rake.rb:1998:in `run' /usr/bin/rake:28
Related issues
       Updated by Jean-Philippe Lang almost 15 years ago
      Updated by Jean-Philippe Lang almost 15 years ago
      
    
    It looks like you're not using the migration script (lib/tasks/migrate_from_trac.rake) provided with 1.0.3.
Anything else to mention?
       Updated by Félix Delval almost 15 years ago
      Updated by Félix Delval almost 15 years ago
      
    
    I am using the migration script from the 1.0.3 version.
The problem seems to be that function Time.fake() has problem to handle when the given input is nil.
  class ::Time
    class << self
      alias :real_now :now
      def now
        real_now - @fake_diff.to_i
      end
      def fake(time)
        @fake_diff = real_now - time
        res = yield
        @fake_diff = 0
       res
      end
    end
  end
	To solve that issue I modified this function in such way :
  class ::Time
    class << self
      alias :real_now :now
      def now
        real_now - @fake_diff.to_i
      end
      def fake(time)
        time = 0 if time.nil?
        @fake_diff = real_now - time
        res = yield
        @fake_diff = 0
       res
      end
    end
  end
	The migration works perfectly nows. I have a few other trac to migrate, I'll try this modification and if it work I'll add a patch file.
       Updated by Jean-Philippe Lang almost 15 years ago
      Updated by Jean-Philippe Lang almost 15 years ago
      
    
    - Status changed from New to Closed
- Resolution set to Duplicate
       Updated by C. X. over 14 years ago
      Updated by C. X. over 14 years ago
      
    
    - Status changed from Closed to Reopened
Why should this be a duplicate of the other issue?
The error is not even the same and the redmine versions are different!
I got the same error with trac 0.13.
The advice of Félix Delval helped me.
       Updated by Leo Shklovskii over 13 years ago
      Updated by Leo Shklovskii over 13 years ago
      
    
    Agreed, it's not a duplicate, it's a totally different issue. The fix that Felix did worked for me, it would be great to get it checked into trunk.
       Updated by J. R. over 13 years ago
      Updated by J. R. over 13 years ago
      
    
    Still exists in redmine 1.4.0. Felix fix is working indeed.
       Updated by Etienne Massip over 13 years ago
      Updated by Etienne Massip over 13 years ago
      
    
    - Target version set to Candidate for next minor release
- Resolution deleted (Duplicate)
       Updated by Toshi MARUYAMA about 12 years ago
      Updated by Toshi MARUYAMA about 12 years ago
      
    
    - Related to Defect #14843: Error in migrate_from_trac added
       Updated by Craig Rodrigues about 12 years ago
      Updated by Craig Rodrigues about 12 years ago
      
    
    #14567 is a more comprehensive fix
       Updated by Toshi MARUYAMA about 12 years ago
      Updated by Toshi MARUYAMA about 12 years ago
      
    
    - Related to Patch #14567: migrate_from_trac.rake does not convert timestamps in Trac database version 23 added
       Updated by Toshi MARUYAMA about 11 years ago
      Updated by Toshi MARUYAMA about 11 years ago
      
    
    - Related to deleted (Defect #14843: Error in migrate_from_trac)
       Updated by Toshi MARUYAMA about 11 years ago
      Updated by Toshi MARUYAMA about 11 years ago
      
    
    - Has duplicate Defect #14843: Error in migrate_from_trac added