Closed jacquescrocker closed 6 years ago
See http://sequel.jeremyevans.net/rdoc/files/doc/schema_modification_rdoc.html#label-primary_key
In create_table
blocks, you generally use primary_key :id
to represent the entire id
column (i.e. you don't need to separately specify column :id, Integer
).
The difference is that primary_key :id
creates an auto-incrementing primary key, which isn't the case for column :id, Integer
followed by primary_key [:id]
Also, to clarify the issue in your example, there's a distinction between primary_key :id
and primary_key [:id]
. The former means that there's an auto-incrementing id column with a primary key constraint. The latter means there's a primary key constraint on an existing column named :id
(which must be specified separately by column :id
).
Your model_schema
block specifies primary_key :id
, whereas your create_table
block specifies primary_key [:id]
. That's why you're getting the error; these two are different, because the :id
column being referred to in the create_table
block is not auto-incrementing.
I'm seeing the following error on my specs. I'm running
rake test:prepare
first.Here's whats in my schema.rb