db migration error

Added by Klaus-Peter Webersinke over 7 years ago

Hi,

after upgrading to the latest trunk via svn and running the db migration, i got the following error:

rake db:migrate RAILS_ENV=production --trace
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  ChangeChangesPathLengthLimit: migrating ===================================
-- change_column(:changes, :path, :text, {:null=>false})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: BLOB/TEXT column 'path' can't have a default value: ALTER TABLE `changes` CHANGE `path` `path` text DEFAULT '' NOT NULL
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/abstract_adapter.rb:219:in `log'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:323:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/connection_adapters/mysql_adapter.rb:511:in `change_column'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:352:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:352:in `method_missing'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:328:in `say_with_time'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:328:in `say_with_time'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:348:in `method_missing'
./db/migrate//20100705164950_change_changes_path_length_limit.rb:3:in `up_without_benchmarks'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:282:in `send'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:282:in `migrate'
c:/ruby/lib/ruby/1.8/benchmark.rb:293:in `measure'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:282:in `migrate'
c:1:in `__send__'
c:1:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:486
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:562:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:562:in `ddl_transaction'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:485:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:472:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:400:in `up'
c:/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.5/lib/active_record/migration.rb:383:in `migrate'
c:/ruby/lib/ruby/gems/1.8/gems/rails-2.3.5/lib/tasks/databases.rake:116
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `call'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:636:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:631:in `execute'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:597:in `invoke_with_call_chain'
c:/ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:590:in `invoke_with_call_chain'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:583:in `invoke'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2051:in `invoke_task'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `each'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2029:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2023:in `top_level'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2001:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:2068:in `standard_exception_handling'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake.rb:1998:in `run'
c:/ruby/lib/ruby/gems/1.8/gems/rake-0.8.7/bin/rake:31
c:/ruby/bin/rake:19:in `load'
c:/ruby/bin/rake:19

Any idea's how to fix that ?

Many regards
kpw

Replies (39)

RE: db migration error - Added by Alan Liu over 7 years ago

Windows Server 2003 R2 Standard Edition SP2

Thanks.

RE: db migration error - Added by Felix Schäfer over 7 years ago

Alan Liu wrote:

Windows Server 2003 R2 Standard Edition SP2

The important also being if you are on 32 or 64 bit, as it seems mysql throws an error on 32bit only. Could you confirm you are on 32bit too?

RE: db migration error - Added by Daniel Morgan over 7 years ago

I'm have redmine installed on WinXP SP3 (32bit).

RE: db migration error - Added by Evgeny Martynenkov over 7 years ago

Windows Server 2003 R2 Standard Edition SP2 (32 bit)

RE: db migration error - Added by Alan Liu over 7 years ago

Felix Schäfer wrote:

Alan Liu wrote:

Windows Server 2003 R2 Standard Edition SP2

The important also being if you are on 32 or 64 bit, as it seems mysql throws an error on 32bit only. Could you confirm you are on 32bit too?

Yes, 32 bit.

RE: db migration error - Added by Nicolas Gauthier over 7 years ago

WinXP SP3 (32bits) for me...

RE: db migration error - Added by Klaus-Peter Webersinke over 7 years ago

according to the mysql documentation (http://dev.mysql.com/doc/refman/5.0/en/blob.html) : BLOB and TEXT columns cannot have DEFAULT values !

the migration may work if we change

ALTER TABLE `changes` CHANGE `path` `path` text DEFAULT '' NOT NULL

to

ALTER TABLE `changes` CHANGE `path` `path` text  NOT NULL

i will test this tomorrow ( currently absend on business)

many regards,
kpw

RE: db migration error - Added by Joshua Masek over 7 years ago

For what it's worth, I changed the file to (see the first 2 change_column commands):

class ChangeChangesPathLengthLimit < ActiveRecord::Migration
  def self.up
    change_column :changes, :path, :text, :default => nil, :null => true
    change_column :changes, :path, :text, :null => false
    change_column :changes, :from_path, :text
  end

  def self.down
    change_column :changes, :path, :string, :default => "", :null => false
    change_column :changes, :from_path, :string
  end
end

This worked for me. I don't know if this is a good change or not. But it didn't error out during db migrate.

RE: db migration error - Added by Masaki Nabetani over 7 years ago

I also have the exact same problem upgrading from redmine-0.9.5 to redmine-1.0.0 downloaded from Rubyforge.
I use Windows 2000 Server SP4 (Yes! 32bit ;-)

D:\ITS\redmine-1.0.0>rake db:migrate RAILS_ENV="production" 
(in D:/ITS/redmine-1.0.0)
==  AddIssuesNestedSetsColumns: migrating =====================================
-- add_column(:issues, :parent_id, :integer, {:default=>nil})
   -> 2.0320s
-- add_column(:issues, :root_id, :integer, {:default=>nil})
   -> 1.1090s
-- add_column(:issues, :lft, :integer, {:default=>nil})
   -> 1.0780s
-- add_column(:issues, :rgt, :integer, {:default=>nil})
   -> 1.2030s
==  AddIssuesNestedSetsColumns: migrated (6.1560s) ============================

==  AddIndexOnIssuesNestedSet: migrating ======================================
-- add_index(:issues, [:root_id, :lft, :rgt])
   -> 1.1400s
==  AddIndexOnIssuesNestedSet: migrated (1.1720s) =============================

==  ChangeChangesPathLengthLimit: migrating ===================================
-- change_column(:changes, :path, :text, {:null=>false})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: BLOB/TEXT column 'path' can't have a default value: ALTER TABLE `c
hanges` CHANGE `path` `path` text DEFAULT '' NOT NULL

(See full trace by running task with --trace)

D:\ITS\redmine-1.0.0>set RAILS_ENV=production

D:\ITS\redmine-1.0.0>ruby script/about
About your application's environment
Ruby version              1.8.6 (i386-mswin32)
RubyGems version          1.3.1
Rack version              1.0
Rails version             2.3.5
Active Record version     2.3.5
Active Resource version   2.3.5
Action Mailer version     2.3.5
Active Support version    2.3.5
Application root          D:/ITS/redmine-1.0.0
Environment               production
Database adapter          mysql
Database schema version   20100313171051

D:\ITS\redmine-1.0.0>mysql --version
mysql  Ver 14.12 Distrib 5.0.67, for Win32 (ia32)

D:\ITS\redmine-1.0.0>rake db:migrate RAILS_ENV="production" --trace
(in D:/ITS/redmine-1.0.0)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
==  ChangeChangesPathLengthLimit: migrating ===================================
-- change_column(:changes, :path, :text, {:null=>false})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: BLOB/TEXT column 'path' can't have a default value: ALTER TABLE `c
hanges` CHANGE `path` `path` text DEFAULT '' NOT NULL
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adap
ters/abstract_adapter.rb:219:in `log'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adap
ters/mysql_adapter.rb:323:in `execute'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/connection_adap
ters/mysql_adapter.rb:511:in `change_column'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:35
2:in `send'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:35
2:in `method_missing'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:32
8:in `say_with_time'
D:/usr/ruby-1.8.6/lib/ruby/1.8/benchmark.rb:293:in `measure'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:32
8:in `say_with_time'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:34
8:in `method_missing'
./db/migrate//20100705164950_change_changes_path_length_limit.rb:3:in `up_withou
t_benchmarks'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:28
2:in `send'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:28
2:in `migrate'
D:/usr/ruby-1.8.6/lib/ruby/1.8/benchmark.rb:293:in `measure'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:28
2:in `migrate'
D:1:in `__send__'
D:1:in `migrate'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:48
6:in `migrate'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:56
2:in `call'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:56
2:in `ddl_transaction'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:48
5:in `migrate'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:47
2:in `each'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:47
2:in `migrate'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:40
0:in `up'
D:/ITS/redmine-1.0.0/vendor/rails/activerecord/lib/active_record/migration.rb:38
3:in `migrate'
D:/ITS/redmine-1.0.0/vendor/rails/railties/lib/tasks/databases.rake:116
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'

