What if I don’t want AR to automatically create an integer id for a
table’s primary key? For example, if I have a habtm connecting table
I want the primary key to cover all columns in the table? I don’t see
any info about this in the docs. Is the only way of doing this to put
in an execute rule to manually drop the previously created primary key
and create my own? It seems like this is a common enough thing that
it should be added as an option to create_table.
What if I don’t want AR to automatically create an integer id for a
table’s primary key? For example, if I have a habtm connecting table
I want the primary key to cover all columns in the table? I don’t see
any info about this in the docs. Is the only way of doing this to put
in an execute rule to manually drop the previously created primary key
and create my own? It seems like this is a common enough thing that
it should be added as an option to create_table.
It is:
create_table :join_table, :id => false do |t|
…
end
Minor nitpick: why does AR:migration make primary keys default to
null? I always thought that primary keys should never be null.
Which adapter? I just verified that sqlite and mysql both do NOT NULL
for the primary keys. If there is an adapter doing otherwise, it
probably ought to be submitted as a bug.
Okay, I get it. I guess it doesn’t matter then, but it would be less
confusing if migrations added a default 0 for all non-null integers.
No big deal though. THanks.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.