Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Comments

@rparker
Copy link

rparker commented Aug 31, 2009

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
Copy link

cure commented Jun 19, 2011

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 added a commit to cure/acts_as_versioned that referenced this issue Jun 19, 2011
…ersioned:

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

  technoweenie#9
  technoweenie#9
  MySQL/PosgreSQL: Index name on table is too long; the limit is 63 characters
yakjuly pushed a commit to getaroom/acts_as_versioned that referenced this issue Mar 4, 2024
Limit index name length to 63; psql NAMEDATALEN-1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants