I'm having problems (acctually diferences) in the generated databases by
Rails. Here's my database.yaml:
===== database.yaml =====
defaults: &defaults
adapter: mysql
encoding: utf8
username: root
password:
socket: /tmp/mysql.sock
development:
database: gemarco_development
<<: *defaults
test:
database: gemarco_test
<<: *defaults
production:
database: gemarco
<<: *defaults
===== database.yaml =====
And the migration:
===== 20080603140348_create_creditos.rb =====
class CreateCreditos < ActiveRecord::Migration
def self.up
create_table :creditos do |t|
t.decimal :valor
end
end
def self.down
drop_table :creditos
end
end
===== 20080603140348_create_creditos.rb =====
After applying the migrations I have:
mysql> use gemarco_development;
Database changed
mysql> describe creditos;
+-------+---------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+---------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| valor | decimal(10,0) | YES | | NULL | |
+-------+---------------+------+-----+---------+----------------+
2 rows in set (0.00 sec)
That's OK for me. decimal(10,0) is what I was expecting. But the same
isn't true for the test database:
mysql> use gemarco_test;
Database changed
mysql> describe creditos;
+-------+------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------+------------+------+-----+---------+----------------+
| id | int(11) | NO | PRI | NULL | auto_increment |
| valor | bigint(10) | YES | | NULL | |
+-------+------------+------+-----+---------+----------------+
2 rows in set (0.01 sec)
It's showing bigint(10). I looked at schema.rb and this is what a found:
===== schema.rb =====
...
create_table "creditos", :force => true do |t|
t.integer "valor", :limit => 10, :precision => 10, :scale => 0
end
...
===== schema.rb =====
t.integer with :precision and :scale? What's wrong?
I readed the documentation and found that:
* MySQL: :precision [1..63], :scale [0..30]. Default is (10,0).
This is what happening in the development environment, but not in the
test environment.
I generated the development database with "rake db:migrate" and the test
database with "rake test:units".
PS: When I specify the :precision and the :scale in the migration
everything's OK.
rails --version
Rails 2.1.0
mysql --version
mysql Ver 14.12 Distrib 5.0.60, for pc-linux-gnu (i686) using readline
5.2
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---