I have the following migration: class TestMigration < ActiveRecord::Migration def self.up create_table :apples do |t| t.column :name, :string t.column :qty, :decimal, :precision => 16, :scale => 2 end add_column :apples, :amt, :decimal, :precision => 16, :scale => 2 end def self.down drop_table :apples end end Which yields this db structure: CREATE TABLE apples ( id serial NOT NULL, name varchar(255), qty numeric(16,2), amt numeric, CONSTRAINT apples_pkey PRIMARY KEY (id) ); Is my add_column statement wrong, or is there a bug somewhere? Running latest edge -- 5086. Any feedback appreciated, Isak --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
I haven''t found :decimal to work for me. Use the following in your migration (outside the create table loop). execute "ALTER TABLE apples ADD COLUMN amt DECIMAL(16,2)" On 9/11/06, Isak Hansen <isak.hansen-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > I have the following migration: > > class TestMigration < ActiveRecord::Migration > def self.up > create_table :apples do |t| > t.column :name, :string > t.column :qty, :decimal, :precision => 16, :scale => 2 > end > add_column :apples, :amt, :decimal, :precision => 16, :scale => 2 > end > > def self.down > drop_table :apples > end > end > > > Which yields this db structure: > > CREATE TABLE apples > ( > id serial NOT NULL, > name varchar(255), > qty numeric(16,2), > amt numeric, > CONSTRAINT apples_pkey PRIMARY KEY (id) > ); > > > Is my add_column statement wrong, or is there a bug somewhere? Running > latest edge -- 5086. > > Any feedback appreciated, > Isak > > > >-- "Impossible is nothing." --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
On 9/11/06, zer0halo <zerohalo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I haven''t found :decimal to work for me. Use the following in your migration > (outside the create table loop). > > execute "ALTER TABLE apples ADD COLUMN amt DECIMAL(16,2)" >Thank you, but I should have been a little clearer. Edge rails does support decimal columns, I''m trying to figure out what goes wrong in my migration. Is it my code that''s wrong, my environment, or a bug in rails? I just ran the same migration for sqlite, with different results: CREATE TABLE apples ("id" INTEGER PRIMARY KEY NOT NULL, "name" varchar(255), "qty" decimal, "amt" decimal(16,2)); Now amt has precision/scale, while qty doesn''t.. Isak --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---