D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'

D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_w
ith_call_chain'
D:/usr/ruby-1.8.6/lib/ruby/1.8/monitor.rb:242:in `synchronize'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_w
ith_call_chain'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_
task'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_lev
el'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_lev
el'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standar
d_exception_handling'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_lev
el'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standar
d_exception_handling'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
D:/usr/ruby-1.8.6/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
D:/usr/ruby-1.8.6/bin/rake:19:in `load'
D:/usr/ruby-1.8.6/bin/rake:19

D:\ITS\redmine-1.0.0>

RE: db migration error - Added by Klaus-Peter Webersinke over 7 years ago

Hi Joshua,

your change worked for me too....

kpw

RE: db migration error - Added by Felix Schäfer over 7 years ago

Joshua Masek wrote:

For what it's worth, I changed the file to (see the first 2 change_column commands):

[...]

This worked for me. I don't know if this is a good change or not. But it didn't error out during db migrate.

We've been able to reproduce the error and the fix you are proposing seems to work. Just give a us a little time to put it through its paces and it should get pushed to trunk shortly. Thanks Joshua for the fix :-)

RE: db migration error - Added by Siwei Shen over 7 years ago

I am updating the redmine from 0.8.X to 1.0, and also met this problem. (win2003, mysql Ver 14.14 Distrib 5.1.43, for Win32 (ia32) )

Thanks Felix! Waiting for the new release.... :-)

Felix Prüll wrote:

Hello,

We run redmine one a Windows Server 2008 Web Edition SP2 with 32 bit. I hope this helps to reproduce the error...

Thanks and Regards
Felix

RE: db migration error - Added by James Van Lommel over 7 years ago

The solution by Joshua Masek worked for me. I was having the same migration issue as others reported.

My platforms:

  • Ruby: 1.8.7 on Windows 7
  • MySQL: 5.1.39 on Linux, with sql_mode= ANSI,TRADITIONAL,STRICT_ALL_TABLES (the OurDelta distribution)

RE: db migration error - Added by Holger Just about 7 years ago

The fix was committed this morning (GMT). Please all update your installations and check if it works correctly now.

--Holger

1 2 (26-39/39)