PostgreSQL 8.2.5 error
== CreateHeartrates: migrating ================================================
NOTICE: CREATE TABLE will create implicit sequence “heartrates_id_seq” for serial column “heartrates.id”
PGError: ERROR: multiple default values specified for column “id” of table “heartrates”
: CREATE TABLE heartrates (“id” serial primary key DEFAULT NULL, “user_id” integer DEFAULT NULL, “timestamp” timestamp with time zone DEFAULT NULL, “heartrate” smallint NOT NULL)
I don’t see the above error on my Lenovo Windows machine because it’s running PostgreSQL 8.2.4. The issue occurs with PostgreSQL 8.2.5
Add this to the create table migration
t.column :id, :primary_key, :null => false
This is probably the simplest way to deal with this defect.
I tried to find a good place to patch the code, but everywhere I did, I could easily imagine someone yelling, “you can’t touch that”!
For instance, if scheme_definitions.rb’s primary_key could set :null => false, then everyone should be happy, even other db’s. Except, that of course you change all db’s to ‘NOT NULL’ versus ‘DEFAULT NULL’. I don’t know why you’d want to say ‘DEFAULT NULL’ though, it seems vaguely wrong.
This seems to be still in rails 2.0 too, and is still in 1.2.6.