Project

General

Profile

Actions

Defect #771

closed

rev1093 doesn't work: Fixed migration 87 (mysql: TEXT column can't have a default value).

Added by Chaoqun Zou about 16 years ago. Updated about 16 years ago.

Status:
Closed
Priority:
Normal
Category:
-
Target version:
-
Start date:
2008-03-02
Due date:
% Done:

0%

Estimated time:
Resolution:
Affected version:

Description

my enviroment is:
windows xp
rails 2.0.2
mysql 5.0.45
redmine r1183

in 001_setup.rb line174
create_table "projects", :force => true do |t|
t.column "name", :string, :limit => 30, :default => "", :null => false
t.column "description", :string, :default => "", :null => false
this means column "description" will have a default value of ""

and
in ruby\lib\ruby\gems\1.8\gems\activerecord-2.0.2\lib\active_record\connection_adapters\mysqladapter.rb line429
def change_column(table_name, column_name, type, options = {}) #:nodoc:
unless options_include_default?(options)
if column = columns(table_name).find { |c| c.name == column_name.to_s }
options[:default] = column.default
else
raise "No such column: #{table_name}.#{column_name}"
end
end
this means when use change_column in 087_change_projects_description_to_text.rb
change_column :projects, :description, :text, :null => true
active_record will find column description's default value and add it to the sql:
ALTER TABLE `projects` CHANGE `description` `description` text DEFAULT ''
which will fail, info:

rake aborted!
Mysql::Error: BLOB/TEXT column 'description' can't have a default value: ALTER TABLE `projects` CHANGE `description` `description` text DEFAULT ''

so I think just remove the "default => ''" statement from 087_change_projects_description_to_text.rb will not solve the problem.
Or should I use mysql5.1?

Actions

Also available in: Atom PDF