Tuesday, March 23, 2010

error: Data truncated for column

We canot alter a nullable column when it is empty at MySQL.

Thus, if I want to change the column 'size_column' that are null to non-nu;;able colume, I got the following error:

== VerificationTries: migrating ==============================================
-- change_column(:associations, :size_column, :integer, {:limit=>3, :null=>false, :default=>0})
rake aborted!
An error has occurred, all later migrations canceled:

Mysql::Error: Data truncated for column 'size_column' at row 1: ALTER TABLE `associations` CHANGE 'size_column' 'size_column' mediumint DEFAULT 0 NOT NULL

No comments:

Post a Comment