I used a migration to add a column to my database that has a default value and a not-null constraint. Sometimes this default value is honored by postgres, sometimes it is not. When it''s not being honored, I get errors like the following from postgres: PGError: ERROR: null value in column "zoom" violates not-null constraint However, I declared this column as having a default value in my migration: add_column(:maps, :zoom, :float, { :null => false, :default => 1.0 }) I have a unit test that checks that the default zoom value is 1, but the test is failing because the zoom value is nil. However, when I create a new Map using the development environment, zoom has a valid default! % script/console test Loading test environment. console>> Map.new => #<Map:0xb7479b4c @new_record=true, @attributes={"zoom"=>nil}> % script/console development Loading development environment. console>> Map.new => #<Map:0xb7414f1c @new_record=true, @attributes={"zoom"=>1.0}> I also noticed a difference in the two database schemas when compared using pg_dump. The test schema has this column description: zoom double precision DEFAULT (1)::double precision NOT NULL, The development schema has this one: zoom double precision DEFAULT 1::double precision NOT NULL, The parenthesis around the (1) in the test schema seems to be indicative of the problem -- whenever I find this in the schema, the default value isn''t being honored. I deployed this app on a production server, and the production environment on the server does *not* have default values. Yet I checked that all the migrations are up to date, and in fact that column would not exist unless I''m at the current migration. It''s just the default value that''s missing. Help? Isn''t this supposed to Just Work? --~--~---------~--~----~------------~-------~--~----~ 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?hl=en -~----------~----~----~----~------~----~------~--~---