Forum: Ruby on Rails Migration w/change_column fails on MySQL 5.1

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2007-03-28 20:44

I have a migration with statements like this:

change_column :quote_input_class_codes, :employee_payroll, :integer,
:default => 0, :null => false

When I migrate, I get:

(in C:/eclipse/workspace/OnlineRating)
== DefaultQiccPayrollsToZero: migrating
-- change_column(:quote_input_class_codes, :employee_payroll, :integer,
{:null=>false, :default=>0})
rake aborted!
Mysql::Error: Data truncated for column 'employee_payroll' at row 1:
ALTER TABLE quote_input_class_codes CHANGE employee_payroll
employee_payroll int(11) DEFAULT 0 NOT NULL

Notice the duplication of the column name in the generated SQL, which is
why this is failing.

Anyone seen this before?  Is it a known issue?

Bb4bdf2b184027bc38d4fb529770cde5?d=identicon&s=25 Wes Gamble (weyus)
on 2007-03-28 21:39
Solutiono: MySQL can't set columns to NOT NULL if any of their values
are NULL.

This migration worked fine after all of the NULLs were replaced with

I verified the ALTER TABLE syntax against the MySQL 5.1 reference manual
and it was correct.

This topic is locked and can not be replied to.