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

Open
rparker opened this Issue Aug 31, 2009 · 1 comment

2 participants

@rparker

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

@cure

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 @@
             end

             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.name, col.type,
-                                         :limit     => col.limit,
+                                         :limit     => limit,
                                          :default   => col.default,
                                          :scale     => col.scale,
                                          :precision => col.precision
@cure cure added a commit to cure/acts_as_versioned that referenced this issue Jun 19, 2011
@cure cure Fix two bugs, as listed in the issues list for technoweenie/acts_as_v…
…ersioned:

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

  #9
  technoweenie#9
  MySQL/PosgreSQL: Index name on table is too long; the limit is 63 characters
5feb16e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment