Skip to content
This repository

MySQL decimal Datatype Requires Migration With ":precision => ..." to Avoid "No integer type has byte size " Error #4

rparker opened this Issue · 1 comment

2 participants

Randy J Parker Ward Vandewege
Randy J Parker

Steps to reproduce:
Create a new Rails app with a single model named "bill.rb" with acts_as_versioned .
Set config/database.yml to use MySQL
Generate a migration called "create_bills".
In this migration, create a table named "bill" with a single attribute named "amount" with a "decimal" datatype. Include the "Bill.create_versioned_table" line.
Try "rake db:migrate" (db:drop & db:create as needed).
Note: No integer type has byte size 10 rake aborted! error
Add a specification of :scale => 2 to the migration datatype specification. The error remains.
Add a specification of :precision => 8 (even without :scale). The error disappears.

Tested on OSX 10.5.8, Ruby 1.8.6, Rails 2.3.3, acts_as_versioned 0.2.3

Ward Vandewege
cure commented

I also ran into this. Here's my workaround:

--- acts_as_versioned.rb.bu 2011-06-18 22:19:17.965242002 -0400
+++ acts_as_versioned.rb    2011-06-18 22:18:36.061242003 -0400
@@ -425,8 +425,13 @@

             self.versioned_columns.each do |col|
+              limit = col.limit
+              if col.limit == 10 and col.type == :integer
+                   # Avoid 'No integer type has byte size 10' under MySQL
+                   limit = 8
+              end
               self.connection.add_column versioned_table_name,, col.type,
-                                         :limit     => col.limit,
+                                         :limit     => limit,
                                          :default   => col.default,
                                          :scale     => col.scale,
                                          :precision => col.precision
Ward Vandewege cure referenced this issue from a commit in cure/acts_as_versioned
Ward Vandewege cure Fix two bugs, as listed in the issues list for technoweenie/acts_as_v…

  MySQL decimal Datatype Requires Migration With ":precision => ..."
  to Avoid "No integer type has byte size " Error

  MySQL/PosgreSQL: Index name on table is too long; the limit is 63 characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.